Browse Source

Make sure no memory leaks

combat-2
MagicBot 8 months ago
parent
commit
25f522c539
  1. 13
      src/engine/gameManager/BuildingManager.java

13
src/engine/gameManager/BuildingManager.java

@ -334,12 +334,25 @@ public enum BuildingManager { @@ -334,12 +334,25 @@ public enum BuildingManager {
NPC hirelingNPC = (NPC) hireling;
if (ForgeManager.vendorWorkOrderLookup.get(hirelingNPC) != null)
for (WorkOrder workOrder : ForgeManager.vendorWorkOrderLookup.get(hirelingNPC)) {
workOrder.runCompleted.set(true);
workOrder.vendor = null;
// Remove any cooking items from collections
// to ensure we don't leak memory.
for (Item item : workOrder.cooking)
ForgeManager.itemWorkOrderLookup.remove(item);
DbManager.WarehouseQueries.DELETE_WORKORDER(workOrder);
}
// Finally remove the NPC from ForgeManager
ForgeManager.vendorWorkOrderLookup.remove(hirelingNPC);
}
// Remove hireling from building
building.getHirelings().remove(hireling);

Loading…
Cancel
Save