total_to_produce updated when slot removed from workOrder

This commit is contained in:
2024-04-27 07:18:24 -04:00
parent f134f71695
commit 743c897254
@@ -373,25 +373,35 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
ManageNPCMsg outMsg;
Dispatch dispatch;
virtualItem = Item.getFromCache(itemUUID);
PlayerCharacter player = origin.getPlayerCharacter();
if (player == null)
return;
// junk nothing?
if (virtualItem == null)
return;
// Cannot junk items without a forge!
if (vendor.getBuilding() == null)
return;
// junk nothing?
virtualItem = Item.getFromCache(itemUUID);
if (virtualItem == null)
return;
WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(virtualItem);
// If this virtual item was already processed then
// it will have been removed from the workOrder.
if (workOrder == null)
return;
if (workOrder.cooking.contains(virtualItem) == false)
return;
;
City city = workOrder.vendor.building.getCity();
if (city == null)
@@ -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