Browse Source

Concurrency update

combat-2
MagicBot 7 months ago
parent
commit
0e7336b8c6
  1. 2
      src/engine/gameManager/ForgeManager.java
  2. 4
      src/engine/gameManager/NPCManager.java
  3. 3
      src/engine/objects/NPC.java

2
src/engine/gameManager/ForgeManager.java

@ -29,7 +29,7 @@ public enum ForgeManager implements Runnable { @@ -29,7 +29,7 @@ public enum ForgeManager implements Runnable {
private static final BlockingQueue<WorkOrder> forge = new DelayQueue<>();
public static final AtomicInteger wordOrderCounter = new AtomicInteger(0);
public static final ConcurrentHashMap<NPC, CopyOnWriteArrayList<WorkOrder>> vendorWorkOrderLookup = new ConcurrentHashMap<>();
public static final ConcurrentHashMap<NPC, ConcurrentHashMap.KeySetView<WorkOrder, Boolean>> vendorWorkOrderLookup = new ConcurrentHashMap<>();
public static final ConcurrentHashMap<Item, WorkOrder> itemWorkOrderLookup = new ConcurrentHashMap<>();
@Override

4
src/engine/gameManager/NPCManager.java

@ -27,7 +27,7 @@ import org.pmw.tinylog.Logger; @@ -27,7 +27,7 @@ import org.pmw.tinylog.Logger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadLocalRandom;
import static engine.math.FastMath.acos;
@ -523,7 +523,7 @@ public enum NPCManager { @@ -523,7 +523,7 @@ public enum NPCManager {
ArrayList<Item> itemList = new ArrayList<>();
List<WorkOrder> vendorWorkOrders = ForgeManager.vendorWorkOrderLookup.get(npc);
ConcurrentHashMap.KeySetView<WorkOrder, Boolean> vendorWorkOrders = ForgeManager.vendorWorkOrderLookup.get(npc);
for (WorkOrder workOrder : vendorWorkOrders)
itemList.addAll(workOrder.cooking);

3
src/engine/objects/NPC.java

@ -35,7 +35,6 @@ import java.util.ArrayList; @@ -35,7 +35,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup;
@ -873,7 +872,7 @@ public class NPC extends AbstractCharacter { @@ -873,7 +872,7 @@ public class NPC extends AbstractCharacter {
// If NPC is a vendor then configure ForgeManager support
if (this.contract.isTrainer() == false)
ForgeManager.vendorWorkOrderLookup.computeIfAbsent(this, k -> new CopyOnWriteArrayList<>());
ForgeManager.vendorWorkOrderLookup.computeIfAbsent(this, k -> ConcurrentHashMap.newKeySet());
this.symbol = this.contract.getIconID();
this.modTypeTable = this.contract.getNPCModTypeTable();

Loading…
Cancel
Save