Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 28836a7a4f | |||
| 5511dc7899 | |||
| e5b2247204 | |||
| 0404ca1a94 |
@@ -798,7 +798,7 @@ public enum BuildingManager {
|
|||||||
// Attempt to write to database or delete the building
|
// Attempt to write to database or delete the building
|
||||||
// if we are destroying it.
|
// if we are destroying it.
|
||||||
|
|
||||||
if (rank < 0)
|
if (rank == -1)
|
||||||
success = DbManager.BuildingQueries.DELETE_FROM_DATABASE(building);
|
success = DbManager.BuildingQueries.DELETE_FROM_DATABASE(building);
|
||||||
else
|
else
|
||||||
success = DbManager.BuildingQueries.updateBuildingRank(building, rank);
|
success = DbManager.BuildingQueries.updateBuildingRank(building, rank);
|
||||||
|
|||||||
@@ -561,7 +561,7 @@ public class Building extends AbstractWorldObject {
|
|||||||
BuildingManager.setRank(barracksBuilding, -1);
|
BuildingManager.setRank(barracksBuilding, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the tree is R8 and deranking, we need to update the
|
// If the tree is R8 and deranking, we need to update it's
|
||||||
// mesh along with buildings losing their health bonus
|
// mesh along with buildings losing their health bonus
|
||||||
|
|
||||||
if (this.rank == 8) {
|
if (this.rank == 8) {
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ import java.util.HashSet;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
|
|
||||||
public class City extends AbstractWorldObject {
|
public class City extends AbstractWorldObject {
|
||||||
@@ -81,7 +80,6 @@ public class City extends AbstractWorldObject {
|
|||||||
private String hash;
|
private String hash;
|
||||||
public Warehouse warehouse;
|
public Warehouse warehouse;
|
||||||
public Realm realm;
|
public Realm realm;
|
||||||
public AtomicBoolean isDestroyed = new AtomicBoolean(false);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ResultSet Constructor
|
* ResultSet Constructor
|
||||||
@@ -324,7 +322,6 @@ public class City extends AbstractWorldObject {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
//can't repledge to a guild you're already part of
|
//can't repledge to a guild you're already part of
|
||||||
|
|
||||||
if (repledge && city.getGuild().equals(playerCharacter.guild))
|
if (repledge && city.getGuild().equals(playerCharacter.guild))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -1119,21 +1116,17 @@ public class City extends AbstractWorldObject {
|
|||||||
|
|
||||||
public final void destroy() {
|
public final void destroy() {
|
||||||
|
|
||||||
if (this.isDestroyed.compareAndSet(false, true)) {
|
|
||||||
|
|
||||||
Thread destroyCityThread = new Thread(new DestroyCityThread(this));
|
Thread destroyCityThread = new Thread(new DestroyCityThread(this));
|
||||||
|
|
||||||
destroyCityThread.setName("destroyCity:" + this.getParent().zoneName);
|
destroyCityThread.setName("destroyCity:" + this.getName());
|
||||||
destroyCityThread.start();
|
destroyCityThread.start();
|
||||||
} else
|
|
||||||
Logger.error("Attempt to destroy destroyed city");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void transfer(AbstractCharacter newOwner) {
|
public final void transfer(AbstractCharacter newOwner) {
|
||||||
|
|
||||||
Thread transferCityThread = new Thread(new TransferCityThread(this, newOwner));
|
Thread transferCityThread = new Thread(new TransferCityThread(this, newOwner));
|
||||||
|
|
||||||
transferCityThread.setName("TransferCity:" + this.getParent().zoneName);
|
transferCityThread.setName("TransferCity:" + this.getName());
|
||||||
transferCityThread.start();
|
transferCityThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,14 +53,11 @@ public class DestroyCityThread implements Runnable {
|
|||||||
|
|
||||||
// Member variable assignment
|
// Member variable assignment
|
||||||
|
|
||||||
try {
|
|
||||||
cityZone = city.getParent();
|
cityZone = city.getParent();
|
||||||
newParent = cityZone.parent;
|
newParent = cityZone.parent;
|
||||||
formerGuild = city.getTOL().getGuild();
|
formerGuild = city.getTOL().getGuild();
|
||||||
|
|
||||||
Logger.info("Destroy city thread started for: " + cityZone.zoneName);
|
// Former guild loses it's tree!
|
||||||
|
|
||||||
// Former guild loses tree!
|
|
||||||
|
|
||||||
if (DbManager.GuildQueries.SET_GUILD_OWNED_CITY(formerGuild.getObjectUUID(), 0)) {
|
if (DbManager.GuildQueries.SET_GUILD_OWNED_CITY(formerGuild.getObjectUUID(), 0)) {
|
||||||
|
|
||||||
@@ -86,9 +83,9 @@ public class DestroyCityThread implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build list of buildings within this parent zone
|
Building tol = null;
|
||||||
|
|
||||||
ArrayList<Building> destroySet = new ArrayList<>();
|
// Build list of buildings within this parent zone
|
||||||
|
|
||||||
for (Building cityBuilding : cityZone.zoneBuildingSet) {
|
for (Building cityBuilding : cityZone.zoneBuildingSet) {
|
||||||
|
|
||||||
@@ -98,11 +95,24 @@ public class DestroyCityThread implements Runnable {
|
|||||||
if (cityBuilding == null)
|
if (cityBuilding == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// check null bluepritn and log error
|
||||||
|
if (cityBuilding.getBlueprint() == null){
|
||||||
|
Logger.error("Null Blueprint for building ID: " + cityBuilding.getObjectUUID());
|
||||||
|
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;
|
||||||
|
|
||||||
|
// 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
|
||||||
|
|
||||||
@@ -128,27 +138,33 @@ public class DestroyCityThread implements Runnable {
|
|||||||
city.warehouse = null;
|
city.warehouse = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark all auto protected buildings for destruction
|
// Destroy all remaining city assets
|
||||||
|
|
||||||
if ((cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.BARRACK) || (cityBuilding.getBlueprint().isWallPiece()) || (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.SHRINE) || (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.TOL) || (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.SPIRE) || (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.WAREHOUSE))
|
if ((cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.BARRACK)
|
||||||
destroySet.add(cityBuilding);
|
|| (cityBuilding.getBlueprint().isWallPiece())
|
||||||
|
|| (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.SHRINE)
|
||||||
|
|| (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.TOL)
|
||||||
|
|| (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.SPIRE)
|
||||||
|
|| (cityBuilding.getBlueprint().getBuildingGroup() == mbEnums.BuildingGroup.WAREHOUSE)) {
|
||||||
|
|
||||||
|
if (cityBuilding.getRank() != -1)
|
||||||
|
BuildingManager.setRank(cityBuilding, -1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destroy set of auto-protected buildings
|
// Destroy the tol
|
||||||
|
|
||||||
for (Building building : destroySet)
|
if (tol != null)
|
||||||
if (building.getRank() != -1)
|
BuildingManager.setRank(tol, -1);
|
||||||
BuildingManager.setRank(building, -1);
|
|
||||||
|
|
||||||
if (city.realm != null) {
|
if (city.realm != null)
|
||||||
city.realm.removeCity(city.getObjectUUID());
|
city.realm.removeCity(city.getObjectUUID());
|
||||||
city.realm = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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)) {
|
|
||||||
|
if (DbManager.ZoneQueries.DELETE_ZONE(cityZone) == false) {
|
||||||
Logger.error("DestroyCityThread", "Database error when deleting city zone: " + cityZone.getObjectUUID());
|
Logger.error("DestroyCityThread", "Database error when deleting city zone: " + cityZone.getObjectUUID());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -157,13 +173,9 @@ public class DestroyCityThread implements Runnable {
|
|||||||
|
|
||||||
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.
|
||||||
|
|
||||||
Logger.info(city.getParent().zoneName + " uuid: " + city.getObjectUUID() + " has been destroyed!");
|
Logger.info(city.getParent().zoneName + " uuid:" + city.getObjectUUID() + "has been destroyed!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user