fix(endgame): "Continue in Singleplayer" resumes the run instead of starting a new one - #503
Open
ChronoFinale wants to merge 1 commit into
Open
Conversation
Continuing in singleplayer from the end-of-match screen silently started a brand-new run instead of resuming the match. save_run() only synchronously populates G.ARGS.save_run; the actual save.jkr write is dispatched to the async SAVE_MANAGER worker thread. The handler read save.jkr back off disk immediately after calling save_run(), racing that write -- and since G.F_NO_SAVING is true for an entire MP match, there was no prior save on disk to fall back on either, so the read reliably came back nil and G:start_run began a fresh run. Capture the in-memory G.ARGS.save_run snapshot (deep-copied before G:delete_run() can mutate the live G.GAME table it still references) and hand it straight to G:start_run, skipping the disk round trip. Extract the "what do we do with the captured snapshot" branch into a pure MP.UTILS.decide_continue_singleplayer so it's unit-testable without disk or event-queue stubbing, and add a nil-snapshot guard that aborts with a logged error instead of silently starting a fresh run.
ChronoFinale
marked this pull request as ready for review
July 23, 2026 23:23
Contributor
Author
|
Follow-up from in-game testing: with the resume fix in, there's a remaining gap on the loss path — when you lose the continued singleplayer run, it just drops you back into the same blind again instead of ending/handling the loss. This ties directly to the open expected-state question in #484 (what "Continue in Singleplayer" should do regardless of win/lose, and where it should resume). Until that behavior is decided, the loss case currently loops the same blind — flagging so the expected-state call in #484 explicitly covers the loss path. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
"Continue in Singleplayer" read the save off disk immediately after an async
save_run()(usuallynil, since the write hadn't landed), so it started a brand-new run instead of resuming. Resume from the actual run state instead.Rebased clean onto current
mqtt. Test:luajit tests/test_continue_singleplayer.lua— green.Closes #484