bug(stats): win events can be double-counted if multiple WinEvent fire in the same frame #69

Closed
opened 2026-05-28 01:52:11 +00:00 by funman300 · 0 comments
Owner

Bug

stats_plugin.rs iterates all WinEvent events in a single system. If, due to a race or a replay fast-forward, multiple WinEvents fire in the same frame, the stats counter increments multiple times for what should be a single win.

Affected file

solitaire_engine/src/stats_plugin.rs

Fix

Drain only the first win event per frame (or deduplicate by game session ID):

if let Some(ev) = win_events.read().next() {
    stats.wins += 1;
    // process ev
}
// ignore any additional WinEvents this frame

Or add a game_id to WinEvent and track which game IDs have already been counted.

## Bug `stats_plugin.rs` iterates all `WinEvent` events in a single system. If, due to a race or a replay fast-forward, multiple `WinEvent`s fire in the same frame, the stats counter increments multiple times for what should be a single win. ## Affected file `solitaire_engine/src/stats_plugin.rs` ## Fix Drain only the **first** win event per frame (or deduplicate by game session ID): ```rust if let Some(ev) = win_events.read().next() { stats.wins += 1; // process ev } // ignore any additional WinEvents this frame ``` Or add a `game_id` to `WinEvent` and track which game IDs have already been counted.
funman300 added the bugcorrectness labels 2026-05-28 01:52:11 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: funman300/Ferrous-Solitaire#69