forked from MagicBane/Server
Make sure no memory leaks
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user