diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index dfa6b57d..ecd90360 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -33,7 +33,6 @@ public enum ForgeManager implements Runnable { private static final BlockingQueue forge = new DelayQueue<>(); public static final AtomicInteger wordOrderCounter = new AtomicInteger(0); - public static final HashMap inMemoryItemLookup = new HashMap<>(); public static final HashMap> vendorWorkOrderLookup = new HashMap<>(); public static final HashMap itemWorkOrderLookup = new HashMap<>(); @@ -306,6 +305,7 @@ public enum ForgeManager implements Runnable { workOrder.cooking.remove(memoryItem); itemWorkOrderLookup.remove(memoryItem); + DbManager.removeFromCache(memoryItem); } } @@ -322,7 +322,7 @@ public enum ForgeManager implements Runnable { // Add virtual item to in-memory caches workOrder.cooking.add(forged_item); - inMemoryItemLookup.put(forged_item.objectUUID, forged_item); + DbManager.addToCache(forged_item); vendorWorkOrderLookup.get(workOrder.vendor).add(workOrder); itemWorkOrderLookup.put(forged_item, workOrder); diff --git a/src/engine/net/client/handlers/ItemProductionMsgHandler.java b/src/engine/net/client/handlers/ItemProductionMsgHandler.java index f4984f13..7c9116ef 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -129,7 +129,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { private static void completeItem(int itemUUID, NPC vendor) { - Item virtualItem = ForgeManager.inMemoryItemLookup.get(itemUUID); + Item virtualItem = Item.getFromCache(itemUUID); WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(virtualItem); // Refresh the window. SetPrice is used only to force a window refresh. @@ -142,6 +142,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { workOrder.cooking.remove(virtualItem); ForgeManager.itemWorkOrderLookup.remove(virtualItem); + DbManager.removeFromCache(virtualItem); // WorkOrder exists until all items are completed or junked // this is to hold a reference to the virtual item for serialization (NPCMsgHandler) @@ -364,7 +365,7 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { try { - targetItem = ForgeManager.inMemoryItemLookup.get(itemUUID); + targetItem = Item.getFromCache(itemUUID); PlayerCharacter player = origin.getPlayerCharacter(); @@ -381,10 +382,9 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { if (vendor.getBuilding() == null) return; - - ForgeManager.inMemoryItemLookup.remove(targetItem.objectUUID); WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(targetItem); workOrder.cooking.remove(targetItem); + DbManager.removeFromCache(targetItem); // WorkOrder exists until all items are completed or junked // this is to hold a reference to the virtual item for serialization (NPCMsgHandler) diff --git a/src/engine/net/client/msg/ItemProductionMsg.java b/src/engine/net/client/msg/ItemProductionMsg.java index bc813d64..76f851ac 100644 --- a/src/engine/net/client/msg/ItemProductionMsg.java +++ b/src/engine/net/client/msg/ItemProductionMsg.java @@ -10,7 +10,6 @@ package engine.net.client.msg; import engine.gameManager.BuildingManager; -import engine.gameManager.ForgeManager; import engine.mbEnums; import engine.mbEnums.GameObjectType; import engine.net.*; @@ -142,11 +141,7 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(0); writer.put((byte) 1); - Item item; - if (this.itemUUID > 0) - item = Item.getFromCache(this.itemUUID); - else - item = ForgeManager.inMemoryItemLookup.get(this.itemUUID); + Item item = Item.getFromCache(this.itemUUID); if (item != null) Item.serializeForClientMsgWithoutSlot(item, writer); @@ -237,7 +232,7 @@ public class ItemProductionMsg extends ClientNetMsg { writer.putInt(0); writer.putInt(0); writer.putInt(1); - Item toRoll = ForgeManager.inMemoryItemLookup.get(this.itemUUID); + Item toRoll = Item.getFromCache(this.itemUUID); writer.putInt(-1497023830); this.pToken = toRoll.prefixToken;