Keep a won fight in the record when restarting its reward screen #334

Merged
nelsong6 merged 1 commit from codex/restart-rewind-matches-prefinished-save into main 2026-09-18 08:23:13 -07:00
nelsong6 commented 2026-09-18 08:23:07 -07:00 (Migrated from github.com)

Problem

At combat victory the game marks the room pre-finished and awaits SaveRun(room) before raising CombatEnded, so "Restart this combat rewards" replays the reward screen with the fight kept. RoomResetter still called RollBackToRoomEntry, restoring the snapshot taken at AfterRoomEntered — before the fight — erasing the fight's promoted stats while the game kept its results. Same for "event rewards" after an event-spawned fight, and for a finished Ancient event (EventRoom.OnEventStateChanged saves after RelicCmd.Obtain).

Fix

  • RunTracker.OnCombatEnded: after promotion, retake the rewind snapshot when room.IsPreFinished (losses never mark the room). No stacked-room skip, so event-spawned fights are covered.
  • New AncientEventRewindSnapshotPatch on EventRoom.OnEventStateChanged: retakes when IsPreFinished flips false → true.
  • Both gated on GameWritesRunSave(), mirroring RunSaveManager.SaveRun's ShouldSave && (Singleplayer || Host).
  • A failed capture/write now deletes the on-disk snapshot instead of leaving a stale one to be read back after a hot reload.
  • Primer's "Rewinding The Game Means Rewinding The Record" section and RoomResetter comments updated (snapshot is disk-persisted; rest sites/treasure rooms are offered; pre-finished rooms are offered, not refused).

Validation

Built, deployed, hot-reloaded: Core.Initialize complete, 436 classes patched, 0 failed/skipped, EventRoom.OnEventStateChanged in the patched-methods list. Tests and live behavioral verification not run (user-owned).

## Problem At combat victory the game marks the room pre-finished and awaits `SaveRun(room)` **before** raising `CombatEnded`, so "Restart this combat rewards" replays the reward screen with the fight kept. `RoomResetter` still called `RollBackToRoomEntry`, restoring the snapshot taken at `AfterRoomEntered` — before the fight — erasing the fight's promoted stats while the game kept its results. Same for "event rewards" after an event-spawned fight, and for a finished Ancient event (`EventRoom.OnEventStateChanged` saves after `RelicCmd.Obtain`). ## Fix - `RunTracker.OnCombatEnded`: after promotion, retake the rewind snapshot when `room.IsPreFinished` (losses never mark the room). No stacked-room skip, so event-spawned fights are covered. - New `AncientEventRewindSnapshotPatch` on `EventRoom.OnEventStateChanged`: retakes when `IsPreFinished` flips false → true. - Both gated on `GameWritesRunSave()`, mirroring `RunSaveManager.SaveRun`'s `ShouldSave && (Singleplayer || Host)`. - A failed capture/write now deletes the on-disk snapshot instead of leaving a stale one to be read back after a hot reload. - Primer's "Rewinding The Game Means Rewinding The Record" section and `RoomResetter` comments updated (snapshot is disk-persisted; rest sites/treasure rooms are offered; pre-finished rooms are offered, not refused). ## Validation Built, deployed, hot-reloaded: `Core.Initialize complete`, `436 classes patched, 0 failed/skipped`, `EventRoom.OnEventStateChanged` in the patched-methods list. Tests and live behavioral verification not run (user-owned).
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
romaine-life/spirelens!334
No description provided.