From: Holger Schemel Date: Fri, 12 Oct 2018 17:11:03 +0000 (+0200) Subject: added functions to check if game is over (and solved or not) (not used yet) X-Git-Tag: 4.1.2.0~136 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=8cae2f011a23232a4233e808fd1092d2871603e6;p=rocksndiamonds.git added functions to check if game is over (and solved or not) (not used yet) --- diff --git a/src/game.c b/src/game.c index c0fa1680..5bfa71db 100644 --- a/src/game.c +++ b/src/game.c @@ -14949,6 +14949,32 @@ void RequestRestartGame(char *message) } } +boolean checkGameSolved(void) +{ + /* set for all game engines if level was solved */ + return local_player->LevelSolved_GameEnd; +} + +boolean checkGameFailed(void) +{ + if (!AllPlayersGone) + return FALSE; + + if (level.game_engine_type == GAME_ENGINE_TYPE_EM) + return (level.native_em_level->lev->home > 0); + else if (level.game_engine_type == GAME_ENGINE_TYPE_SP) + return (game_sp.GameOver && !game_sp.LevelSolved); + else if (level.game_engine_type == GAME_ENGINE_TYPE_MM) + return (game_mm.game_over && !game_mm.level_solved); + else /* GAME_ENGINE_TYPE_RND */ + return (local_player->GameOver && !local_player->LevelSolved); +} + +boolean checkGameEnded(void) +{ + return (checkGameSolved() || checkGameFailed()); +} + /* ------------------------------------------------------------------------- */ /* random generator functions */ diff --git a/src/game.h b/src/game.h index 3b79cb5d..5fab8390 100644 --- a/src/game.h +++ b/src/game.h @@ -418,6 +418,10 @@ void RequestQuitGameExt(boolean, boolean, char *); void RequestQuitGame(boolean); void RequestRestartGame(char *); +boolean checkGameSolved(void); +boolean checkGameFailed(void); +boolean checkGameEnded(void); + unsigned int InitEngineRandom_RND(int); unsigned int RND(int);