Browse Source

Update to thread logic

bane-update2
MagicBot 3 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 { @@ -88,6 +88,8 @@ public class DestroyCityThread implements Runnable {
// Build list of buildings within this parent zone
ArrayList<Building> destroySet = new ArrayList<>();
for (Building cityBuilding : cityZone.zoneBuildingSet) {
// Sanity Check in case player deletes the building
@ -126,29 +128,27 @@ public class DestroyCityThread implements Runnable { @@ -126,29 +128,27 @@ public class DestroyCityThread implements Runnable {
city.warehouse = null;
}
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)) {
// Mark all auto protected buildings for destruction
if (cityBuilding.getRank() != -1)
BuildingManager.setRank(cityBuilding, -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))
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) {
city.realm.removeCity(city.getObjectUUID());
city.realm = null;
}
city.getTOL().setOwner(null);
// It's now safe to delete the city zone from the database
// 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());
return;
}

Loading…
Cancel
Save