Browse Source

Debug code added

bane-updates
MagicBot 4 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 {
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) {
subGuildList = new ArrayList<>(); //Successful Update of guild
for (Guild subGuild : formerGuild.getSubGuildList()) { formerGuild.setGuildState(mbEnums.GuildState.Errant);
subGuildList.add(subGuild); formerGuild.setNation(null);
formerGuild.setCityUUID(0);
GuildManager.updateAllGuildTags(formerGuild);
GuildManager.updateAllGuildBinds(formerGuild, null);
} }
for (Guild subGuild : subGuildList) { if (formerGuild.getSubGuildList().isEmpty() == false) {
formerGuild.removeSubGuild(subGuild);
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 // Sanity Check in case player deletes the building
// before this thread can get to it // before this thread can get to it
if (cityBuilding == null) if (cityBuilding == null)
continue; 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)) if (cityBuilding.getBlueprint().getBuildingGroup().equals(mbEnums.BuildingGroup.BANESTONE))
continue; 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
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 // All buildings are re-parented to a zone one node
// higher in the tree (continent) as we will be // higher in the tree (continent) as we will be
// deleting the city zone very shortly. // deleting the city zone very shortly.
if (cityBuilding.getParentZoneID() != newParent.getParentZoneID()) if (cityBuilding.getParentZoneID() != newParent.getParentZoneID())
cityBuilding.setParentZone(newParent); 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)) { 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 auto-protected city assets // Destroy all remaining auto-protected city assets
EnumSet<mbEnums.BuildingGroup> assetsToDestroy = EnumSet.of(mbEnums.BuildingGroup.TOL, mbEnums.BuildingGroup.BARRACK, EnumSet<mbEnums.BuildingGroup> assetsToDestroy = EnumSet.of(mbEnums.BuildingGroup.TOL, mbEnums.BuildingGroup.BARRACK,
mbEnums.BuildingGroup.SPIRE, mbEnums.BuildingGroup.SHRINE, mbEnums.BuildingGroup.WAREHOUSE); 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) if (cityBuilding.getRank() != -1)
BuildingManager.setRank(cityBuilding, -1); BuildingManager.setRank(cityBuilding, -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", "Error when deleting city zone: " + cityZone.getObjectUUID()); Logger.error("DestroyCityThread", "Error when deleting city zone: " + cityZone.getObjectUUID());
return; 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 // Zone and city should vanish upon next reboot
// if the codebase reaches here. // if the codebase reaches here.

Loading…
Cancel
Save