Browse Source

Update to thread logic

bane-update2
MagicBot 4 months ago
parent
commit
4da089e9b8
  1. 24
      src/engine/workthreads/DestroyCityThread.java

24
src/engine/workthreads/DestroyCityThread.java

@ -88,6 +88,8 @@ public class DestroyCityThread implements Runnable {
// Build list of buildings within this parent zone // Build list of buildings within this parent zone
ArrayList<Building> destroySet = new ArrayList<>();
for (Building cityBuilding : cityZone.zoneBuildingSet) { for (Building cityBuilding : cityZone.zoneBuildingSet) {
// Sanity Check in case player deletes the building // Sanity Check in case player deletes the building
@ -126,29 +128,27 @@ public class DestroyCityThread implements Runnable {
city.warehouse = null; city.warehouse = null;
} }
if ((cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.BARRACK) // Mark all auto protected buildings for destruction
|| (cityBuilding.getBlueprint().isWallPiece())
|| (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.SHRINE)
|| (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.TOL)
|| (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.SPIRE)
|| (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.WAREHOUSE)) {
if (cityBuilding.getRank() != -1) if ((cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.BARRACK) || (cityBuilding.getBlueprint().isWallPiece()) || (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.SHRINE) || (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.TOL) || (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.SPIRE) || (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.WAREHOUSE))
BuildingManager.setRank(cityBuilding, -1); destroySet.add(cityBuilding);
}
} }
// Destroy set of auto-protected buildings
for (Building building : destroySet)
if (building.getRank() != -1)
BuildingManager.setRank(building, -1);
if (city.realm != null) { if (city.realm != null) {
city.realm.removeCity(city.getObjectUUID()); city.realm.removeCity(city.getObjectUUID());
city.realm = null; city.realm = null;
} }
city.getTOL().setOwner(null);
// It's now safe to delete the city zone from the database // It's now safe to delete the city zone from the database
// which will cause a cascade delete of everything else // which will cause a cascade delete of everything else
if (DbManager.ZoneQueries.DELETE_ZONE(cityZone) == false) { if (!DbManager.ZoneQueries.DELETE_ZONE(cityZone)) {
Logger.error("DestroyCityThread", "Database error when deleting city zone: " + cityZone.getObjectUUID()); Logger.error("DestroyCityThread", "Database error when deleting city zone: " + cityZone.getObjectUUID());
return; return;
} }

Loading…
Cancel
Save