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 {
NPC hirelingNPC = (NPC) hireling; NPC hirelingNPC = (NPC) hireling;
if (ForgeManager.vendorWorkOrderLookup.get(hirelingNPC) != null) if (ForgeManager.vendorWorkOrderLookup.get(hirelingNPC) != null)
for (WorkOrder workOrder : ForgeManager.vendorWorkOrderLookup.get(hirelingNPC)) { for (WorkOrder workOrder : ForgeManager.vendorWorkOrderLookup.get(hirelingNPC)) {
workOrder.runCompleted.set(true); workOrder.runCompleted.set(true);
workOrder.vendor = null; 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); DbManager.WarehouseQueries.DELETE_WORKORDER(workOrder);
} }
// Finally remove the NPC from ForgeManager
ForgeManager.vendorWorkOrderLookup.remove(hirelingNPC);
} }
// Remove hireling from building // Remove hireling from building
building.getHirelings().remove(hireling); building.getHirelings().remove(hireling);

Loading…
Cancel
Save