Keep destroyed warehouse contents in memory so the rubble can be looted
destroyOrDerank nulled city.warehouse on destruction, so the loot click found no warehouse and returned silently. The destroyed Warehouse is now held in Warehouse.destroyedWarehouses keyed by the rubble building UUID until it is looted empty, the rubble is destroyed, or the city places a new warehouse. Contents are not persisted across a reboot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0865a7be74
commit
e64d64bf18
6 files changed
+12
-16
No files matched your search
@@ -211,12 +211,7 @@ public enum BuildingManager {
|
||||
break;
|
||||
case WAREHOUSE:
|
||||
|
||||
City city = building.getCity();
|
||||
|
||||
if (city == null)
|
||||
return true;
|
||||
|
||||
Warehouse warehouse = city.warehouse;
|
||||
Warehouse warehouse = Warehouse.destroyedWarehouses.get(building.getObjectUUID());
|
||||
|
||||
if (warehouse == null)
|
||||
return false;
|
||||
@@ -241,6 +236,9 @@ public enum BuildingManager {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (Warehouse.isEmpty(warehouse))
|
||||
Warehouse.destroyedWarehouses.remove(building.getObjectUUID());
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
@@ -97,6 +97,7 @@ public class DestroyBuildingHandler extends AbstractClientMsgHandler {
|
||||
if (city == null)
|
||||
return true;
|
||||
|
||||
Warehouse.destroyedWarehouses.remove(building.getObjectUUID());
|
||||
DbManager.WarehouseQueries.DELETE_WAREHOUSE(city.warehouse);
|
||||
|
||||
city.warehouse = null;
|
||||
|
||||
@@ -141,17 +141,9 @@ public class ManageCityAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
City city = building.getCity();
|
||||
Warehouse warehouse = Warehouse.destroyedWarehouses.get(building.getObjectUUID());
|
||||
|
||||
if (city == null)
|
||||
return true;
|
||||
|
||||
Warehouse warehouse = city.warehouse;
|
||||
|
||||
if (warehouse == null)
|
||||
return true;
|
||||
|
||||
if (Warehouse.isEmpty(warehouse)) {
|
||||
if (warehouse == null || Warehouse.isEmpty(warehouse)) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 167); // no more resources.
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1341,6 +1341,7 @@ public class PlaceAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
}
|
||||
|
||||
Warehouse warehouse = new Warehouse(warehouseBuilding);
|
||||
Warehouse.destroyedWarehouses.values().removeIf(destroyed -> destroyed.city == city);
|
||||
city.warehouse = warehouse;
|
||||
DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse);
|
||||
|
||||
|
||||
@@ -433,6 +433,7 @@ public class Building extends AbstractWorldObject {
|
||||
// Special handling of warehouses
|
||||
|
||||
if (blueprint.getBuildingGroup() == BuildingGroup.WAREHOUSE) {
|
||||
Warehouse.destroyedWarehouses.put(this.getObjectUUID(), city.warehouse);
|
||||
DbManager.WarehouseQueries.DELETE_WAREHOUSE(city.warehouse);
|
||||
city.warehouse = null;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,9 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class Warehouse {
|
||||
|
||||
// Destroyed warehouses keyed by rubble building UUID; memory only so the rubble can be looted
|
||||
public static final ConcurrentHashMap<Integer, Warehouse> destroyedWarehouses = new ConcurrentHashMap<>();
|
||||
|
||||
public EnumSet<mbEnums.ResourceType> locked = EnumSet.noneOf(mbEnums.ResourceType.class);
|
||||
public Building building;
|
||||
public City city;
|
||||
|
||||
Reference in new issue
Block a user