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 c0fa168..5bfa71d 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 3b79cb5..5fab839 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);