Browse Source

Proper accounting for workOrder removal post completion

combat-2
MagicBot 8 months ago
parent
commit
264094924b
  1. 17
      src/engine/net/client/handlers/ItemProductionMsgHandler.java

17
src/engine/net/client/handlers/ItemProductionMsgHandler.java

@ -142,6 +142,14 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
workOrder.cooking.remove(virtualItem); workOrder.cooking.remove(virtualItem);
ForgeManager.itemWorkOrderLookup.remove(virtualItem); ForgeManager.itemWorkOrderLookup.remove(virtualItem);
// WorkOrder exists until all items are completed or junked
// this is to hold a reference to the virtual item for serialization (NPCMsgHandler)
workOrder.slots_used = workOrder.slots_used - 1;
if (workOrder.slots_used == 0)
ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).remove(workOrder);
// Persist item and add to vendor inventory // Persist item and add to vendor inventory
Item completedItem = DbManager.ItemQueries.PERSIST(virtualItem); Item completedItem = DbManager.ItemQueries.PERSIST(virtualItem);
@ -364,12 +372,19 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
if (vendor.getBuilding() == null) if (vendor.getBuilding() == null)
return; return;
// Delete the item
ForgeManager.inMemoryItemLookup.remove(targetItem.objectUUID); ForgeManager.inMemoryItemLookup.remove(targetItem.objectUUID);
WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(targetItem); WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(targetItem);
workOrder.cooking.remove(targetItem); workOrder.cooking.remove(targetItem);
// WorkOrder exists until all items are completed or junked
// this is to hold a reference to the virtual item for serialization (NPCMsgHandler)
workOrder.slots_used = workOrder.slots_used - 1;
if (workOrder.slots_used == 0)
ForgeManager.vendorWorkOrderLookup.get(workOrder.vendor).remove(workOrder);
// Refresh vendor's inventory to client // Refresh vendor's inventory to client
outMsg = new ManageNPCMsg(vendor); outMsg = new ManageNPCMsg(vendor);

Loading…
Cancel
Save