From f459d13abcc4b9966d23ff233201d77039b73777 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 10 Mar 2018 20:18:07 +0100 Subject: [PATCH] added asking for restart after game was lost (MM game engine only) --- src/game.c | 17 +++++++++++++++++ src/game.h | 4 ++++ src/game_mm/mm_game.c | 6 ++++++ src/init.c | 1 + src/screens.c | 3 +++ 5 files changed, 31 insertions(+) diff --git a/src/game.c b/src/game.c index 464cdc0b..f8606638 100644 --- a/src/game.c +++ b/src/game.c @@ -4227,6 +4227,7 @@ void InitGame() } game.restart_level = FALSE; + game.restart_game_message = NULL; if (level.game_engine_type == GAME_ENGINE_TYPE_MM) InitGameActions_MM(); @@ -14958,6 +14959,22 @@ void RequestQuitGame(boolean ask_if_really_quit) "Do you really want to quit the game?"); } +void RequestRestartGame(char *message) +{ + game.restart_game_message = NULL; + + if (Request(message, REQ_ASK | REQ_STAY_CLOSED)) + { + StartGameActions(options.network, setup.autorecord, level.random_seed); + } + else + { + SetGameStatus(GAME_MODE_MAIN); + + DrawMainMenu(); + } +} + /* ------------------------------------------------------------------------- */ /* random generator functions */ diff --git a/src/game.h b/src/game.h index 34854a77..93e1d094 100644 --- a/src/game.h +++ b/src/game.h @@ -207,6 +207,9 @@ struct GameInfo /* values for special game initialization control */ boolean restart_level; + /* trigger message to ask for restarting the game */ + char *restart_game_message; + /* values for special game control */ int centered_player_nr; int centered_player_nr_next; @@ -410,6 +413,7 @@ void RaiseScoreElement(int); void RequestQuitGameExt(boolean, boolean, char *); void RequestQuitGame(boolean); +void RequestRestartGame(char *); unsigned int InitEngineRandom_RND(int); unsigned int RND(int); diff --git a/src/game_mm/mm_game.c b/src/game_mm/mm_game.c index 96be05c4..0a9d2da6 100644 --- a/src/game_mm/mm_game.c +++ b/src/game_mm/mm_game.c @@ -2490,6 +2490,8 @@ static void Explode_MM(int x, int y, int phase, int mode) else if (IS_MCDUFFIN(Store[x][y])) { Store[x][y] = EL_EMPTY; + + game.restart_game_message = "Bomb killed Mc Duffin ! Play it again ?"; } Feld[x][y] = Store[x][y]; @@ -3181,6 +3183,8 @@ static void GameActions_MM_Ext(struct MouseActionInfo action, boolean warp_mode) SetTileCursorActive(FALSE); + game.restart_game_message = "Out of magic energy ! Play it again ?"; + #if 0 if (Request("Out of magic energy ! Play it again ?", REQ_ASK | REQ_STAY_CLOSED)) @@ -3313,6 +3317,8 @@ static void GameActions_MM_Ext(struct MouseActionInfo action, boolean warp_mode) SetTileCursorActive(FALSE); + game.restart_game_message = "Magic spell hit Mc Duffin ! Play it again ?"; + #if 0 if (Request("Magic spell hit Mc Duffin ! Play it again ?", REQ_ASK | REQ_STAY_CLOSED)) diff --git a/src/init.c b/src/init.c index dc929129..45f08cd6 100644 --- a/src/init.c +++ b/src/init.c @@ -5064,6 +5064,7 @@ static void InitSetup() static void InitGameInfo() { game.restart_level = FALSE; + game.restart_game_message = NULL; } static void InitPlayerInfo() diff --git a/src/screens.c b/src/screens.c index 1a2bc9b7..e20f4deb 100644 --- a/src/screens.c +++ b/src/screens.c @@ -7091,6 +7091,9 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) void HandleGameActions() { + if (game.restart_game_message != NULL) + RequestRestartGame(game.restart_game_message); + if (game_status != GAME_MODE_PLAYING) return; -- 2.34.1