From 01641081a40849079b565b7fbde494814c4b18d4 Mon Sep 17 00:00:00 2001 From: Daniel Monteiro Date: Mon, 1 Jul 2024 23:06:27 +0100 Subject: [PATCH] [MX, GL, EE] Fixes crash when completing the game or on game over --- common/include/Enums.h | 3 ++- common/src/Dungeon.c | 4 ++++ common/src/Events.c | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/common/include/Enums.h b/common/include/Enums.h index 49c2e81e3..bc33a8e70 100644 --- a/common/include/Enums.h +++ b/common/include/Enums.h @@ -12,7 +12,8 @@ enum EDirection { enum CrawlerState { kCrawlerGameOver = -1, kCrawlerQuit = 0, - kCrawlerGameInProgress = 1 + kCrawlerGameInProgress = 1, + kCrawlerGameFinished = 2 }; enum ECommand { diff --git a/common/src/Dungeon.c b/common/src/Dungeon.c index b63826266..6d58e4869 100644 --- a/common/src/Dungeon.c +++ b/common/src/Dungeon.c @@ -295,18 +295,22 @@ struct GameSnapshot dungeonTick(const enum ECommand command) { switch (getGameStatus()) { case kBadVictory: + gameSnapshot.should_continue = kCrawlerGameFinished; enterState(kBadVictoryEpilogue); return gameSnapshot; case kBadGameOver: + gameSnapshot.should_continue = kCrawlerGameFinished; enterState(kBadGameOverEpilogue); return gameSnapshot; case kGoodVictory: + gameSnapshot.should_continue = kCrawlerGameFinished; enterState(kGoodVictoryEpilogue); return gameSnapshot; case kGoodGameOver: + gameSnapshot.should_continue = kCrawlerGameFinished; enterState(kGoodGameOverEpilogue); return gameSnapshot; default: diff --git a/common/src/Events.c b/common/src/Events.c index 2167b1c4d..c78d2682b 100644 --- a/common/src/Events.c +++ b/common/src/Events.c @@ -147,6 +147,10 @@ int loopTick(enum ECommand command) { tickMission(command); + if (crawlerGameState == kCrawlerGameFinished) { + return kCrawlerGameFinished; + } + if (gameTicks != 0) { yCameraOffset = ((struct CTile3DProperties *) getFromMap(&tileProperties, LEVEL_MAP(x, z)))->mFloorHeight -