fixed graphical bugs if digging or collecting caused player relocation
[rocksndiamonds.git] / src / game.c
index 5e4e151fe3134c7548cce810dff6eb1f72fe7648..c6a7ef73146a7cf1bd90b59121cbf0856b802189 100644 (file)
@@ -11200,6 +11200,15 @@ static void CheckSaveEngineSnapshot(struct PlayerInfo *player)
     if (!player->is_dropping)
       player->was_dropping = FALSE;
   }
+
+  static struct MouseActionInfo mouse_action_last = { 0 };
+  struct MouseActionInfo mouse_action = player->effective_mouse_action;
+  boolean new_released = (!mouse_action.button && mouse_action_last.button);
+
+  if (new_released)
+    CheckSaveEngineSnapshotToList();
+
+  mouse_action_last = mouse_action;
 }
 
 static void CheckSingleStepMode(struct PlayerInfo *player)
@@ -13988,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)
@@ -14109,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)