Browse Source

Debug code added

bane-updates
MagicBot 3 months ago
parent
commit
b602a78950
  1. 133
      src/engine/workthreads/DestroyCityThread.java

133
src/engine/workthreads/DestroyCityThread.java

@ -52,104 +52,111 @@ public class DestroyCityThread implements Runnable { @@ -52,104 +52,111 @@ 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 (formerGuild.getSubGuildList().isEmpty() == false) {
if (DbManager.GuildQueries.SET_GUILD_OWNED_CITY(formerGuild.getObjectUUID(), 0)) {
subGuildList = new ArrayList<>();
//Successful Update of guild
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) {
subGuildList = new ArrayList<>();
for (Guild subGuild : formerGuild.getSubGuildList()) {
subGuildList.add(subGuild);
}
for (Guild subGuild : subGuildList) {
formerGuild.removeSubGuild(subGuild);
}
}
}
// 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) {
// Sanity Check in case player deletes the building
// before this thread can get to it
// Sanity Check in case player deletes the building
// before this thread can get to it
if (cityBuilding == null)
continue;
if (cityBuilding == null)
continue;
// Do nothing with the banestone. It will be removed elsewhere
// Do nothing with the banestone. It will be removed elsewhere
if (cityBuilding.getBlueprint().getBuildingGroup().equals(mbEnums.BuildingGroup.BANESTONE))
continue;
if (cityBuilding.getBlueprint().getBuildingGroup().equals(mbEnums.BuildingGroup.BANESTONE))
continue;
// All buildings are moved to a location relative
// to their new parent zone
// All buildings are moved to a location relative
// to their new parent zone
localCoords = ZoneManager.worldToLocal(cityBuilding.getLoc(), newParent);
localCoords = ZoneManager.worldToLocal(cityBuilding.getLoc(), newParent);
DbManager.BuildingQueries.MOVE_BUILDING(cityBuilding.getObjectUUID(), newParent.getObjectUUID(), localCoords.x, localCoords.y, localCoords.z);
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.
// 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);
if (cityBuilding.getParentZoneID() != newParent.getParentZoneID())
cityBuilding.setParentZone(newParent);
// No longer a tree, no longer any protection contract!
// No longer a tree, no longer any protection contract!
cityBuilding.setProtectionState(mbEnums.ProtectionState.NONE);
cityBuilding.setProtectionState(mbEnums.ProtectionState.NONE);
// Remove warehouse entry if one exists.
// Remove warehouse entry if one exists.
if (cityBuilding.getBlueprint().getBuildingGroup().equals(mbEnums.BuildingGroup.WAREHOUSE)) {
DbManager.WarehouseQueries.DELETE_WAREHOUSE(city.warehouse);
city.warehouse = null;
}
if (cityBuilding.getBlueprint().getBuildingGroup().equals(mbEnums.BuildingGroup.WAREHOUSE)) {
DbManager.WarehouseQueries.DELETE_WAREHOUSE(city.warehouse);
city.warehouse = null;
}
// Destroy all remaining auto-protected city assets
// 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);
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 (assetsToDestroy.contains(cityBuilding.getBlueprint().getBuildingGroup())) {
if (cityBuilding.getRank() != -1)
BuildingManager.setRank(cityBuilding, -1);
if (cityBuilding.getRank() != -1)
BuildingManager.setRank(cityBuilding, -1);
}
}
}
if (city.realm != null)
city.realm.removeCity(city.getObjectUUID());
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
// 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;
}
if (DbManager.ZoneQueries.DELETE_ZONE(cityZone) == false) {
Logger.error("DestroyCityThread", "Error when deleting city zone: " + cityZone.getObjectUUID());
return;
}
// Refresh the city for map requests
// Refresh the city for map requests
City.lastCityUpdate = System.currentTimeMillis();
City.lastCityUpdate = System.currentTimeMillis();
} catch (Exception e) {
Logger.error(e);
}
// Zone and city should vanish upon next reboot
// if the codebase reaches here.

Loading…
Cancel
Save