Browse Source

Workorders cleared with hireling removal.

combat-2
MagicBot 8 months ago
parent
commit
408e3a45ca
  1. 2
      src/engine/devcmd/cmds/InfoCmd.java
  2. 12
      src/engine/devcmd/cmds/PurgeObjectsCmd.java
  3. 12
      src/engine/devcmd/cmds/RemoveObjectCmd.java
  4. 47
      src/engine/gameManager/BuildingManager.java
  5. 2
      src/engine/mobileAI/MobAI.java
  6. 3
      src/engine/mobileAI/utilities/MovementUtilities.java
  7. 10
      src/engine/net/client/handlers/MinionTrainingMsgHandler.java
  8. 6
      src/engine/objects/AbstractIntelligenceAgent.java
  9. 5
      src/engine/objects/NPC.java
  10. 6
      src/engine/objects/PlayerCharacter.java

2
src/engine/devcmd/cmds/InfoCmd.java

@ -475,7 +475,7 @@ public class InfoCmd extends AbstractDevCmd {
output += "EquipSet: " + targetMob.equipmentSetID; output += "EquipSet: " + targetMob.equipmentSetID;
output += newline; output += newline;
try { try {
output += "Parent Zone LoadNum : " + targetMob.getParentZone().templateID; output += "Parent Zone LoadNum : " + targetMob.parentZone.templateID;
} catch (Exception ex) { } catch (Exception ex) {
//who cares //who cares
} }

12
src/engine/devcmd/cmds/PurgeObjectsCmd.java

@ -64,9 +64,10 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
WorldGrid.RemoveWorldObject(mob); WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc); WorldGrid.removeObject(mob, pc);
if (mob.getParentZone() != null) if (mob.getParentZone() != null) {
mob.getParentZone().zoneMobSet.remove(mob); mob.getParentZone().zoneMobSet.remove(mob);
} }
}
DbManager.NPCQueries.DELETE_NPC(npc); DbManager.NPCQueries.DELETE_NPC(npc);
DbManager.removeFromCache(GameObjectType.NPC, DbManager.removeFromCache(GameObjectType.NPC,
@ -78,9 +79,10 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
WorldGrid.RemoveWorldObject(mob); WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc); WorldGrid.removeObject(mob, pc);
if (mob.getParentZone() != null) if (mob.getParentZone() != null) {
mob.getParentZone().zoneMobSet.remove(mob); mob.getParentZone().zoneMobSet.remove(mob);
} }
}
DbManager.MobQueries.DELETE_MOB(mobA); DbManager.MobQueries.DELETE_MOB(mobA);
DbManager.removeFromCache(GameObjectType.Mob, DbManager.removeFromCache(GameObjectType.Mob,
mobA.getObjectUUID()); mobA.getObjectUUID());
@ -159,9 +161,10 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
WorldGrid.RemoveWorldObject(mob); WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc); WorldGrid.removeObject(mob, pc);
if (mob.getParentZone() != null) if (mob.getParentZone() != null) {
mob.getParentZone().zoneMobSet.remove(mob); mob.getParentZone().zoneMobSet.remove(mob);
} }
}
DbManager.NPCQueries.DELETE_NPC(npc); DbManager.NPCQueries.DELETE_NPC(npc);
DbManager.removeFromCache(mbEnums.GameObjectType.NPC, DbManager.removeFromCache(mbEnums.GameObjectType.NPC,
npc.getObjectUUID()); npc.getObjectUUID());
@ -172,9 +175,10 @@ public class PurgeObjectsCmd extends AbstractDevCmd {
WorldGrid.RemoveWorldObject(mob); WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc); WorldGrid.removeObject(mob, pc);
if (mob.getParentZone() != null) if (mob.getParentZone() != null) {
mob.getParentZone().zoneMobSet.remove(mob); mob.getParentZone().zoneMobSet.remove(mob);
} }
}
DbManager.MobQueries.DELETE_MOB(mobA); DbManager.MobQueries.DELETE_MOB(mobA);
DbManager.removeFromCache(mbEnums.GameObjectType.Mob, DbManager.removeFromCache(mbEnums.GameObjectType.Mob,
mobA.getObjectUUID()); mobA.getObjectUUID());

12
src/engine/devcmd/cmds/RemoveObjectCmd.java

