Browse Source

Concurrency update

combat-2
MagicBot 8 months ago
parent
commit
6f39767fb4
  1. 2
      src/engine/gameManager/ForgeManager.java
  2. 4
      src/engine/loot/WorkOrder.java
  3. 2
      src/engine/net/client/handlers/ItemProductionMsgHandler.java
  4. 3
      src/engine/objects/NPC.java

2
src/engine/gameManager/ForgeManager.java

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

4
src/engine/loot/WorkOrder.java

@ -16,8 +16,8 @@ import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Delayed; import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -39,7 +39,7 @@ public class WorkOrder implements Delayed {
public long completionTime; public long completionTime;
public boolean runCompleted = false; public boolean runCompleted = false;
public boolean runCanceled = false; public boolean runCanceled = false;
public ArrayList<Item> cooking = new ArrayList<>(); public CopyOnWriteArrayList<Item> cooking = new CopyOnWriteArrayList<>();
public WorkOrder() { public WorkOrder() {

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

@ -164,6 +164,8 @@ public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
vendor.charItemManager.addItemToInventory(completedItem); vendor.charItemManager.addItemToInventory(completedItem);
// Refresh the vendor inventory window
ItemProductionMsg outMsg1 = new ItemProductionMsg(vendor.building, vendor, completedItem, mbEnums.ProductionActionType.DEPOSIT, true); ItemProductionMsg outMsg1 = new ItemProductionMsg(vendor.building, vendor, completedItem, mbEnums.ProductionActionType.DEPOSIT, true);
DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false); DispatchMessage.dispatchMsgToInterestArea(vendor, outMsg1, mbEnums.DispatchChannel.SECONDARY, 700, false, false);
ItemProductionMsg outMsg2 = new ItemProductionMsg(vendor.building, vendor, completedItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true); ItemProductionMsg outMsg2 = new ItemProductionMsg(vendor.building, vendor, completedItem, mbEnums.ProductionActionType.CONFIRM_DEPOSIT, true);

3
src/engine/objects/NPC.java

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

Loading…
Cancel
Save