From 668b61b734fdf176cf55515a0f9755a987eaaeaa Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 25 Aug 2024 17:11:01 -0400 Subject: [PATCH] city.isDestroyed --- src/engine/objects/City.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/engine/objects/City.java b/src/engine/objects/City.java index a4591532..52f09882 100644 --- a/src/engine/objects/City.java +++ b/src/engine/objects/City.java @@ -41,6 +41,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.locks.ReentrantReadWriteLock; public class City extends AbstractWorldObject { @@ -80,6 +81,7 @@ public class City extends AbstractWorldObject { private String hash; public Warehouse warehouse; public Realm realm; + public AtomicBoolean isDestroyed = new AtomicBoolean(false); /** * ResultSet Constructor @@ -1102,10 +1104,14 @@ public class City extends AbstractWorldObject { public final void destroy() { - Thread destroyCityThread = new Thread(new DestroyCityThread(this)); + if (this.isDestroyed.compareAndSet(false, true)) { - destroyCityThread.setName("destroyCity:" + this.getParent().zoneName); - destroyCityThread.start(); + Thread destroyCityThread = new Thread(new DestroyCityThread(this)); + + destroyCityThread.setName("destroyCity:" + this.getParent().zoneName); + destroyCityThread.start(); + } else + Logger.error("Attempt to destroy destroyed city"); } public final void transfer(AbstractCharacter newOwner) {