diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Actor.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Actor.java index 0ea86159c..7834abc70 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Actor.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Actor.java @@ -179,21 +179,24 @@ public abstract class Actor implements Bundlable { boolean interrupted = false; do { - now = Float.MAX_VALUE; - current = null; - for (Actor actor : all) { + current = null; + if (!interrupted) { + now = Float.MAX_VALUE; - //some actors will always go before others if time is equal. - if (actor.time < now || - actor.time == now && (current == null || actor.actPriority < current.actPriority)) { - now = actor.time; - current = actor; + for (Actor actor : all) { + + //some actors will always go before others if time is equal. + if (actor.time < now || + actor.time == now && (current == null || actor.actPriority < current.actPriority)) { + now = actor.time; + current = actor; + } + } - } - if (!interrupted && current != null) { + if (current != null) { Actor acting = current; @@ -228,6 +231,7 @@ public abstract class Actor implements Bundlable { synchronized (Thread.currentThread()) { synchronized (GameScene.class){ + //signals to the gamescene that actor processing is finished for now GameScene.class.notify(); } try { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java index e5c910a79..2c2a7de49 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java @@ -416,11 +416,10 @@ public class GameScene extends PixelScene { //tell the actor thread to finish, then wait for it to complete any actions it may be doing. if (actorThread.isAlive()){ - synchronized (actorThread) { - actorThread.interrupt(); - } synchronized (GameScene.class){ - if (actorThread.getState() != Thread.State.WAITING) { + synchronized (actorThread) { + actorThread.interrupt(); + } try { GameScene.class.wait(5000); } catch (InterruptedException e) { @@ -432,7 +431,6 @@ public class GameScene extends PixelScene { t.setStackTrace(actorThread.getStackTrace()); throw new RuntimeException("timeout waiting for actor thread! ", t); } - } } } }