From 7f8c297ae265cf2cc464a9ced84f9e5a901c31ef Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 21 Apr 2024 14:08:27 -0400 Subject: [PATCH] City check moved outside of validation --- src/engine/gameManager/ForgeManager.java | 6 ++++++ src/engine/gameManager/ItemManager.java | 3 --- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index edcd26e7..b79264d3 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -105,7 +105,13 @@ public enum ForgeManager implements Runnable { if (validation_result != 0) 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 { diff --git a/src/engine/gameManager/ItemManager.java b/src/engine/gameManager/ItemManager.java index e90d8b62..c9634ad8 100644 --- a/src/engine/gameManager/ItemManager.java +++ b/src/engine/gameManager/ItemManager.java @@ -238,9 +238,6 @@ public enum ItemManager { if (workOrder.vendor.getBuilding() == null) return 58; //58: The formula is beyond the means of this facility - if (workOrder.vendor.getBuilding().getCity() == null) - return 58; //58: The formula is beyond the means of this facility - if (!workOrder.vendor.charItemManager.hasRoomInventory(template.item_wt)) return 30; //30: That person cannot carry that item