fixed bug with CE change setting the player to its current position
authorHolger Schemel <info@artsoft.org>
Sun, 8 Oct 2023 11:46:18 +0000 (13:46 +0200)
committerHolger Schemel <info@artsoft.org>
Sun, 8 Oct 2023 11:59:55 +0000 (13:59 +0200)
This change fixes a bug where a CE change places the player at the
current player position, causing an explosion at that playfield
position, which should not happen.

In other words, such an event would normally relocate the player, but
to a playfield position which is identical to the current playfield
position of the player, which should therefore have no effect at all.

The bug occured because it was not checked if the new element to be
created is the player itself, but only checks if an element that is
not walkable by the player is created at the players current position.

src/game.c

index 311777303723e2031c92b5b7eb46c2d268992561..ea30528996c15d9b1a706d899d0d6f0853dd5bd7 100644 (file)
@@ -10641,17 +10641,17 @@ static void CreateFieldExt(int x, int y, int element, boolean is_change)
 
     if (GFX_CRUMBLED(new_element))
       TEST_DrawLevelFieldCrumbledNeighbours(x, y);
-  }
 
-  // check if element under the player changes from accessible to unaccessible
-  // (needed for special case of dropping element which then changes)
-  // (must be checked after creating new element for walkable group elements)
-  if (IS_PLAYER(x, y) && !player_explosion_protected &&
-      IS_ACCESSIBLE(old_element) && !IS_ACCESSIBLE(new_element))
-  {
-    Bang(x, y);
+    // check if element under the player changes from accessible to unaccessible
+    // (needed for special case of dropping element which then changes)
+    // (must be checked after creating new element for walkable group elements)
+    if (IS_PLAYER(x, y) && !player_explosion_protected &&
+       IS_ACCESSIBLE(old_element) && !IS_ACCESSIBLE(new_element))
+    {
+      Bang(x, y);
 
-    return;
+      return;
+    }
   }
 
   // "ChangeCount" not set yet to allow "entered by player" change one time