Replay backward step decrements cursor before undo is applied — cursor/state mismatch and rapid-click divergence #16

Closed
opened 2026-05-19 18:43:04 +00:00 by funman300 · 0 comments
Owner

File

solitaire_engine/src/replay_playback.rs lines 328–329

Description

*cursor -= 1;
undo_writer.write(UndoRequestEvent);

The cursor is decremented immediately, but handle_undo only applies the undo the following frame. For one frame the overlay shows cursor = N-1 while the cards are still in position N — the move log, scrub fill, and "MOVE N/M" counter all show the wrong state, producing a visible flicker.

Worse: if the player clicks the backwards button multiple times in a single frame, multiple cursor decrements accumulate before any undo fires, permanently diverging the cursor from the actual game history.

Fix

Either decrement the cursor only after confirming the undo was applied (via StateChangedEvent), or debounce to allow at most one backward step per frame.

## File `solitaire_engine/src/replay_playback.rs` lines 328–329 ## Description ```rust *cursor -= 1; undo_writer.write(UndoRequestEvent); ``` The cursor is decremented immediately, but `handle_undo` only applies the undo the following frame. For one frame the overlay shows `cursor = N-1` while the cards are still in position N — the move log, scrub fill, and "MOVE N/M" counter all show the wrong state, producing a visible flicker. Worse: if the player clicks the backwards button multiple times in a single frame, multiple cursor decrements accumulate before any undo fires, permanently diverging the cursor from the actual game history. ## Fix Either decrement the cursor only after confirming the undo was applied (via `StateChangedEvent`), or debounce to allow at most one backward step per frame.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: funman300/Ferrous-Solitaire#16