diff --git a/src/engine/gameManager/NPCManager.java b/src/engine/gameManager/NPCManager.java index f8c61771..7b1241fb 100644 --- a/src/engine/gameManager/NPCManager.java +++ b/src/engine/gameManager/NPCManager.java @@ -119,82 +119,6 @@ public enum NPCManager { playerCharacter.necroPets.clear(); } - - public static void removeSiegeMinions(Mob mobile) { - - for (Integer minionUUID : mobile.minions) { - - Mob siegeMinion = Mob.getMob(minionUUID); - - if (mobile.isMoving()) { - - mobile.stopMovement(mobile.getLoc()); - - if (siegeMinion.parentZone != null) - siegeMinion.parentZone.zoneMobSet.remove(siegeMinion); - } - - try { - siegeMinion.clearEffects(); - } catch (Exception e) { - Logger.error(e.getMessage()); - } - - if (siegeMinion.parentZone != null) - siegeMinion.parentZone.zoneMobSet.remove(siegeMinion); - - WorldGrid.RemoveWorldObject(siegeMinion); - WorldGrid.removeObject(siegeMinion); - DbManager.removeFromCache(siegeMinion); - - - PlayerCharacter petOwner = (PlayerCharacter) siegeMinion.guardCaptain; - - if (petOwner != null) { - - petOwner.setPet(null); - - siegeMinion.guardCaptain = null; - - PetMsg petMsg = new PetMsg(5, null); - Dispatch dispatch = Dispatch.borrow(petOwner, petMsg); - DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY); - } - } - } - - public static boolean removeMobileFromBuilding(Mob mobile, Building building) { - - // Remove npc from it's building - - try { - mobile.clearEffects(); - } catch (Exception e) { - Logger.error(e.getMessage()); - } - - if (mobile.parentZone != null) - mobile.parentZone.zoneMobSet.remove(mobile); - - if (building != null) { - building.getHirelings().remove(mobile); - removeSiegeMinions(mobile); - } - - // Delete npc from database - - if (DbManager.MobQueries.DELETE_MOB(mobile) == 0) - return false; - - // Remove npc from the simulation - - mobile.removeFromCache(); - DbManager.removeFromCache(mobile); - WorldGrid.RemoveWorldObject(mobile); - WorldGrid.removeObject(mobile); - return true; - } - public static void loadAllPirateNames() { DbManager.NPCQueries.LOAD_PIRATE_NAMES(); diff --git a/src/engine/net/client/handlers/OrderNPCMsgHandler.java b/src/engine/net/client/handlers/OrderNPCMsgHandler.java index 802e302d..e26933ab 100644 --- a/src/engine/net/client/handlers/OrderNPCMsgHandler.java +++ b/src/engine/net/client/handlers/OrderNPCMsgHandler.java @@ -7,7 +7,6 @@ import engine.Enum.ProfitType; import engine.exception.MsgSendException; import engine.gameManager.BuildingManager; import engine.gameManager.DbManager; -import engine.gameManager.NPCManager; import engine.gameManager.SessionManager; import engine.math.FastMath; import engine.math.Vector3fImmutable; @@ -37,7 +36,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { super(OrderNPCMsg.class); } - public static void processRedeedHireling(Mob hireling, Building building, ClientConnection origin) { + public static void processRedeedHireling(AbstractCharacter hireling, Building building, ClientConnection origin) { PlayerCharacter player; Contract contract; @@ -48,7 +47,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { player = SessionManager.getPlayerCharacter(origin); itemMan = player.getCharItemManager(); - contract = hireling.getContract(); + contract = hireling.contract; if (!player.getCharItemManager().hasRoomInventory((short) 1)) { ErrorPopupMsg.sendErrorPopup(player, 21); @@ -277,28 +276,6 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { } } - private static synchronized void processRedeedNPC(AbstractCharacter abstractCharacter, Building building, ClientConnection origin) { - - // Member variable declaration - - switch (abstractCharacter.getObjectType()) { - case NPC: - NPC npc = (NPC) abstractCharacter; - - Building cityBuilding = npc.getBuilding(); - - if (cityBuilding == null) - return; - - BuildingManager.processRedeedNPC(npc, npc.building, origin); - break; - case Mob: - Mob mob = (Mob) abstractCharacter; - processRedeedHireling(mob, mob.building, origin); - break; - } - } - private static boolean AddPatrolPoints(int buildingID, ArrayList patrolPoints) { Building building = BuildingManager.getBuildingFromCache(buildingID); @@ -489,7 +466,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { if (BuildingManager.PlayerCanControlNotOwner(building, player) == false) return true; - processRedeedNPC(npc, building, origin); + processRedeedHireling(npc, building, origin); return true; //MB TODO HANDLE all profits. case 7: @@ -557,10 +534,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { if (building.getHirelings().containsKey(mob) == false) return true; - if (NPCManager.removeMobileFromBuilding(mob, building) == false) { - PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "A Serious error has occurred. Please post details for to ensure transaction integrity"); - return true; - } + BuildingManager.removeHireling(building, mob); ManageCityAssetsMsg manageCityAssetsMsg = new ManageCityAssetsMsg(); manageCityAssetsMsg.actionType = SVR_CLOSE_WINDOW; @@ -595,7 +569,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { if (BuildingManager.PlayerCanControlNotOwner(building, player) == false) return true; - processRedeedNPC(mob, building, origin); + processRedeedHireling(mob, building, origin); return true; //MB TODO HANDLE all profits. case 7: