Browse Source

total_to_produce updated when slot removed from workOrder

combat-2
MagicBot 7 months ago
parent
commit
743c897254
  1. 30
      src/engine/net/client/handlers/ItemProductionMsgHandler.java

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

@ -373,24 +373,34 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { @@ -373,24 +373,34 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
ManageNPCMsg outMsg;
Dispatch dispatch;
virtualItem = Item.getFromCache(itemUUID);
PlayerCharacter player = origin.getPlayerCharacter();
if (player == null)
return;
// Cannot junk items without a forge!
if (vendor.getBuilding() == null)
return;
// junk nothing?
virtualItem = Item.getFromCache(itemUUID);
if (virtualItem == null)
return;
// Cannot junk items without a forge!
WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(virtualItem);
if (vendor.getBuilding() == null)
// If this virtual item was already processed then
// it will have been removed from the workOrder.
if (workOrder == null)
return;
WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(virtualItem);
if (workOrder.cooking.contains(virtualItem) == false)
return;
;
City city = workOrder.vendor.building.getCity();
@ -405,6 +415,16 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { @@ -405,6 +415,16 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
DbManager.removeFromCache(virtualItem);
ForgeManager.itemWorkOrderLookup.remove(virtualItem);
// Update total_to_produce accounting for the slot being
// removed while workOrder is not completed.
if (workOrder.runCompleted == false) {
int itemsPerSlot = workOrder.total_to_produce / workOrder.slots_used;
workOrder.total_to_produce = workOrder.total_to_produce - itemsPerSlot;
}
// Slot is no longer allocated to this workOrder.
workOrder.slots_used = workOrder.slots_used - 1;
// Update workOrder on disk

Loading…
Cancel
Save