Cleanup of thread.
This commit is contained in:
@@ -31,6 +31,7 @@ import engine.objects.Zone;
|
|||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
public class DestroyCityThread implements Runnable {
|
public class DestroyCityThread implements Runnable {
|
||||||
|
|
||||||
@@ -50,6 +51,7 @@ public class DestroyCityThread implements Runnable {
|
|||||||
Guild formerGuild;
|
Guild formerGuild;
|
||||||
Vector3fImmutable localCoords;
|
Vector3fImmutable localCoords;
|
||||||
ArrayList<Guild> subGuildList;
|
ArrayList<Guild> subGuildList;
|
||||||
|
ArrayList<Building> transferSet;
|
||||||
|
|
||||||
// Member variable assignment
|
// Member variable assignment
|
||||||
|
|
||||||
@@ -70,21 +72,19 @@ public class DestroyCityThread implements Runnable {
|
|||||||
GuildManager.updateAllGuildBinds(formerGuild, null);
|
GuildManager.updateAllGuildBinds(formerGuild, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// By losing the tree, the former owners lose all of their subguilds.
|
if (formerGuild.getSubGuildList().isEmpty() == false) {
|
||||||
|
|
||||||
if (!formerGuild.getSubGuildList().isEmpty()) {
|
|
||||||
|
|
||||||
subGuildList = new ArrayList<>();
|
subGuildList = new ArrayList<>();
|
||||||
|
|
||||||
subGuildList.addAll(formerGuild.getSubGuildList());
|
for (Guild subGuild : formerGuild.getSubGuildList()) {
|
||||||
|
subGuildList.add(subGuild);
|
||||||
|
}
|
||||||
|
|
||||||
for (Guild subGuild : subGuildList) {
|
for (Guild subGuild : subGuildList) {
|
||||||
formerGuild.removeSubGuild(subGuild);
|
formerGuild.removeSubGuild(subGuild);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Building tol = null;
|
|
||||||
|
|
||||||
// Build list of buildings within this parent zone
|
// Build list of buildings within this parent zone
|
||||||
|
|
||||||
for (Building cityBuilding : cityZone.zoneBuildingSet) {
|
for (Building cityBuilding : cityZone.zoneBuildingSet) {
|
||||||
@@ -100,13 +100,6 @@ public class DestroyCityThread implements Runnable {
|
|||||||
if (cityBuilding.getBlueprint().getBuildingGroup().equals(mbEnums.BuildingGroup.BANESTONE))
|
if (cityBuilding.getBlueprint().getBuildingGroup().equals(mbEnums.BuildingGroup.BANESTONE))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// TOL is processed after all other structures in the city zone
|
|
||||||
|
|
||||||
if (cityBuilding.getBlueprint().getBuildingGroup().equals(mbEnums.BuildingGroup.TOL)) {
|
|
||||||
tol = cityBuilding;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// All buildings are moved to a location relative
|
// All buildings are moved to a location relative
|
||||||
// to their new parent zone
|
// to their new parent zone
|
||||||
|
|
||||||
@@ -127,39 +120,31 @@ public class DestroyCityThread implements Runnable {
|
|||||||
|
|
||||||
// Remove warehouse entry if one exists.
|
// Remove warehouse entry if one exists.
|
||||||
|
|
||||||
if (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.WAREHOUSE) {
|
if (cityBuilding.getBlueprint().getBuildingGroup().equals(mbEnums.BuildingGroup.WAREHOUSE)) {
|
||||||
DbManager.WarehouseQueries.DELETE_WAREHOUSE(city.warehouse);
|
DbManager.WarehouseQueries.DELETE_WAREHOUSE(city.warehouse);
|
||||||
city.warehouse = null;
|
city.warehouse = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destroy all remaining city assets
|
// Destroy all remaining auto-protected city assets
|
||||||
|
|
||||||
if ((cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.BARRACK)
|
EnumSet<mbEnums.BuildingGroup> assetsToDestroy = EnumSet.of(mbEnums.BuildingGroup.TOL, mbEnums.BuildingGroup.BARRACK,
|
||||||
|| (cityBuilding.getBlueprint().isWallPiece())
|
mbEnums.BuildingGroup.SPIRE, mbEnums.BuildingGroup.SHRINE, mbEnums.BuildingGroup.WAREHOUSE);
|
||||||
|| (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.SHRINE)
|
|
||||||
|| (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.TOL)
|
if (assetsToDestroy.contains(cityBuilding.getBlueprint().getBuildingGroup())) {
|
||||||
|| (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.SPIRE)
|
|
||||||
|| (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.WAREHOUSE)) {
|
|
||||||
|
|
||||||
if (cityBuilding.getRank() != -1)
|
if (cityBuilding.getRank() != -1)
|
||||||
BuildingManager.setRank(cityBuilding, -1);
|
BuildingManager.setRank(cityBuilding, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destroy the tol
|
|
||||||
|
|
||||||
if (tol != null)
|
|
||||||
BuildingManager.setRank(tol, -1);
|
|
||||||
|
|
||||||
if (city.realm != null)
|
if (city.realm != null)
|
||||||
city.realm.removeCity(city.getObjectUUID());
|
city.realm.removeCity(city.getObjectUUID());
|
||||||
|
|
||||||
// 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) == false) {
|
||||||
Logger.error("DestroyCityThread", "Database error when deleting city zone: " + cityZone.getObjectUUID());
|
Logger.error("DestroyCityThread", "Error when deleting city zone: " + cityZone.getObjectUUID());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user