forked from MagicBane/Server
Debug code added
This commit is contained in:
@@ -52,105 +52,112 @@ public class DestroyCityThread implements Runnable {
|
||||
Vector3fImmutable localCoords;
|
||||
ArrayList<Guild> subGuildList;
|
||||
|
||||
// Member variable assignment
|
||||
Logger.info("Destroy city routing started");
|
||||
|
||||
cityZone = city.getParent();
|
||||
newParent = cityZone.parent;
|
||||
formerGuild = city.getTOL().getGuild();
|
||||
try {
|
||||
|
||||
// Former guild loses it's tree!
|
||||
// Member variable assignment
|
||||
|
||||
if (DbManager.GuildQueries.SET_GUILD_OWNED_CITY(formerGuild.getObjectUUID(), 0)) {
|
||||
cityZone = city.getParent();
|
||||
newParent = cityZone.parent;
|
||||
formerGuild = city.getTOL().getGuild();
|
||||
|
||||
//Successful Update of guild
|
||||
// Former guild loses it's tree!
|
||||
|
||||
formerGuild.setGuildState(mbEnums.GuildState.Errant);
|
||||
formerGuild.setNation(null);
|
||||
formerGuild.setCityUUID(0);
|
||||
GuildManager.updateAllGuildTags(formerGuild);
|
||||
GuildManager.updateAllGuildBinds(formerGuild, null);
|
||||
}
|
||||
if (DbManager.GuildQueries.SET_GUILD_OWNED_CITY(formerGuild.getObjectUUID(), 0)) {
|
||||
|
||||
if (formerGuild.getSubGuildList().isEmpty() == false) {
|
||||
//Successful Update of guild
|
||||
|
||||
subGuildList = new ArrayList<>();
|
||||
|
||||
for (Guild subGuild : formerGuild.getSubGuildList()) {
|
||||
subGuildList.add(subGuild);
|
||||
formerGuild.setGuildState(mbEnums.GuildState.Errant);
|
||||
formerGuild.setNation(null);
|
||||
formerGuild.setCityUUID(0);
|
||||
GuildManager.updateAllGuildTags(formerGuild);
|
||||
GuildManager.updateAllGuildBinds(formerGuild, null);
|
||||
}
|
||||
|
||||
for (Guild subGuild : subGuildList) {
|
||||
formerGuild.removeSubGuild(subGuild);
|
||||
}
|
||||
}
|
||||
if (formerGuild.getSubGuildList().isEmpty() == false) {
|
||||
|
||||
// Build list of buildings within this parent zone
|
||||
subGuildList = new ArrayList<>();
|
||||
|
||||
for (Building cityBuilding : cityZone.zoneBuildingSet) {
|
||||
for (Guild subGuild : formerGuild.getSubGuildList()) {
|
||||
subGuildList.add(subGuild);
|
||||
}
|
||||
|
||||
// Sanity Check in case player deletes the building
|
||||
// before this thread can get to it
|
||||
|
||||
if (cityBuilding == null)
|
||||
continue;
|
||||
|
||||
// Do nothing with the banestone. It will be removed elsewhere
|
||||
|
||||
if (cityBuilding.getBlueprint().getBuildingGroup().equals(mbEnums.BuildingGroup.BANESTONE))
|
||||
continue;
|
||||
|
||||
// All buildings are moved to a location relative
|
||||
// to their new parent zone
|
||||
|
||||
localCoords = ZoneManager.worldToLocal(cityBuilding.getLoc(), newParent);
|
||||
|
||||
DbManager.BuildingQueries.MOVE_BUILDING(cityBuilding.getObjectUUID(), newParent.getObjectUUID(), localCoords.x, localCoords.y, localCoords.z);
|
||||
|
||||
// All buildings are re-parented to a zone one node
|
||||
// higher in the tree (continent) as we will be
|
||||
// deleting the city zone very shortly.
|
||||
|
||||
if (cityBuilding.getParentZoneID() != newParent.getParentZoneID())
|
||||
cityBuilding.setParentZone(newParent);
|
||||
|
||||
// No longer a tree, no longer any protection contract!
|
||||
|
||||
cityBuilding.setProtectionState(mbEnums.ProtectionState.NONE);
|
||||
|
||||
// Remove warehouse entry if one exists.
|
||||
|
||||
if (cityBuilding.getBlueprint().getBuildingGroup().equals(mbEnums.BuildingGroup.WAREHOUSE)) {
|
||||
DbManager.WarehouseQueries.DELETE_WAREHOUSE(city.warehouse);
|
||||
city.warehouse = null;
|
||||
for (Guild subGuild : subGuildList) {
|
||||
formerGuild.removeSubGuild(subGuild);
|
||||
}
|
||||
}
|
||||
|
||||
// Destroy all remaining auto-protected city assets
|
||||
// Build list of buildings within this parent zone
|
||||
|
||||
EnumSet<mbEnums.BuildingGroup> assetsToDestroy = EnumSet.of(mbEnums.BuildingGroup.TOL, mbEnums.BuildingGroup.BARRACK,
|
||||
mbEnums.BuildingGroup.SPIRE, mbEnums.BuildingGroup.SHRINE, mbEnums.BuildingGroup.WAREHOUSE);
|
||||
for (Building cityBuilding : cityZone.zoneBuildingSet) {
|
||||
|
||||
if (assetsToDestroy.contains(cityBuilding.getBlueprint().getBuildingGroup())) {
|
||||
// Sanity Check in case player deletes the building
|
||||
// before this thread can get to it
|
||||
|
||||
if (cityBuilding.getRank() != -1)
|
||||
BuildingManager.setRank(cityBuilding, -1);
|
||||
if (cityBuilding == null)
|
||||
continue;
|
||||
|
||||
// Do nothing with the banestone. It will be removed elsewhere
|
||||
|
||||
if (cityBuilding.getBlueprint().getBuildingGroup().equals(mbEnums.BuildingGroup.BANESTONE))
|
||||
continue;
|
||||
|
||||
// All buildings are moved to a location relative
|
||||
// to their new parent zone
|
||||
|
||||
localCoords = ZoneManager.worldToLocal(cityBuilding.getLoc(), newParent);
|
||||
|
||||
DbManager.BuildingQueries.MOVE_BUILDING(cityBuilding.getObjectUUID(), newParent.getObjectUUID(), localCoords.x, localCoords.y, localCoords.z);
|
||||
|
||||
// All buildings are re-parented to a zone one node
|
||||
// higher in the tree (continent) as we will be
|
||||
// deleting the city zone very shortly.
|
||||
|
||||
if (cityBuilding.getParentZoneID() != newParent.getParentZoneID())
|
||||
cityBuilding.setParentZone(newParent);
|
||||
|
||||
// No longer a tree, no longer any protection contract!
|
||||
|
||||
cityBuilding.setProtectionState(mbEnums.ProtectionState.NONE);
|
||||
|
||||
// Remove warehouse entry if one exists.
|
||||
|
||||
if (cityBuilding.getBlueprint().getBuildingGroup().equals(mbEnums.BuildingGroup.WAREHOUSE)) {
|
||||
DbManager.WarehouseQueries.DELETE_WAREHOUSE(city.warehouse);
|
||||
city.warehouse = null;
|
||||
}
|
||||
|
||||
// Destroy all remaining auto-protected city assets
|
||||
|
||||
EnumSet<mbEnums.BuildingGroup> assetsToDestroy = EnumSet.of(mbEnums.BuildingGroup.TOL, mbEnums.BuildingGroup.BARRACK,
|
||||
mbEnums.BuildingGroup.SPIRE, mbEnums.BuildingGroup.SHRINE, mbEnums.BuildingGroup.WAREHOUSE);
|
||||
|
||||
if (assetsToDestroy.contains(cityBuilding.getBlueprint().getBuildingGroup())) {
|
||||
|
||||
if (cityBuilding.getRank() != -1)
|
||||
BuildingManager.setRank(cityBuilding, -1);
|
||||
}
|
||||
}
|
||||
|
||||
if (city.realm != null)
|
||||
city.realm.removeCity(city.getObjectUUID());
|
||||
|
||||
// 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) {
|
||||
Logger.error("DestroyCityThread", "Error when deleting city zone: " + cityZone.getObjectUUID());
|
||||
return;
|
||||
}
|
||||
|
||||
// Refresh the city for map requests
|
||||
|
||||
City.lastCityUpdate = System.currentTimeMillis();
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
|
||||
if (city.realm != null)
|
||||
city.realm.removeCity(city.getObjectUUID());
|
||||
|
||||
// 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) {
|
||||
Logger.error("DestroyCityThread", "Error when deleting city zone: " + cityZone.getObjectUUID());
|
||||
return;
|
||||
}
|
||||
|
||||
// Refresh the city for map requests
|
||||
|
||||
City.lastCityUpdate = System.currentTimeMillis();
|
||||
|
||||
// Zone and city should vanish upon next reboot
|
||||
// if the codebase reaches here.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user