From: Holger Schemel Date: Wed, 22 Mar 2023 17:12:49 +0000 (+0100) Subject: moved requesting game restart to function that checks for game over X-Git-Tag: 4.3.5.3~34 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=c118d37bf6ad02e90d4ea7c4a4d7d34d8f745c26;p=rocksndiamonds.git moved requesting game restart to function that checks for game over --- diff --git a/src/game.c b/src/game.c index ae65ccd9..c5d941dd 100644 --- a/src/game.c +++ b/src/game.c @@ -15678,7 +15678,7 @@ static char *getRestartGameMessage(void) return message; } -void CheckGameOver(void) +boolean CheckRestartGame(void) { static boolean last_game_over = FALSE; static int game_over_delay = 0; @@ -15690,7 +15690,7 @@ void CheckGameOver(void) last_game_over = FALSE; game_over_delay = game_over_delay_value; - return; + return FALSE; } if (game_over_delay > 0) @@ -15700,25 +15700,34 @@ void CheckGameOver(void) game_over_delay--; - return; + return FALSE; } // do not handle game over if request dialog is already active if (game.request_active) - return; + return FALSE; // do not ask to play again if game was never actually played if (!game.GamePlayed) - return; + return FALSE; // do not ask to play again if this was disabled in setup menu if (!setup.ask_on_game_over) - return; + return FALSE; if (last_game_over != game_over) game.restart_game_message = getRestartGameMessage(); last_game_over = game_over; + + if (game.restart_game_message != NULL) + { + RequestRestartGame(game.restart_game_message); + + return TRUE; + } + + return FALSE; } boolean checkGameSolved(void) diff --git a/src/game.h b/src/game.h index 26c186fe..95531163 100644 --- a/src/game.h +++ b/src/game.h @@ -456,8 +456,8 @@ void RaiseScoreElement(int); void RequestQuitGameExt(boolean, boolean, char *); void RequestQuitGame(boolean); void RequestRestartGame(char *); -void CheckGameOver(void); +boolean CheckRestartGame(void); boolean checkGameSolved(void); boolean checkGameFailed(void); boolean checkGameEnded(void); diff --git a/src/screens.c b/src/screens.c index eecb688b..c4955e8c 100644 --- a/src/screens.c +++ b/src/screens.c @@ -9527,14 +9527,8 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) void HandleGameActions(void) { - CheckGameOver(); - - if (game.restart_game_message != NULL) - { - RequestRestartGame(game.restart_game_message); - + if (CheckRestartGame()) return; - } if (game_status != GAME_MODE_PLAYING) return;