fixed graphical bugs if digging or collecting caused player relocation 4.2.0.4
authorHolger Schemel <info@artsoft.org>
Fri, 6 Nov 2020 14:35:02 +0000 (15:35 +0100)
committerHolger Schemel <info@artsoft.org>
Fri, 6 Nov 2020 14:35:02 +0000 (15:35 +0100)
If digging or collecting (but not snapping!) certain tiles or elements
causes the player to be relocated ("teleported"), the corresponding
digging or collecting animation for this element will not be continued
anymore (because the player does not move towards this tile anymore).

To fix this problem, the digged or collected tile will be treated like
being snapped (using a temporary run-time element) for this edge case.
(The resulting engine behaviour is slightly different to the previous
behaviour, but should not break too many levels as this case should be
rather uncommon.)

src/game.c

index 8b77ddef674f65d232e0c968c5e4c5ef9529870f..c6a7ef73146a7cf1bd90b59121cbf0856b802189 100644 (file)
@@ -13997,6 +13997,10 @@ static int DigField(struct PlayerInfo *player,
     CheckTriggeredElementChangeByPlayer(x, y, element, CE_PLAYER_DIGS_X,
                                        player->index_bit, dig_side);
 
+    // if digging triggered player relocation, finish digging tile
+    if (mode == DF_DIG && (player->jx != jx || player->jy != jy))
+      setFieldForSnapping(x, y, element, move_direction);
+
     if (mode == DF_SNAP)
     {
       if (level.block_snap_field)
@@ -14118,9 +14122,15 @@ static int DigField(struct PlayerInfo *player,
     PlayLevelSoundElementAction(x, y, element, ACTION_COLLECTING);
 
     if (is_player)
+    {
       CheckTriggeredElementChangeByPlayer(x, y, element, CE_PLAYER_COLLECTS_X,
                                          player->index_bit, dig_side);
 
+      // if collecting triggered player relocation, finish collecting tile
+      if (mode == DF_DIG && (player->jx != jx || player->jy != jy))
+       setFieldForSnapping(x, y, element, move_direction);
+    }
+
     if (mode == DF_SNAP)
     {
       if (level.block_snap_field)