From e38324af634224cfdeda4e47bae827f50e5d0c11 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Mar 2024 11:34:36 -0400 Subject: [PATCH] Building set on load --- src/engine/db/handlers/dbWarehouseHandler.java | 10 ++++++++++ src/engine/objects/Warehouse.java | 1 - 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/engine/db/handlers/dbWarehouseHandler.java b/src/engine/db/handlers/dbWarehouseHandler.java index 9ef927af..18995208 100644 --- a/src/engine/db/handlers/dbWarehouseHandler.java +++ b/src/engine/db/handlers/dbWarehouseHandler.java @@ -13,6 +13,7 @@ import engine.Enum; import engine.Enum.GameObjectType; import engine.Enum.TransactionType; import engine.gameManager.DbManager; +import engine.objects.Building; import engine.objects.City; import engine.objects.Transaction; import engine.objects.Warehouse; @@ -114,6 +115,15 @@ public class dbWarehouseHandler extends dbHandlerBase { JSONObject jsonObject = (JSONObject) jsonParser.parse(rs.getString("warehouse")); City city = City.getCity(cityUID); city.warehouse = new Warehouse(jsonObject); + + // Locate warehouse building + for (Building building : city.parentZone.zoneBuildingSet) { + if (building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.WAREHOUSE)) { + city.warehouse.building = building; + break; + } + } + } } catch (Exception e) { diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index b8c85884..01b3af5c 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -52,7 +52,6 @@ public class Warehouse { public Warehouse(JSONObject warehouse) throws SQLException { - JSONObject resources = (JSONObject) warehouse.get("resources"); for (Object key : resources.keySet()) {