From 408e3a45ca1e52676a304fdfecf16a89f8fe6ed7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 11 May 2024 07:51:56 -0400 Subject: [PATCH] Workorders cleared with hireling removal. --- src/engine/devcmd/cmds/InfoCmd.java | 2 +- src/engine/devcmd/cmds/PurgeObjectsCmd.java | 12 +++-- src/engine/devcmd/cmds/RemoveObjectCmd.java | 16 ++++--- src/engine/gameManager/BuildingManager.java | 47 +++++++++---------- src/engine/mobileAI/MobAI.java | 2 +- .../mobileAI/utilities/MovementUtilities.java | 3 +- .../handlers/MinionTrainingMsgHandler.java | 10 ++-- .../objects/AbstractIntelligenceAgent.java | 6 ++- src/engine/objects/NPC.java | 5 +- src/engine/objects/PlayerCharacter.java | 6 +-- 10 files changed, 61 insertions(+), 48 deletions(-) diff --git a/src/engine/devcmd/cmds/InfoCmd.java b/src/engine/devcmd/cmds/InfoCmd.java index 3d7fead5..ce9d36d1 100644 --- a/src/engine/devcmd/cmds/InfoCmd.java +++ b/src/engine/devcmd/cmds/InfoCmd.java @@ -475,7 +475,7 @@ public class InfoCmd extends AbstractDevCmd { output += "EquipSet: " + targetMob.equipmentSetID; output += newline; try { - output += "Parent Zone LoadNum : " + targetMob.getParentZone().templateID; + output += "Parent Zone LoadNum : " + targetMob.parentZone.templateID; } catch (Exception ex) { //who cares } diff --git a/src/engine/devcmd/cmds/PurgeObjectsCmd.java b/src/engine/devcmd/cmds/PurgeObjectsCmd.java index 2725eb37..c362f023 100644 --- a/src/engine/devcmd/cmds/PurgeObjectsCmd.java +++ b/src/engine/devcmd/cmds/PurgeObjectsCmd.java @@ -64,8 +64,9 @@ public class PurgeObjectsCmd extends AbstractDevCmd { WorldGrid.RemoveWorldObject(mob); WorldGrid.removeObject(mob, pc); - if (mob.getParentZone() != null) + if (mob.getParentZone() != null) { mob.getParentZone().zoneMobSet.remove(mob); + } } DbManager.NPCQueries.DELETE_NPC(npc); @@ -78,8 +79,9 @@ public class PurgeObjectsCmd extends AbstractDevCmd { WorldGrid.RemoveWorldObject(mob); WorldGrid.removeObject(mob, pc); - if (mob.getParentZone() != null) + if (mob.getParentZone() != null) { mob.getParentZone().zoneMobSet.remove(mob); + } } DbManager.MobQueries.DELETE_MOB(mobA); DbManager.removeFromCache(GameObjectType.Mob, @@ -159,8 +161,9 @@ public class PurgeObjectsCmd extends AbstractDevCmd { WorldGrid.RemoveWorldObject(mob); WorldGrid.removeObject(mob, pc); - if (mob.getParentZone() != null) + if (mob.getParentZone() != null) { mob.getParentZone().zoneMobSet.remove(mob); + } } DbManager.NPCQueries.DELETE_NPC(npc); DbManager.removeFromCache(mbEnums.GameObjectType.NPC, @@ -172,8 +175,9 @@ public class PurgeObjectsCmd extends AbstractDevCmd { WorldGrid.RemoveWorldObject(mob); WorldGrid.removeObject(mob, pc); - if (mob.getParentZone() != null) + if (mob.getParentZone() != null) { mob.getParentZone().zoneMobSet.remove(mob); + } } DbManager.MobQueries.DELETE_MOB(mobA); DbManager.removeFromCache(mbEnums.GameObjectType.Mob, diff --git a/src/engine/devcmd/cmds/RemoveObjectCmd.java b/src/engine/devcmd/cmds/RemoveObjectCmd.java index 3b55edcd..6ed4d35c 100644 --- a/src/engine/devcmd/cmds/RemoveObjectCmd.java +++ b/src/engine/devcmd/cmds/RemoveObjectCmd.java @@ -180,8 +180,9 @@ public class RemoveObjectCmd extends AbstractDevCmd { WorldGrid.RemoveWorldObject(minionMob); WorldGrid.removeObject(minionMob, pc); - if (minionMob.getParentZone() != null) + if (minionMob.getParentZone() != null) { minionMob.getParentZone().zoneMobSet.remove(minionMob); + } } DbManager.NPCQueries.DELETE_NPC(npc); @@ -202,9 +203,11 @@ public class RemoveObjectCmd extends AbstractDevCmd { return; } - if (mob.getParentZone() != null && mob.getParentZone() != currentZone && !mob.isPet() && !mob.isNecroPet()) { - this.throwbackError(pc, "Error 376954: Could not Remove Mob.Mob is not in the same zone as player."); - return; + if (mob.getParentZone() != null) { + if (mob.parentZone != currentZone && !mob.isPet() && !mob.isNecroPet()) { + this.throwbackError(pc, "Error 376954: Could not Remove Mob.Mob is not in the same zone as player."); + return; + } } // Remove npc from hirelings list. @@ -222,8 +225,9 @@ public class RemoveObjectCmd extends AbstractDevCmd { WorldGrid.RemoveWorldObject(mob); WorldGrid.removeObject(mob, pc); - if (mob.getParentZone() != null) - mob.getParentZone().zoneMobSet.remove(mob); + if (mob.parentZone != null) { + mob.parentZone.zoneMobSet.remove(mob); + } ChatManager.chatSayInfo(pc, "Mob with ID " + mob.getDBID() + " removed"); diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index d14e3d99..6131dc04 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -14,6 +14,7 @@ import engine.InterestManagement.WorldGrid; import engine.job.JobContainer; import engine.job.JobScheduler; import engine.jobs.UpgradeBuildingJob; +import engine.loot.WorkOrder; import engine.math.Bounds; import engine.math.Vector3fImmutable; import engine.mbEnums; @@ -49,8 +50,7 @@ public enum BuildingManager { // Some meshes might not have slot locations assigned. - if (slotLocations == null || - slotLocations.isEmpty()) + if (slotLocations == null || slotLocations.isEmpty()) return -1; int numOfSlots = _slotLocations.get(building.meshUUID).size(); @@ -69,8 +69,7 @@ public enum BuildingManager { // Some meshes might not have slot locations assigned. - if (slotLocations == null || - slotLocations.isEmpty()) + if (slotLocations == null || slotLocations.isEmpty()) return -1; int numOfSlots = _slotLocations.get(building.meshUUID).size(); @@ -127,22 +126,16 @@ public enum BuildingManager { if (building.getGuild().isGuildLeader(player.getObjectUUID())) return true; - if (building.getFriends().get(player.getGuild().getObjectUUID()) != null - && building.getFriends().get(player.getGuild().getObjectUUID()).friendType == 8) + if (building.getFriends().get(player.getGuild().getObjectUUID()) != null && building.getFriends().get(player.getGuild().getObjectUUID()).friendType == 8) return true; - if (building.getFriends().get(player.getGuild().getObjectUUID()) != null - && building.getFriends().get(player.getGuild().getObjectUUID()).friendType == 9 - && GuildStatusController.isInnerCouncil(player.getGuildStatus())) + if (building.getFriends().get(player.getGuild().getObjectUUID()) != null && building.getFriends().get(player.getGuild().getObjectUUID()).friendType == 9 && GuildStatusController.isInnerCouncil(player.getGuildStatus())) return true; if (Guild.sameGuild(building.getGuild(), player.getGuild()) && GuildStatusController.isInnerCouncil(player.getGuildStatus())) return true; - if (Guild.sameGuild(building.getGuild(), player.getGuild()) && GuildStatusController.isGuildLeader(player.getGuildStatus())) - return true; - - return false; + return Guild.sameGuild(building.getGuild(), player.getGuild()) && GuildStatusController.isGuildLeader(player.getGuildStatus()); //TODO test friends list once added //does not meet above criteria. Cannot access. @@ -168,7 +161,7 @@ public enum BuildingManager { //Somehow guild leader check fails? lets check if Player is true Guild GL. if (building.getGuild() != null && building.getGuild().isGuildLeader(player.getObjectUUID())) return true; - if (GuildStatusController.isGuildLeader(player.getGuildStatus()) == false && GuildStatusController.isInnerCouncil(player.getGuildStatus()) == false) + if (!GuildStatusController.isGuildLeader(player.getGuildStatus()) && !GuildStatusController.isInnerCouncil(player.getGuildStatus())) return false; @@ -274,9 +267,7 @@ public enum BuildingManager { // Submit upgrade job for future date or current instant if (building.getUpgradeDateTime().isAfter(LocalDateTime.now())) { - JobContainer jc = JobScheduler.getInstance().scheduleJob(new UpgradeBuildingJob(building), - building.getUpgradeDateTime().atZone(ZoneId.systemDefault()) - .toInstant().toEpochMilli()); + JobContainer jc = JobScheduler.getInstance().scheduleJob(new UpgradeBuildingJob(building), building.getUpgradeDateTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()); } else JobScheduler.getInstance().scheduleJob(new UpgradeBuildingJob(building), 0); } @@ -335,10 +326,16 @@ public enum BuildingManager { WorldGrid.RemoveWorldObject(minionMob); WorldGrid.unloadObject(minionMob); - if (minionMob.getParentZone() != null) - minionMob.getParentZone().zoneMobSet.remove(minionMob); + if (minionMob.parentZone != null) + minionMob.parentZone.zoneMobSet.remove(minionMob); } + // Clear all workorders for this hireling + if (hireling.getObjectType().equals(GameObjectType.NPC)) + if (ForgeManager.vendorWorkOrderLookup.contains(hireling)) + for (WorkOrder workOrder : ForgeManager.vendorWorkOrderLookup.get(hireling)) + DbManager.WarehouseQueries.DELETE_WORKORDER(workOrder); + // Remove hireling from building building.getHirelings().remove(hireling); @@ -349,9 +346,11 @@ public enum BuildingManager { Mob hirelingMob = (Mob) hireling; - if (hirelingMob.getParentZone() != null) - if (hirelingMob.getParentZone().zoneMobSet.contains(hirelingMob)) - hirelingMob.getParentZone().zoneMobSet.remove(hireling); + if (hirelingMob.parentZone != null) { + if (hirelingMob.parentZone.zoneMobSet.contains(hirelingMob)) { + hirelingMob.parentZone.zoneMobSet.remove(hireling); + } + } } @@ -451,7 +450,7 @@ public enum BuildingManager { if (!Guild.sameGuild(building.getGuild(), player.getGuild())) return false; - return GuildStatusController.isGuildLeader(player.getGuildStatus()) != false || GuildStatusController.isInnerCouncil(player.getGuildStatus()) != false; + return GuildStatusController.isGuildLeader(player.getGuildStatus()) || GuildStatusController.isInnerCouncil(player.getGuildStatus()); } //This is mainly used for Rolling and gold sharing between building and warehouse. @@ -825,7 +824,7 @@ public enum BuildingManager { else success = DbManager.BuildingQueries.updateBuildingRank(building, rank); - if (success == false) { + if (!success) { Logger.error("Error writing to database UUID: " + building.getObjectUUID()); return; } diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 86dcc870..4200b909 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -432,7 +432,7 @@ public class MobAI { ChatManager.chatSayInfo(null, mob.getName() + " calls for help!"); - Zone mobCamp = mob.getParentZone(); + Zone mobCamp = mob.parentZone; for (Mob helper : mobCamp.zoneMobSet) { if (helper.behaviourType.respondsToCallForHelp && helper.behaviourType.BehaviourHelperType.equals(mob.behaviourType)) { diff --git a/src/engine/mobileAI/utilities/MovementUtilities.java b/src/engine/mobileAI/utilities/MovementUtilities.java index 999a74ed..4a48bae1 100644 --- a/src/engine/mobileAI/utilities/MovementUtilities.java +++ b/src/engine/mobileAI/utilities/MovementUtilities.java @@ -68,8 +68,9 @@ public class MovementUtilities { float zoneRange = 250; if (agent.getParentZone() != null) { - if (agent.getParentZone().bounds != null) + if (agent.getParentZone().bounds != null) { zoneRange = agent.getParentZone().bounds.getHalfExtents().x * 2; + } } if (zoneRange > 300) diff --git a/src/engine/net/client/handlers/MinionTrainingMsgHandler.java b/src/engine/net/client/handlers/MinionTrainingMsgHandler.java index fa92c5f0..917d0201 100644 --- a/src/engine/net/client/handlers/MinionTrainingMsgHandler.java +++ b/src/engine/net/client/handlers/MinionTrainingMsgHandler.java @@ -65,8 +65,9 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { WorldGrid.RemoveWorldObject(toRemove); - if (toRemove.getParentZone() != null) + if (toRemove.getParentZone() != null) { toRemove.getParentZone().zoneMobSet.remove(toRemove); + } DbManager.removeFromCache(toRemove); @@ -189,8 +190,9 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { WorldGrid.RemoveWorldObject(toRemove); - if (toRemove.getParentZone() != null) - toRemove.getParentZone().zoneMobSet.remove(toRemove); + if (toRemove.parentZone != null) { + toRemove.parentZone.zoneMobSet.remove(toRemove); + } DbManager.removeFromCache(toRemove); @@ -227,7 +229,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler { //Add Minion } else { - Zone zone = npc.getParentZone(); + Zone zone = npc.parentZone; if (zone == null) return true; diff --git a/src/engine/objects/AbstractIntelligenceAgent.java b/src/engine/objects/AbstractIntelligenceAgent.java index 3198e014..f9800b35 100644 --- a/src/engine/objects/AbstractIntelligenceAgent.java +++ b/src/engine/objects/AbstractIntelligenceAgent.java @@ -154,9 +154,11 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter { WorldGrid.RemoveWorldObject(this); - if (this.getObjectType() == GameObjectType.Mob) - if (((Mob) this).getParentZone() != null) + if (this.getObjectType() == GameObjectType.Mob) { + if (((Mob) this).getParentZone() != null) { ((Mob) this).getParentZone().zoneMobSet.remove(this); + } + } } else { //revert charmed pet this.agentType = mbEnums.AIAgentType.MOBILE; diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 94180f65..b5c6db6e 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -651,8 +651,9 @@ public class NPC extends AbstractCharacter { Logger.error(e.getMessage()); } - if (minionMob.getParentZone() != null) - minionMob.getParentZone().zoneMobSet.remove(minionMob); + if (minionMob.parentZone != null) { + minionMob.parentZone.zoneMobSet.remove(minionMob); + } WorldGrid.RemoveWorldObject(minionMob); DbManager.removeFromCache(minionMob); diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java index c728fc0c..b93e2d13 100644 --- a/src/engine/objects/PlayerCharacter.java +++ b/src/engine/objects/PlayerCharacter.java @@ -4172,9 +4172,9 @@ public class PlayerCharacter extends AbstractCharacter { currentPet.setCombatTarget(null); - if (currentPet.getParentZone() != null) - - currentPet.getParentZone().zoneMobSet.remove(currentPet); + if (currentPet.parentZone != null) { + currentPet.parentZone.zoneMobSet.remove(currentPet); + } try { currentPet.clearEffects();