Browse Source

refactored out collection

combat-2
MagicBot 8 months ago
parent
commit
18587e281f
  1. 4
      src/engine/gameManager/ForgeManager.java
  2. 2
      src/engine/net/client/handlers/ItemProductionMsgHandler.java
  3. 6
      src/engine/net/client/msg/ManageNPCMsg.java
  4. 4
      src/engine/objects/NPC.java

4
src/engine/gameManager/ForgeManager.java

@ -35,7 +35,6 @@ public enum ForgeManager implements Runnable { @@ -35,7 +35,6 @@ public enum ForgeManager implements Runnable {
private static final BlockingQueue<WorkOrder> forge = new DelayQueue<>();
public static final AtomicInteger wordOrderCounter = new AtomicInteger(0);
public static final HashMap<Integer, Item> inMemoryItemLookup = new HashMap<>();
public static final HashMap<NPC, ArrayList<Item>> vendorItemLookup = new HashMap<>();
public static final HashMap<NPC, ArrayList<WorkOrder>> vendorWorkOrderLookup = new HashMap<>();
public static final HashMap<Item, WorkOrder> itemWorkOrderLookup = new HashMap<>();
@ -356,7 +355,6 @@ public enum ForgeManager implements Runnable { @@ -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 { @@ -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);

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

@ -147,7 +147,6 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler { @@ -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 { @@ -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

6
src/engine/net/client/msg/ManageNPCMsg.java

@ -9,7 +9,6 @@ @@ -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 { @@ -434,9 +433,10 @@ public class ManageNPCMsg extends ClientNetMsg {
writer.put((byte) template.modTable);//EffectItemType
}
writer.putInt(ForgeManager.vendorItemLookup.get(npc).size());
ArrayList<Item> 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());

4
src/engine/objects/NPC.java

@ -871,10 +871,8 @@ public class NPC extends AbstractCharacter { @@ -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();

Loading…
Cancel
Save