From 4da089e9b880e728a94c8a299aa94594e067a0e0 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 25 Aug 2024 16:20:27 -0400 Subject: [PATCH] Update to thread logic --- src/engine/workthreads/DestroyCityThread.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/engine/workthreads/DestroyCityThread.java b/src/engine/workthreads/DestroyCityThread.java index 64ef509f..77453c71 100644 --- a/src/engine/workthreads/DestroyCityThread.java +++ b/src/engine/workthreads/DestroyCityThread.java @@ -88,6 +88,8 @@ public class DestroyCityThread implements Runnable { // Build list of buildings within this parent zone + ArrayList 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 { 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; }