530b56c33c6215cf4211db09990af0573b442454
Two root causes fixed: 1. Race condition (primary cause): SaveStateAsync committed the transaction with Phase=GameOver in StateJson, but session.Status was not set to Completed until a separate SaveChangesAsync in FinalizeGameAsync. If the server crashed or any exception was thrown between those two calls, the session was left Active with a GameOver state — causing the "active game" prompt on next login. Fix: each game-over handler (concede, force_concede, attack) now sets session.Status/WinnerAccountId/WinCondition/EndedAt BEFORE calling SaveStateAsync, so all fields commit atomically in the same transaction. 2. Wrong save order in FinalizeGameAsync: identityDb.SaveChangesAsync (ELO update) ran before gameDb.SaveChangesAsync (Status=Completed). Any transient identity-DB error left the session permanently Active. Fix: gameDb is saved first; ELO runs after, so a failed ELO update never causes a ghost match. 3. Defensive startup heal (GameStartupCleanupService): on server start, Active sessions whose StateJson contains Phase=GameOver are now detected and marked Completed. game.over is pushed to any still-connected clients so they can exit cleanly. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
Description
No description provided
53 MiB
Languages
C#
52.7%
HTML
24.9%
GDScript
21.2%
CSS
0.8%
Python
0.3%
Other
0.1%