moved flag for "game over" from player to game structure
authorHolger Schemel <info@artsoft.org>
Mon, 5 Nov 2018 20:35:53 +0000 (21:35 +0100)
committerHolger Schemel <info@artsoft.org>
Mon, 5 Nov 2018 20:35:53 +0000 (21:35 +0100)
This also removes asymmetric behaviour depending on players being the
"local player" or any other player in team mode (which happened if one
player dies and the other enters the exit, for example -- in one case,
the game will be treated as "game over", in the other case the game
will continue running without asking to play again).

src/game.c
src/game.h

index acba22e9b2f67838bbde1ba74c84b6bedf5fb9ab..2308c32b0e8bef612aeca72b5a9264c438c51fd2 100644 (file)
@@ -3396,6 +3396,7 @@ void InitGame(void)
 
     player->killed = FALSE;
     player->reanimated = FALSE;
+    player->buried = FALSE;
 
     player->action = 0;
     player->effective_action = 0;
@@ -3539,8 +3540,6 @@ void InitGame(void)
     DigField(player, 0, 0, 0, 0, 0, 0, DF_NO_PUSH);
     SnapField(player, 0, 0);
 
-    player->GameOver = FALSE;
-
     map_player_action[i] = i;
   }
 
@@ -3568,6 +3567,7 @@ void InitGame(void)
   AllPlayersGone = FALSE;
 
   game.LevelSolved = FALSE;
+  game.GameOver = FALSE;
 
   game.LevelSolved_GameWon = FALSE;
   game.LevelSolved_GameEnd = FALSE;
@@ -4464,8 +4464,7 @@ static void LevelSolved(void)
     return;
 
   game.LevelSolved = TRUE;
-
-  local_player->GameOver = TRUE;
+  game.GameOver = TRUE;
 
   local_player->score_final = (level.game_engine_type == GAME_ENGINE_TYPE_EM ?
                               level.native_em_level->lev->score :
@@ -5304,7 +5303,7 @@ static void RelocatePlayer(int jx, int jy, int el_player_raw)
   int enter_side = enter_side_horiz | enter_side_vert;
   int leave_side = leave_side_horiz | leave_side_vert;
 
-  if (player->GameOver)                // do not reanimate dead player
+  if (player->buried)          // do not reanimate dead player
     return;
 
   if (!player_relocated)       // no need to relocate the player
@@ -7951,7 +7950,7 @@ static void StartMoving(int x, int y)
 
        game.friends_still_needed--;
        if (!game.friends_still_needed &&
-           !local_player->GameOver && AllPlayersGone)
+           !game.GameOver && AllPlayersGone)
          LevelSolved();
 
        return;
@@ -13404,8 +13403,10 @@ void BuryPlayer(struct PlayerInfo *player)
   PlayLevelSoundElementAction(jx, jy, player->artwork_element, ACTION_DYING);
   PlayLevelSound(jx, jy, SND_GAME_LOSING);
 
-  player->GameOver = TRUE;
   RemovePlayer(player);
+
+  player->buried = TRUE;
+  game.GameOver = TRUE;
 }
 
 void RemovePlayer(struct PlayerInfo *player)
@@ -15045,7 +15046,7 @@ boolean checkGameFailed(void)
   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 && !game.LevelSolved);
+    return (game.GameOver && !game.LevelSolved);
 }
 
 boolean checkGameEnded(void)
index a0ffe85a31b15e7dff94dee66e4c7ef24844c3b9..fffbefa2766009efdb2e86d4129312799e7a632d 100644 (file)
@@ -186,6 +186,7 @@ struct GameInfo
   int belt_dir_nr[4];
   int switchgate_pos;
   int wind_direction;
+
   boolean explosions_delayed;
   boolean envelope_active;
   boolean no_time_limit;       // (variable only in very special case)
@@ -229,8 +230,9 @@ struct GameInfo
   // values for game engine snapshot control
   struct GameSnapshotInfo snapshot;
 
-  // values for handling states for solved level
+  // values for handling states for solved level and game over
   boolean LevelSolved;
+  boolean GameOver;
 
   boolean LevelSolved_GameWon;
   boolean LevelSolved_GameEnd;
@@ -253,6 +255,7 @@ struct PlayerInfo
 
   boolean killed;              // player maybe present/active, but killed
   boolean reanimated;          // player maybe killed, but reanimated
+  boolean buried;              // player finally killed and removed
 
   int index_nr;                        // player number (0 to 3)
   int index_bit;               // player number bit (1 << 0 to 1 << 3)
@@ -287,8 +290,6 @@ struct PlayerInfo
 
   boolean gravity;
 
-  boolean GameOver;
-
   int last_move_dir;
 
   boolean is_active;