Do not change rooms if scene failed to load

Sometimes a following room fails to load (e.g., #582) and instead of fading to black (as no scene is active) when trying to enter that next room, the player will stay in the old room and an error is logged (as throwing one crashes the game).
This commit is contained in:
MisterErwin 2021-02-13 14:15:09 +01:00 committed by GitHub
parent cfcad07487
commit aff4c8d145
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -716,6 +716,10 @@ export class GameScene extends ResizableScene implements CenterListener {
if (!roomId) throw new Error('Could not find the room from its exit key: '+exitKey); if (!roomId) throw new Error('Could not find the room from its exit key: '+exitKey);
urlManager.pushStartLayerNameToUrl(hash); urlManager.pushStartLayerNameToUrl(hash);
if (roomId !== this.scene.key) { if (roomId !== this.scene.key) {
if (this.scene.get(roomId) === null) {
console.error("next room not loaded", exitKey);
return;
}
this.cleanupClosingScene(); this.cleanupClosingScene();
this.scene.stop(); this.scene.stop();
this.scene.remove(this.scene.key); this.scene.remove(this.scene.key);