fixed bug with CE actions "show envelope" and "exit player" when moving
authorHolger Schemel <info@artsoft.org>
Mon, 17 Dec 2018 08:14:05 +0000 (09:14 +0100)
committerHolger Schemel <info@artsoft.org>
Mon, 17 Dec 2018 08:28:11 +0000 (09:28 +0100)
When using the CE actions "show envelope" or "exit player" with the
condition "after explosion of player", those actions are not performed
if the player was moving at the time of explosion, as they are both
waiting for the player to reach the next tile (which will never happen
in this case).

The best solution is to only check for a "non-moving" tile position of
the player if the player is still active, which will fix the problem.

However, as the check for a "non-moving" tile position is used very
frequently, setting the tile position to "non-moving" for inactive
players was added.

src/game.c

index d517cdc..6463df1 100644 (file)
@@ -4503,7 +4503,7 @@ void GameWon(void)
     int i;
 
     // do not start end game actions before the player stops moving (to exit)
-    if (local_player->MovPos)
+    if (local_player->active && local_player->MovPos)
       return;
 
     game.LevelSolved_GameWon = TRUE;
@@ -12164,7 +12164,8 @@ void GameActions_RND(void)
   DrawAllPlayers();
   PlayAllPlayersSound();
 
-  if (local_player->show_envelope != 0 && local_player->MovPos == 0)
+  if (local_player->show_envelope != 0 && (!local_player->active ||
+                                          local_player->MovPos == 0))
   {
     ShowEnvelope(local_player->show_envelope - EL_ENVELOPE_1);
 
@@ -13451,6 +13452,9 @@ void RemovePlayer(struct PlayerInfo *player)
   player->present = FALSE;
   player->active = FALSE;
 
+  // required for some CE actions (even if the player is not active anymore)
+  player->MovPos = 0;
+
   if (!ExplodeField[jx][jy])
     StorePlayer[jx][jy] = 0;