From 18587e281fbf05ae8def233605cc5835eff818f3 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 19 Apr 2024 09:03:35 -0400 Subject: [PATCH] refactored out collection --- src/engine/gameManager/ForgeManager.java | 4 ---- .../net/client/handlers/ItemProductionMsgHandler.java | 2 -- src/engine/net/client/msg/ManageNPCMsg.java | 6 +++--- src/engine/objects/NPC.java | 4 +--- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index b33cb3ca..e57db32f 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -35,7 +35,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> vendorItemLookup = new HashMap<>(); public static final HashMap> vendorWorkOrderLookup = new HashMap<>(); public static final HashMap itemWorkOrderLookup = new HashMap<>(); @@ -356,7 +355,6 @@ public enum ForgeManager implements Runnable { DispatchMessage.dispatchMsgToInterestArea(workOrder.vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); workOrder.cooking.remove(memoryItem); - vendorItemLookup.get(workOrder.vendor).remove(memoryItem); itemWorkOrderLookup.remove(memoryItem); } } @@ -375,8 +373,6 @@ public enum ForgeManager implements Runnable { workOrder.cooking.add(forged_item); inMemoryItemLookup.put(forged_item.objectUUID, forged_item); - vendorItemLookup.computeIfAbsent(workOrder.vendor, k -> new ArrayList<>()); - vendorItemLookup.get(workOrder.vendor).add(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 fdf173cc..088d2888 100644 --- a/src/engine/net/client/handlers/ItemProductionMsgHandler.java +++ b/src/engine/net/client/handlers/ItemProductionMsgHandler.java @@ -147,7 +147,6 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg, mbEnums.DispatchChannel.SECONDARY, 700, false, false); workOrder.cooking.remove(virtualItem); - ForgeManager.vendorItemLookup.get(workOrder.vendor).remove(virtualItem); ForgeManager.itemWorkOrderLookup.remove(virtualItem); @@ -368,7 +367,6 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { ForgeManager.inMemoryItemLookup.remove(targetItem.objectUUID); WorkOrder workOrder = ForgeManager.itemWorkOrderLookup.get(targetItem); workOrder.cooking.remove(targetItem); - ForgeManager.vendorItemLookup.get(workOrder.vendor).remove(targetItem); // Refresh vendor's inventory to client diff --git a/src/engine/net/client/msg/ManageNPCMsg.java b/src/engine/net/client/msg/ManageNPCMsg.java index 2b54b69d..4e422bcd 100644 --- a/src/engine/net/client/msg/ManageNPCMsg.java +++ b/src/engine/net/client/msg/ManageNPCMsg.java @@ -9,7 +9,6 @@ package engine.net.client.msg; -import engine.gameManager.ForgeManager; import engine.gameManager.NPCManager; import engine.gameManager.PowersManager; import engine.mbEnums.GameObjectType; @@ -434,9 +433,10 @@ public class ManageNPCMsg extends ClientNetMsg { writer.put((byte) template.modTable);//EffectItemType } - writer.putInt(ForgeManager.vendorItemLookup.get(npc).size()); + ArrayList cooking = NPCManager.getAllCookingForVendor(npc); + writer.putInt(cooking.size()); - for (Item item : ForgeManager.vendorItemLookup.get(npc)) { + for (Item item : cooking) { writer.put((byte) 0); // ? Unknown45 writer.putInt(item.getObjectType().ordinal()); diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index 5c22b4db..b567c200 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -871,10 +871,8 @@ public class NPC extends AbstractCharacter { // If NPC is a vendor then configure ForgeManager support - if (this.contract.isTrainer() == false) { - ForgeManager.vendorItemLookup.computeIfAbsent(this, k -> new ArrayList<>()); // Forge lookup + if (this.contract.isTrainer() == false) ForgeManager.vendorWorkOrderLookup.computeIfAbsent(this, k -> new ArrayList<>()); - } this.symbol = this.contract.getIconID(); this.modTypeTable = this.contract.getNPCModTypeTable();