From f4ceab41dd4d171eea32bab7fc3420a89a576206 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 4 Feb 2024 12:48:59 -0500 Subject: [PATCH] Update to list based lookup --- src/engine/gameManager/BuildingManager.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 82ae9ee3..f1c5bb83 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -53,8 +53,14 @@ public enum BuildingManager { int numOfSlots = _slotLocations.get(building.meshUUID).size(); + if (building.hirelings.isEmpty()) + return 0; + for (int i = 0; i < numOfSlots; i++) { + if (i > building.hirelings.size()) + return i; + if (building.hirelings.get(i) == null) return i; } @@ -73,8 +79,14 @@ public enum BuildingManager { int numOfSlots = _slotLocations.get(building.meshUUID).size(); + if (building.hirelings.isEmpty()) + return numOfSlots - 1; + for (int i = numOfSlots - 1; i >= 0; i--) { + if (i > building.hirelings.size()) + return i; + if (building.hirelings.get(i) == null) return i; }