Browse Source

Warehouse loading work.

combat-2
MagicBot 8 months ago
parent
commit
5f930b0482
  1. 4
      src/engine/net/client/handlers/PlaceAssetMsgHandler.java
  2. 15
      src/engine/objects/Warehouse.java

4
src/engine/net/client/handlers/PlaceAssetMsgHandler.java

@ -1343,6 +1343,10 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
return false; return false;
} }
Warehouse warehouse = new Warehouse(warehouseBuilding);
city.warehouse = warehouse;
DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse);
// Load the building into the simulation // Load the building into the simulation
warehouseBuilding.setObjectTypeMask(MBServerStatics.MASK_BUILDING); warehouseBuilding.setObjectTypeMask(MBServerStatics.MASK_BUILDING);

15
src/engine/objects/Warehouse.java

@ -35,6 +35,21 @@ public class Warehouse {
public ArrayList<Transaction> transactions = new ArrayList<>(); public ArrayList<Transaction> transactions = new ArrayList<>();
public ConcurrentHashMap<Enum.ResourceType, Integer> resources = new ConcurrentHashMap<>(); public ConcurrentHashMap<Enum.ResourceType, Integer> 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 { public Warehouse(JSONObject warehouse) throws SQLException {

Loading…
Cancel
Save