diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index 49354b69..e57db32f 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -323,6 +323,8 @@ public enum ForgeManager implements Runnable { public static void completeWorkOrderBatch(WorkOrder workOrder) { + ArrayList toRemove = new ArrayList<>(); + for (Item workOrderItem : workOrder.cooking) { // Persist item @@ -338,13 +340,22 @@ public enum ForgeManager implements Runnable { ItemProductionMsg outMsg2 = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, completedItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg2, mbEnums.DispatchChannel.SECONDARY, 700, false, false); + toRemove.add(workOrderItem); + } + + // Remove the negativeID virtual item from all collections + // other than the virtual item lookup map. Item will be + // persisted when bought/taken from vendor. + + for (Item memoryItem : toRemove) { + // Remove the virtual items from the forge window - ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, workOrderItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); + ItemProductionMsg outMsg = new ItemProductionMsg(workOrder.vendor.building, workOrder.vendor, memoryItem, mbEnums.ProductionActionType.CONFIRM_SETPRICE, true); DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); - workOrder.cooking.remove(workOrderItem); - itemWorkOrderLookup.remove(workOrderItem); + workOrder.cooking.remove(memoryItem); + itemWorkOrderLookup.remove(memoryItem); } }