v1.1.0: fixed game pause interrupting the actor thread when it shouldn't
This commit is contained in:
parent
1eff353254
commit
6a61d0851b
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue
Block a user