Browse Source

Update to validation order.

combat-2
MagicBot 7 months ago
parent
commit
ff2e381999
  1. 22
      src/engine/gameManager/ForgeManager.java

22
src/engine/gameManager/ForgeManager.java

@ -96,26 +96,28 @@ public enum ForgeManager implements Runnable {
public static int submit(WorkOrder workOrder) { public static int submit(WorkOrder workOrder) {
// Must have a city to roll anything
City city = workOrder.vendor.building.getCity();
if (city == null)
return 58; //58: The formula is beyond the means of this facility
// Concurrency is rightly managed by same lock as warehouse
city.transactionLock.writeLock().lock();
// Make sure vendor can roll the formulae, warehouse can // Make sure vendor can roll the formulae, warehouse can
// afford this wordOrder and other related checks. // afford this wordOrder and other related checks.
int validation_result = WorkOrder.validate(workOrder); int validation_result = WorkOrder.validate(workOrder);
// The return code is used by the submitter as a // The return code is used by the ItemProductionMsgHandler as a
// popup error message for the player. // popup error message for the player.
if (validation_result != 0) if (validation_result != 0)
return validation_result; return validation_result;
// Concurrency is managed by same lock as warehouse
City city = workOrder.vendor.building.getCity();
if (city == null)
return 58; //58: The formula is beyond the means of this facility
city.transactionLock.writeLock().lock();
try { try {
// Configure this production run. // Configure this production run.

Loading…
Cancel
Save