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; }