From 5f930b048250d9b256386ee8df67dc781246767e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 17 Mar 2024 10:52:33 -0400 Subject: [PATCH] Warehouse loading work. --- .../net/client/handlers/PlaceAssetMsgHandler.java | 4 ++++ src/engine/objects/Warehouse.java | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java index 7a7826e0..17727592 100644 --- a/src/engine/net/client/handlers/PlaceAssetMsgHandler.java +++ b/src/engine/net/client/handlers/PlaceAssetMsgHandler.java @@ -1343,6 +1343,10 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler { return false; } + Warehouse warehouse = new Warehouse(warehouseBuilding); + city.warehouse = warehouse; + DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse); + // Load the building into the simulation warehouseBuilding.setObjectTypeMask(MBServerStatics.MASK_BUILDING); diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index 472b0d3c..1230ccb6 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -35,6 +35,21 @@ public class Warehouse { public ArrayList transactions = new ArrayList<>(); public ConcurrentHashMap resources = new ConcurrentHashMap<>(); + public Warehouse(Building building) { + + this.buildingUID = building.objectUUID; + this.city = building.getCity(); + + // New empty warehouse + + for (Enum.ResourceType resourceType : EnumSet.allOf(Enum.ResourceType.class)) + this.resources.put(resourceType, 0); + + // With no locks + + this.locked = EnumSet.noneOf(Enum.ResourceType.class); + } + public Warehouse(JSONObject warehouse) throws SQLException {