fixed bug with CE replacing exploding player, causing half-dead player
authorHolger Schemel <info@artsoft.org>
Sun, 8 Oct 2023 21:33:54 +0000 (23:33 +0200)
committerHolger Schemel <info@artsoft.org>
Sun, 8 Oct 2023 21:39:47 +0000 (23:39 +0200)
This bug could happen when a player was just exploding (for whatever
reason) and an adjacent CE replaced the explosion's center element
with something else, leading to the player not being totally removed,
potentially causing some strange effects afterwards.

This change adds some cleanup required to prevent such cases.

src/game.c

index ef117c8fa9409fc9bc4e63b6878a1e5e022c185b..338355393f4e08063bc4de7ab28fe820fde403f8 100644 (file)
@@ -10642,6 +10642,15 @@ static void CreateFieldExt(int x, int y, int element, boolean is_change)
     if (GFX_CRUMBLED(new_element))
       TEST_DrawLevelFieldCrumbledNeighbours(x, y);
 
+    if (old_element == EL_EXPLOSION)
+    {
+      Store[x][y] = Store2[x][y] = 0;
+
+      // check if new element replaces an exploding player, requiring cleanup
+      if (IS_PLAYER(x, y) && !PLAYERINFO(x, y)->present)
+       StorePlayer[x][y] = 0;
+    }
+
     // 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)