From 6a61d0851b5a0c9eb72677d86ed42d07d6c0a8bb Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sat, 23 Oct 2021 14:33:25 -0400 Subject: [PATCH] v1.1.0: fixed game pause interrupting the actor thread when it shouldn't --- .../shatteredpixeldungeon/scenes/GameScene.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 74acc4ab8..8a4698318 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java @@ -565,7 +565,7 @@ public class GameScene extends PixelScene { public void destroy() { //tell the actor thread to finish, then wait for it to complete any actions it may be doing. - if (!waitForActorThread( 4500 )){ + if (!waitForActorThread( 4500, true )){ Throwable t = new Throwable(); t.setStackTrace(actorThread.getStackTrace()); throw new RuntimeException("timeout waiting for actor thread! ", t); @@ -587,12 +587,12 @@ public class GameScene extends PixelScene { } } - public boolean waitForActorThread(int msToWait ){ + public boolean waitForActorThread(int msToWait, boolean interrupt){ if (actorThread == null || !actorThread.isAlive()) { return true; } synchronized (actorThread) { - actorThread.interrupt(); + if (interrupt) actorThread.interrupt(); try { actorThread.wait(msToWait); } catch (InterruptedException e) { @@ -605,7 +605,7 @@ public class GameScene extends PixelScene { @Override public synchronized void onPause() { try { - waitForActorThread(500); + if (!Dungeon.hero.ready) waitForActorThread(1000, false); Dungeon.saveAll(); Badges.saveGlobal(); Journal.saveGlobal();