added functions to check if game is over (and solved or not) (not used yet)
authorHolger Schemel <info@artsoft.org>
Fri, 12 Oct 2018 17:11:03 +0000 (19:11 +0200)
committerHolger Schemel <info@artsoft.org>
Fri, 12 Oct 2018 17:11:03 +0000 (19:11 +0200)
src/game.c
src/game.h

index c0fa1680b8c8ada252f5abe538d633499756930a..5bfa71db14d69900b035c2d31a0e60df472027bd 100644 (file)
@@ -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                                                */
index 3b79cb5d27e4ef817e13d9af119f34842e521d17..5fab8390aa479813373faab3268edc2890632152 100644 (file)
@@ -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);