+ // do not handle game over if request dialog is already active
+ if (game.request_active)
+ return;
+
+ if (!game_over)
+ {
+ last_game_over = FALSE;
+ game_over_delay = game_over_delay_value;
+
+ return;
+ }
+
+ if (game_over_delay > 0)
+ {
+ game_over_delay--;
+
+ return;
+ }
+
+ if (last_game_over != game_over)
+ game.restart_game_message = (hasStartedNetworkGame() ?
+ "Game over! Play it again?" :
+ "Game over!");
+
+ last_game_over = game_over;
+}
+
+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 (game_em.game_over && !game_em.level_solved);
+ else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
+ return (game_sp.game_over && !game_sp.level_solved);
+ 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
+// ----------------------------------------------------------------------------