@ -180,9 +180,10 @@ public class RemoveObjectCmd extends AbstractDevCmd {
WorldGrid.RemoveWorldObject(minionMob); WorldGrid.RemoveWorldObject(minionMob);
WorldGrid.removeObject(minionMob, pc); WorldGrid.removeObject(minionMob, pc);
if (minionMob.getParentZone() != null) if (minionMob.getParentZone() != null) {
minionMob.getParentZone().zoneMobSet.remove(minionMob); minionMob.getParentZone().zoneMobSet.remove(minionMob);
} }
}
DbManager.NPCQueries.DELETE_NPC(npc); DbManager.NPCQueries.DELETE_NPC(npc);
DbManager.removeFromCache(npc); DbManager.removeFromCache(npc);
@ -202,10 +203,12 @@ public class RemoveObjectCmd extends AbstractDevCmd {
return; return;
} }
if (mob.getParentZone() != null && mob.getParentZone() != currentZone && !mob.isPet() && !mob.isNecroPet()) { 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."); this.throwbackError(pc, "Error 376954: Could not Remove Mob.Mob is not in the same zone as player.");
return; return;
} }
}
// Remove npc from hirelings list. // Remove npc from hirelings list.
@ -222,8 +225,9 @@ public class RemoveObjectCmd extends AbstractDevCmd {
WorldGrid.RemoveWorldObject(mob); WorldGrid.RemoveWorldObject(mob);
WorldGrid.removeObject(mob, pc); WorldGrid.removeObject(mob, pc);
if (mob.getParentZone() != null) if (mob.parentZone != null) {
mob.getParentZone().zoneMobSet.remove(mob); mob.parentZone.zoneMobSet.remove(mob);
}
ChatManager.chatSayInfo(pc, ChatManager.chatSayInfo(pc,
"Mob with ID " + mob.getDBID() + " removed"); "Mob with ID " + mob.getDBID() + " removed");

47
src/engine/gameManager/BuildingManager.java

@ -14,6 +14,7 @@ import engine.InterestManagement.WorldGrid;
import engine.job.JobContainer; import engine.job.JobContainer;
import engine.job.JobScheduler; import engine.job.JobScheduler;
import engine.jobs.UpgradeBuildingJob; import engine.jobs.UpgradeBuildingJob;
import engine.loot.WorkOrder;
import engine.math.Bounds; import engine.math.Bounds;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.mbEnums; import engine.mbEnums;
@ -49,8 +50,7 @@ public enum BuildingManager {
// Some meshes might not have slot locations assigned. // Some meshes might not have slot locations assigned.
if (slotLocations == null || if (slotLocations == null || slotLocations.isEmpty())
slotLocations.isEmpty())
return -1; return -1;
int numOfSlots = _slotLocations.get(building.meshUUID).size(); int numOfSlots = _slotLocations.get(building.meshUUID).size();
@ -69,8 +69,7 @@ public enum BuildingManager {
// Some meshes might not have slot locations assigned. // Some meshes might not have slot locations assigned.
if (slotLocations == null || if (slotLocations == null || slotLocations.isEmpty())
slotLocations.isEmpty())
return -1; return -1;
int numOfSlots = _slotLocations.get(building.meshUUID).size(); int numOfSlots = _slotLocations.get(building.meshUUID).size();
@ -127,22 +126,16 @@ public enum BuildingManager {
if (building.getGuild().isGuildLeader(player.getObjectUUID())) if (building.getGuild().isGuildLeader(player.getObjectUUID()))
return true; return true;
if (building.getFriends().get(player.getGuild().getObjectUUID()) != null if (building.getFriends().get(player.getGuild().getObjectUUID()) != null && building.getFriends().get(player.getGuild().getObjectUUID()).friendType == 8)
&& building.getFriends().get(player.getGuild().getObjectUUID()).friendType == 8)
return true; return true;
if (building.getFriends().get(player.getGuild().getObjectUUID()) != null if (building.getFriends().get(player.getGuild().getObjectUUID()) != null && building.getFriends().get(player.getGuild().getObjectUUID()).friendType == 9 && GuildStatusController.isInnerCouncil(player.getGuildStatus()))
&& building.getFriends().get(player.getGuild().getObjectUUID()).friendType == 9
&& GuildStatusController.isInnerCouncil(player.getGuildStatus()))
return true; return true;
if (Guild.sameGuild(building.getGuild(), player.getGuild()) && GuildStatusController.isInnerCouncil(player.getGuildStatus())) if (Guild.sameGuild(building.getGuild(), player.getGuild()) && GuildStatusController.isInnerCouncil(player.getGuildStatus()))
return true; return true;
if (Guild.sameGuild(building.getGuild(), player.getGuild()) && GuildStatusController.isGuildLeader(player.getGuildStatus())) return Guild.sameGuild(building.getGuild(), player.getGuild()) && GuildStatusController.isGuildLeader(player.getGuildStatus());
return true;
return false;
//TODO test friends list once added //TODO test friends list once added
//does not meet above criteria. Cannot access. //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. //Somehow guild leader check fails? lets check if Player is true Guild GL.
if (building.getGuild() != null && building.getGuild().isGuildLeader(player.getObjectUUID())) if (building.getGuild() != null && building.getGuild().isGuildLeader(player.getObjectUUID()))
return true; return true;
if (GuildStatusController.isGuildLeader(player.getGuildStatus()) == false && GuildStatusController.isInnerCouncil(player.getGuildStatus()) == false) if (!GuildStatusController.isGuildLeader(player.getGuildStatus()) && !GuildStatusController.isInnerCouncil(player.getGuildStatus()))
return false; return false;
@ -274,9 +267,7 @@ public enum BuildingManager {
// Submit upgrade job for future date or current instant // Submit upgrade job for future date or current instant
if (building.getUpgradeDateTime().isAfter(LocalDateTime.now())) { if (building.getUpgradeDateTime().isAfter(LocalDateTime.now())) {
JobContainer jc = JobScheduler.getInstance().scheduleJob(new UpgradeBuildingJob(building), JobContainer jc = JobScheduler.getInstance().scheduleJob(new UpgradeBuildingJob(building), building.getUpgradeDateTime().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
building.getUpgradeDateTime().atZone(ZoneId.systemDefault())
.toInstant().toEpochMilli());
} else } else
JobScheduler.getInstance().scheduleJob(new UpgradeBuildingJob(building), 0); JobScheduler.getInstance().scheduleJob(new UpgradeBuildingJob(building), 0);
} }
@ -335,10 +326,16 @@ public enum BuildingManager {
WorldGrid.RemoveWorldObject(minionMob); WorldGrid.RemoveWorldObject(minionMob);
WorldGrid.unloadObject(minionMob); WorldGrid.unloadObject(minionMob);
if (minionMob.getParentZone() != null) if (minionMob.parentZone != null)
minionMob.getParentZone().zoneMobSet.remove(minionMob); 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 // Remove hireling from building
building.getHirelings().remove(hireling); building.getHirelings().remove(hireling);
@ -349,9 +346,11 @@ public enum BuildingManager {
Mob hirelingMob = (Mob) hireling; Mob hirelingMob = (Mob) hireling;
if (hirelingMob.getParentZone() != null) if (hirelingMob.parentZone != null) {
if (hirelingMob.getParentZone().zoneMobSet.contains(hirelingMob)) if (hirelingMob.parentZone.zoneMobSet.contains(hirelingMob)) {
hirelingMob.getParentZone().zoneMobSet.remove(hireling); hirelingMob.parentZone.zoneMobSet.remove(hireling);
}
}
} }
@ -451,7 +450,7 @@ public enum BuildingManager {
if (!Guild.sameGuild(building.getGuild(), player.getGuild())) if (!Guild.sameGuild(building.getGuild(), player.getGuild()))
return false; 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. //This is mainly used for Rolling and gold sharing between building and warehouse.
@ -825,7 +824,7 @@ public enum BuildingManager {
else else
success = DbManager.BuildingQueries.updateBuildingRank(building, rank); success = DbManager.BuildingQueries.updateBuildingRank(building, rank);
if (success == false) { if (!success) {
Logger.error("Error writing to database UUID: " + building.getObjectUUID()); Logger.error("Error writing to database UUID: " + building.getObjectUUID());
return; return;
} }

2
src/engine/mobileAI/MobAI.java

@ -432,7 +432,7 @@ public class MobAI {
ChatManager.chatSayInfo(null, mob.getName() + " calls for help!"); ChatManager.chatSayInfo(null, mob.getName() + " calls for help!");
Zone mobCamp = mob.getParentZone(); Zone mobCamp = mob.parentZone;
for (Mob helper : mobCamp.zoneMobSet) { for (Mob helper : mobCamp.zoneMobSet) {
if (helper.behaviourType.respondsToCallForHelp && helper.behaviourType.BehaviourHelperType.equals(mob.behaviourType)) { if (helper.behaviourType.respondsToCallForHelp && helper.behaviourType.BehaviourHelperType.equals(mob.behaviourType)) {

3
src/engine/mobileAI/utilities/MovementUtilities.java

@ -68,9 +68,10 @@ public class MovementUtilities {
float zoneRange = 250; float zoneRange = 250;
if (agent.getParentZone() != null) { if (agent.getParentZone() != null) {
if (agent.getParentZone().bounds != null) if (agent.getParentZone().bounds != null) {
zoneRange = agent.getParentZone().bounds.getHalfExtents().x * 2; zoneRange = agent.getParentZone().bounds.getHalfExtents().x * 2;
} }
}
if (zoneRange > 300) if (zoneRange > 300)
zoneRange = 300; zoneRange = 300;

10
src/engine/net/client/handlers/MinionTrainingMsgHandler.java

@ -65,8 +65,9 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
WorldGrid.RemoveWorldObject(toRemove); WorldGrid.RemoveWorldObject(toRemove);
if (toRemove.getParentZone() != null) if (toRemove.getParentZone() != null) {
toRemove.getParentZone().zoneMobSet.remove(toRemove); toRemove.getParentZone().zoneMobSet.remove(toRemove);
}
DbManager.removeFromCache(toRemove); DbManager.removeFromCache(toRemove);
@ -189,8 +190,9 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
WorldGrid.RemoveWorldObject(toRemove); WorldGrid.RemoveWorldObject(toRemove);
if (toRemove.getParentZone() != null) if (toRemove.parentZone != null) {
toRemove.getParentZone().zoneMobSet.remove(toRemove); toRemove.parentZone.zoneMobSet.remove(toRemove);
}
DbManager.removeFromCache(toRemove); DbManager.removeFromCache(toRemove);
@ -227,7 +229,7 @@ public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
//Add Minion //Add Minion
} else { } else {
Zone zone = npc.getParentZone(); Zone zone = npc.parentZone;
if (zone == null) if (zone == null)
return true; return true;

6
src/engine/objects/AbstractIntelligenceAgent.java

@ -154,9 +154,11 @@ public abstract class AbstractIntelligenceAgent extends AbstractCharacter {
WorldGrid.RemoveWorldObject(this); WorldGrid.RemoveWorldObject(this);
if (this.getObjectType() == GameObjectType.Mob) if (this.getObjectType() == GameObjectType.Mob) {
if (((Mob) this).getParentZone() != null) if (((Mob) this).getParentZone() != null) {
((Mob) this).getParentZone().zoneMobSet.remove(this); ((Mob) this).getParentZone().zoneMobSet.remove(this);
}
}
} else { //revert charmed pet } else { //revert charmed pet
this.agentType = mbEnums.AIAgentType.MOBILE; this.agentType = mbEnums.AIAgentType.MOBILE;

5
src/engine/objects/NPC.java

@ -651,8 +651,9 @@ public class NPC extends AbstractCharacter {
Logger.error(e.getMessage()); Logger.error(e.getMessage());
} }
if (minionMob.getParentZone() != null) if (minionMob.parentZone != null) {
minionMob.getParentZone().zoneMobSet.remove(minionMob); minionMob.parentZone.zoneMobSet.remove(minionMob);
}
WorldGrid.RemoveWorldObject(minionMob); WorldGrid.RemoveWorldObject(minionMob);
DbManager.removeFromCache(minionMob); DbManager.removeFromCache(minionMob);

6
src/engine/objects/PlayerCharacter.java

@ -4172,9 +4172,9 @@ public class PlayerCharacter extends AbstractCharacter {
currentPet.setCombatTarget(null); currentPet.setCombatTarget(null);
if (currentPet.getParentZone() != null) if (currentPet.parentZone != null) {
currentPet.parentZone.zoneMobSet.remove(currentPet);
currentPet.getParentZone().zoneMobSet.remove(currentPet); }
try { try {
currentPet.clearEffects(); currentPet.clearEffects();

Loading…
Cancel
Save