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() {
|
public void destroy() {
|
||||||
|
|
||||||
//tell the actor thread to finish, then wait for it to complete any actions it may be doing.
|
//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();
|
Throwable t = new Throwable();
|
||||||
t.setStackTrace(actorThread.getStackTrace());
|
t.setStackTrace(actorThread.getStackTrace());
|
||||||
throw new RuntimeException("timeout waiting for actor thread! ", t);
|
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()) {
|
if (actorThread == null || !actorThread.isAlive()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
synchronized (actorThread) {
|
synchronized (actorThread) {
|
||||||
actorThread.interrupt();
|
if (interrupt) actorThread.interrupt();
|
||||||
try {
|
try {
|
||||||
actorThread.wait(msToWait);
|
actorThread.wait(msToWait);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
@ -605,7 +605,7 @@ public class GameScene extends PixelScene {
|
||||||
@Override
|
@Override
|
||||||
public synchronized void onPause() {
|
public synchronized void onPause() {
|
||||||
try {
|
try {
|
||||||
waitForActorThread(500);
|
if (!Dungeon.hero.ready) waitForActorThread(1000, false);
|
||||||
Dungeon.saveAll();
|
Dungeon.saveAll();
|
||||||
Badges.saveGlobal();
|
Badges.saveGlobal();
|
||||||
Journal.saveGlobal();
|
Journal.saveGlobal();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user