Debug code added
This commit is contained in:
@@ -52,105 +52,112 @@ public class DestroyCityThread implements Runnable {
|
|||||||
Vector3fImmutable localCoords;
|
Vector3fImmutable localCoords;
|
||||||
ArrayList<Guild> subGuildList;
|
ArrayList<Guild> subGuildList;
|
||||||
|
|
||||||
// Member variable assignment
|
Logger.info("Destroy city routing started");
|
||||||
|
|
||||||
cityZone = city.getParent();
|
try {
|
||||||
newParent = cityZone.parent;
|
|
||||||
formerGuild = city.getTOL().getGuild();
|
|
||||||
|
|
||||||
// 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);
|
if (DbManager.GuildQueries.SET_GUILD_OWNED_CITY(formerGuild.getObjectUUID(), 0)) {
|
||||||
formerGuild.setNation(null);
|
|
||||||
formerGuild.setCityUUID(0);
|
|
||||||
GuildManager.updateAllGuildTags(formerGuild);
|
|
||||||
GuildManager.updateAllGuildBinds(formerGuild, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (formerGuild.getSubGuildList().isEmpty() == false) {
|
//Successful Update of guild
|
||||||
|
|
||||||
subGuildList = new ArrayList<>();
|
formerGuild.setGuildState(mbEnums.GuildState.Errant);
|
||||||
|
formerGuild.setNation(null);
|
||||||
for (Guild subGuild : formerGuild.getSubGuildList()) {
|
formerGuild.setCityUUID(0);
|
||||||
subGuildList.add(subGuild);
|
GuildManager.updateAllGuildTags(formerGuild);
|
||||||
|
GuildManager.updateAllGuildBinds(formerGuild, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Guild subGuild : subGuildList) {
|
if (formerGuild.getSubGuildList().isEmpty() == false) {
|
||||||
formerGuild.removeSubGuild(subGuild);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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
|
for (Guild subGuild : subGuildList) {
|
||||||
// before this thread can get to it
|
formerGuild.removeSubGuild(subGuild);
|
||||||
|
}
|
||||||
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
|
// Build list of buildings within this parent zone
|
||||||
|
|
||||||
EnumSet<mbEnums.BuildingGroup> assetsToDestroy = EnumSet.of(mbEnums.BuildingGroup.TOL, mbEnums.BuildingGroup.BARRACK,
|
for (Building cityBuilding : cityZone.zoneBuildingSet) {
|
||||||
mbEnums.BuildingGroup.SPIRE, mbEnums.BuildingGroup.SHRINE, mbEnums.BuildingGroup.WAREHOUSE);
|
|
||||||
|
|
||||||
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)
|
if (cityBuilding == null)
|
||||||
BuildingManager.setRank(cityBuilding, -1);
|
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
|
// Zone and city should vanish upon next reboot
|
||||||
// if the codebase reaches here.
|
// if the codebase reaches here.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user