added creating engine snapshots when using mouse click events
authorHolger Schemel <info@artsoft.org>
Sat, 3 Oct 2020 23:52:40 +0000 (01:52 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 3 Oct 2020 23:52:40 +0000 (01:52 +0200)
Before, when using mouse click events as CE change events, clicking on
a CE with mouse click event did not save a new game engine snapshot,
so undo/redo of CE mouse click events did not work.

With this change, undo/redo snapshots will also be created when using
mouse click events.

src/game.c

index 5e4e151fe3134c7548cce810dff6eb1f72fe7648..8b77ddef674f65d232e0c968c5e4c5ef9529870f 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)