feat(saves): save slots as a system mod: Save as New, a save list, 50 slots a quest, a set number of autosaves (#2643) #3205
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3205
Loading…
Reference in a new issue
No description provided.
Delete branch "dyst/Longshot:feat/save-slots-sysmod"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The game has 6 save slots a quest, shared between its autosaves and one manual save. This adds a built-in mod,
system/save-slots:src/switch.rs): the list's screen is closed and the confirm loaded, set up for a save and opened with the game's own screen calls, and the Save's button wait is entered again on it. No button press is faked.Past the game's 6 the two quests take turns over the folders (
slot_12, 14, ...andslot_13, 15, ...), so neither writes the other's. An emulator or Hookshot shows only its own 6 of each.docs/dev/reference/saves.mdhas the table. See #2643.The core gives the mod: a part pane copied into a layout as the game builds it (
game_core::layouts, sitelayout.build; the list's prompt bar has two slots and needs a third), the buttons the game was given (host_sys::input::buttons_given, #2641), a guest thread's TLS slot, the options and the loading mods before the mods start (#2644), andui.paneDirtyas a core site, as two mods use it now.Read first:
game/mods/save-slots/README.md(every site it uses and why), thenslots.rs(which slot a save takes),files.rs(which folder),game/crates/game-core/src/layouts.rs.This replaces #2818, the same branch: that one's history lists the 1,770 commits of
mod-apifrom before its squash, which its first push carried. Its one comment is on #2818.It stands alone. Its prompts are clickable with #3219 (every menu prompt clickable), and on a wider picture its list's bar is drawn unstretched with #3218 (the Widescreen fix).
Testing
Tested: on
main(2026-12-04), Windows 11, RTX 3080 (NVIDIA 621.47), 3440x1440 (21:9), played by hand in a build ofmaina66fa5fc8with657ba2f97: Save as New from the System tab, the save list, saving over an entry and Continue worked. What that run lacked is in43772e403: the list's X prompt was missing, and the confirm reached by Save as New was titled as Save's (the stretched title and prompts at 21:9 are #3218's).43772e403, headless through the control bridge (sandbox off), at 16:9 and at 21:9 (HOS_ASPECT=2.3889), from a copy of that run's saves: the list's bar reads Select / Back / Save as New; X in the list saves into a new slot with "Saving…" up (the log: guides hidden, title set); X on the System tab gives a confirm titled "Save as New" that saves into a new slot (7); B after the list restores the pause menu's bar. Not yet played by hand. (43772e403's "Saving…" title for a save from the list is gone: the list now opens the game's own confirm, below.)c40d3ad21, played by hand (2026-12-04), Windows 11, RTX 3080, 3440x1440, with #3218 merged in: A on a save in the list opened the game's confirm in the list's place five times, and each save from it (three) went over the picked slot (the records after each, in the log). In that build Back on the confirm closed the Save instead of returning to the list (the request's owner was read as a pointer, so an empty owner looked held);c40d3ad21reads it as a number.ae3af28fb(the review's fixes), played by hand (2026-12-04), the same PC, with #3218 merged in: A on a save opened the confirm in place, Back there returned to the list and its wait took input again, and X on the System tab saved into a new slot twice under the Save as New title (slots 3 and 4), each save written. X in the list has not been pressed in a hand run of this design yet. Every slot held (no Save as New) is checked by the code and its tests, not in game: 50 saves by hand.Rebased onto
maina66fa5fc8(2026-12-04), asmod-apiis inmainsince #2822: the branch is one commit. The conflicts were the host's header and what goes beside it:hos_guest_tls_get,hos_guest_tls_setandhos_hid_givenare declared inhost/game_host.h's ffi-gen part, with their docs, andffi.rsis generated from it (ffi-gen --checkpasses); ingame_initthe early options and the loading mods are set where they were, before the mods start.main's menu test and the settings page's table hold every row of a tab, so "Autosaves to keep" is in both (game/mods/menu/test/menu.test.ts's PLACED,docs/user/graphics-and-controls.md), and its label and help are translated in every language ofgame/mods/menu/strings(tests/test_i18n_complete.py).On
main, this PC (Windows 11, llvm-mingw):cargo test --workspace --no-fail-fast: this change's crates pass (sysmod-save-slots18,game-core413,host-sys23,longshot-game214,sites46); four targets fail in crates this does not change (api's ReShade folder watch,build-compile's header-during-compile,build-driver's tools lock, four oflongshot-builder's), not yet run on plainmainhere.dev.py test-changed's Python checks: the 13 that fail fail the same on plainmaina66fa5fc8on this PC;test_i18n_complete.pyfailed here alone, and passes now. The runs below were onmod-apibefore the rebase; the runs onmainare above.Tested (on
mod-api, before the rebase): Windows 11, RTX 3080, a build ofmod-api4c498c8aawith this branch, the clickable prompts branch and the Widescreen fix merged (c9c84b690), headless through the control bridge with the sandbox off (HOS_SANDBOX=0), against plain4c498c8aawhere it says so. Not run with this branch alone.slot_18. Save then opens the list of two manual saves, the new one first; B goes back to the System tab.slot_00toslot_05,slot_12,slot_14,slot_16) are all still there;slot_18is the new one.Saving over an entry, and X in the list into a new save, were run before the rebase (an earlier build) and not again on this one.
cargo test: the mod's 18 pass;game-core350 pass (346 on plainmod-api). The mod's saved row is intests/test_menu_ini_keys.py's FROZEN (save_autosaves). Two amends since then changed comments only.cargo testfails on the same four tests here and on plainmod-apion this PC, and on no other:apia_content_mods_changed_module_runs_again_and_its_outputs_are_served,longshot-gamea_folder_of_mods_tests_each_of_its_folders,a_mods_profile_sits_inside_the_launchers_save_folder,a_separate_mod_moves_the_saves_into_its_profile_and_records_it.cargo fmt --checknames the same four files as plainmod-apidoes. The checks undertests/: 19 fail here and the same 19 on plainmod-apion this PC.Still to test:
ae3af28fb, expecting the confirm titled Save as New and a save into a new slot (by hand)slot_13, 15, ...and the normal game's saves untouched (by hand)Known limits: the list's third prompt is drawn by the pause menu's own "Save as New" showing through, not by the overlay (its slot lookup does not reach the copied pane yet; README, "Not yet"). "Save as New" is English only.
Measurements
Not measured: on hot sites it adds a compare to
ui.paneDirtyand, while a menu is up, a read of the screen's first word tomenu.update; the rest acts at a save, in the save list and at a layout's build.Risks
Saves: the slot choosers (
save.chooseAuto,save.chooseManual), the caption manager's size and the folder numbering (save.fileSlot*) are the game's own below slot 6. Saves past 6 are in new folders that older Longshot builds ignore, so going back to one hides them without losing them; the launcher's free-slot placement assumes 6.layout.buildchanges a layout's shared resource once, for the one layout a mod names. Turn the mod off in the Mods tab for the game's own saves.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). Not run onmainyet.main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
tests/that reads changed source is updated, not weakened (input_background_test.cdefineshos_hid_given).mainand here, for a change that shows on screen.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
Tested in game: Windows 11, RTX 3080, before the rebase onto main: a build of mod-api
4c498c8aawith this branch, headless through the control bridge with the sandbox off. In play at 21:9 and 16:9, System tab: Save as New saved into slot 9 (folder slot_18), Save then opened the list of two manual saves, B went back; the folders there before were all kept; the file select listed the saves and Continue went into play; no crash. Not run on main yet: a run there is next, and Testing will say what it showed.ed9cdacca5657ba2f972WIP: feat(saves): save slots as a system mod: Save as New, a save list, 50 slots a quest, a set number of autosaves (#2643)to feat(saves): save slots as a system mod: Save as New, a save list, 50 slots a quest, a set number of autosaves (#2643)Recommendation: Request changes. Save as New can overwrite an existing save when all slots are occupied, and the new input handoff has a cross-thread data race.
The mod adds manual save slots, a save list, and a configurable autosave count. It expands the save system substantially, but full-slot handling and shared state need correction before players can rely on it.
Blocking (2): must change before merging.
game/mods/save-slots/src/menu.rs:535: When no slot is free, Save as New falls through to the ordinary save instead of refusing the new save. (more on the line) Do: Disable or reject Save as New when there is no free slot, and tell the player why before any existing save can be overwritten.host/nn_hid.c:1471: The input word is written through a volatile C object while Rust reads it as an atomic from other threads; volatile does not make the C write atomic or synchronize it. (more on the line) Do: Declare and access the shared word atomically on both sides, using a compatible C atomic store and Rust atomic load.Should fix (1): not blocking, but worth doing before merging.
game/mods/save-slots/src/menu.rs:552: The list's Select guide is only installed when a new slot is available. (more on the line) Do: Show Select and Back whenever the list opens, adding Save as New only when a free slot exists.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L1, L2 and L3.Questions (2) (not confirmed from the code; they don't hold the recommendation)
game/crates/game-core/src/layouts.rs:331: Were these fixture values made from a game file, or independently written from observations of the layout?Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven on the final head: the earlier main-based build was played by hand, and the final head was exercised through the control bridge, but the final UI changes have not been played by hand. This is not a performance change; no performance comparison was supplied.
Other systems: The folder mapping and caption manager affect both quests, existing saves, Continue and Load, and moving saves between Windows and Linux. Master Quest, Linux, a long rotation, and disabling the mod with extra saves remain untested. The shared layout and input hooks also run on worker threads.
Switches: Adds the restart-required save_autosaves setting, default 6, range 1–40; 6 preserves the stated autosave count. The built-in save-slots mod is enabled by default and changes slot handling for both quests.
Reviewed:
43772e4039againsta66fa5fc8a: Read the repository rules and PR template, commit messages, save-slots README, slots.rs, files.rs, config.rs, newsave.rs, menu.rs, choose.rs production logic, game-core layouts.rs, mod registration and hooks, and the relevant input and host diffs. Skimmed the remaining diff, tests, documentation, site declarations, and generated bindings; did not read every changed file in full. docs/review-checklist.md was absent.; nothing run (a code review).Checked and fine:
Testing: No code, scripts, builds, or tests were run during this review. The supplied CI checks were still running.
Overlaps and merge order: The PR describes #2818 as the replaced branch and identifies #3218 and #3219 as related UI changes; their diffs were not available for an overlap review.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, as dyst took it out of WIP. Nothing was run; a maintainer decides.
@ -0,0 +532,4 @@let titled = screen != 0 && buf != 0 && set_title(g, screen, buf + 128);log::say(format!("save as new: the confirm saves into slot {new_slot} (titled: {titled})"));} else {log::say("save as new: every slot is held: the game's own Save".to_owned());L1 (blocking): When no slot is free, Save as New falls through to the ordinary save instead of refusing the new save.
When: With all 50 slots occupied, X on the System tab still opens a confirmation; confirming uses the normal manual chooser and overwrites an existing manual save, despite the player asking for a new slot.
Do: Disable or reject Save as New when there is no free slot, and tell the player why before any existing save can be overwritten.
@ -0,0 +549,4 @@B_BEFORE.store(pad(l::PAD_B), Ordering::Relaxed);X_BEFORE.store(pad(l::PAD_X), Ordering::Relaxed);set(State::Begun);if new_slot >= 0 {L3 (should fix): The list's Select guide is only installed when a new slot is available.
When: With all 50 slots occupied and at least two manual saves, Pause > Save opens the overwrite list but retains the overlay's Back-only guide, even though A selects a save.
Do: Show Select and Back whenever the list opens, adding Save as New only when a free slot exists.
@ -1465,6 +1468,7 @@ static void npad_states(Ctx *c) {}if (connected) oc_track(word); /* (the note buttons of the try, for the songs: game-core's ocarina) */game_menu_input(word);if (connected) hos_hid_given = word;L2 (blocking): The input word is written through a volatile C object while Rust reads it as an atomic from other threads; volatile does not make the C write atomic or synchronize it.
When: A HID read can write hos_hid_given while a menu worker calls buttons_given. Those conflicting accesses form a data race, so button detection has undefined behavior.
Do: Declare and access the shared word atomically on both sides, using a compatible C atomic store and Rust atomic load.
feat(saves): save slots as a system mod: Save as New, a save list, 50 slots a quest, a set number of autosaves (#2643)to WIP: feat(saves): save slots as a system mod: Save as New, a save list, 50 slots a quest, a set number of autosaves (#2643)Back to work in progress: the "Saving…" shown after a save from the list (
43772e403) isn't right in play. It is to be redone to look like the game's own save.WIP: feat(saves): save slots as a system mod: Save as New, a save list, 50 slots a quest, a set number of autosaves (#2643)to feat(saves): save slots as a system mod: Save as New, a save list, 50 slots a quest, a set number of autosaves (#2643)Recommendation: Request changes. Save as New can overwrite an existing save when all slots are occupied, and the input word is accessed concurrently without an atomic C write. The full-list Select guide is also still missing.
The change adds manual save slots, a save list and configurable autosave retention. The latest commit uses the game's own confirmation screen for saves from the list, but the earlier full-slot and input synchronization defects remain.
Blocking (2): must change before merging.
game/mods/save-slots/src/menu.rs:535: When no slot is free, Save as New falls through to the ordinary save instead of refusing the new save. When: With all 50 slots occupied, X on the System tab still opens a confirmation; confirming uses the normal manual chooser and overwrites an existing manual save, despite the player asking for a new slot. Do: Disable or reject Save as New when there is no free slot, and tell the player why before any existing save can be overwritten.host/nn_hid.c:1471: The input word is written through a volatile C object while Rust reads it as an atomic from other threads; volatile does not make the C write atomic or synchronize it. When: A HID read can write hos_hid_given while a menu worker calls buttons_given. Those conflicting accesses form a data race, so button detection has undefined behavior. Do: Declare and access the shared word atomically on both sides, using a compatible C atomic store and Rust atomic load.Should fix (1): not blocking, but worth doing before merging.
game/mods/save-slots/src/menu.rs:552: The list's Select guide is only installed when a new slot is available. When: With all 50 slots occupied and at least two manual saves, Pause > Save opens the overwrite list but retains the overlay's Back-only guide, even though A selects a save. Do: Show Select and Back whenever the list opens, adding Save as New only when a free slot exists.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L1, L2 and L3.Since the last review (on
43772e4039)Still open: L1 (When no slot is free, Save as New falls through to the ordinary save instead of refusing t…); L2 (The input word is written through a volatile C object while Rust reads it as an atomic fro…); L3 (The list's Select guide is only installed when a new slot is available.); L4 (The final head still needs the save lifecycle exercised in game, including the paths that…); L5 (The new save and host paths have not been tested on Linux.)
Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven: reported Windows runs exercised several save paths, but Back to the list and X from the list have not been run with the current fix.
Other systems: Linux and moving saves between Windows and Linux remain untested. Master Quest, autosave rotation, large save lists and disabling the mod with extra saves also need the reported lifecycle run.
Switches: Autosaves to keep is added, default 6, range 1–40, applied after restart. The system mod can be disabled; its extra save folders remain on disk.
Reviewed:
c40d3ad211againsta66fa5fc8a: Read the changed menu and switch diff, the relevant save-list and Save as New paths, and the input writer and reader. Skimmed repository rules and the PR template. The full base diff and all changed files were not read in full.; nothing run (a code review).Checked and fine:
Testing: No commands from the project or tests were run. The PR reports Windows testing; CI is still running.
Overlaps and merge order: The PR identifies #2818 as the replaced pull request and names #3218 and #3219 as related changes.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, as dyst took it out of WIP. Nothing was run; a maintainer decides.
55459ddf2' into feat/save-slots-sysmodOn BeanBot's review (
c40d3ad21), answered inae3af28fb(the head,6487051ad, is it merged with the branch's merge ofmain,55459ddf2):hos_hid_given: fixed.nn_hid.cwrites it with__atomic_store_n(..., __ATOMIC_RELAXED), ashost-sysloads it as anAtomicU64(relaxed: a word of buttons, nothing published with it). The declaration staysvolatile uint64_t, as ffi-gen maps it. (hos_hid_buttonsbeside it, cheats.c's, is written the same old way; it is not this PR's.)Prompts::List { new }inmenu.rs).The questions:
SystemOverlay_00after the mod asks (at its start), underlayouts.rs's lock against other extensions, but not against the game's own readers. The new arrays are complete before the table points at them, the old ones are kept (never freed) with the same first entries, and the count is written last. So a build that reads the count and then the arrays sees a consistent table. One window is left: a build that read an array's address before the swap and the count after it would read one entry past the old array. That needs the same layout built on two threads during that one extension. Not seen in any run; I can't close it without a lock the game's builder takes too.layouts.rs's test values: they described the system overlay's pane tree (13 pairs of a parent's index and a subtree's end).ae3af28fbreplaces them with a made-up tree that tests the same two cases, so the test holds nothing of the game's.Checks on
ae3af28fb, this PC (Windows 11, llvm-mingw):cargo fmt --check,cargo testandcargo clippyforsysmod-save-slots(19 pass),game-core(413) andhost-sys(7); clippy names no line of this PR (build-core's andhost-sys's one warning each aremain's).@rebase
This pull request has merge commits, so I brought it up to date by merging
main(4007f6eae4) into it rather than rebasing (its history stays as it is): the new head is711ee7d00c.Conflicts resolved
Nothing was built or run: read the resolution before merging.
Automated rebase by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
Recommendation: Request changes. Save as New is blocked when all slots are already full, but it still falls through to an ordinary save if the last slot fills before the Save starts. That leaves the original overwrite risk in the remaining path.
The built-in save-slots mod adds manual save selection, Save as New, up to 50 slots per quest, and configurable autosave retention. The fix improves full-slot handling and makes the input word atomic, but the save lifecycle still needs coverage on the remaining paths and Linux.
Blocking (1): must change before merging.
game/mods/save-slots/src/menu.rs:535: A Save as New request still falls through to an ordinary Save when no free slot remains at Save start. When: If the last free slot is taken between the System tab's X check and begin(), begin() proceeds to the ordinary list or confirm, which can overwrite an existing save. Do: Cancel or refuse the requested Save as New when begin() finds no free slot, rather than entering the ordinary Save path.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L1.Since the last review (on
c40d3ad211)Resolved: L2 (The input word is written through a volatile C object while Rust reads it as an atomic fro…); L3 (The list's Select guide is only installed when a new slot is available.)
Still open: L1 (A Save as New request still falls through to an ordinary Save when no free slot remains at…); L4 (The remaining save lifecycle paths need an in-game run.); L5 (The new save and host paths have not been tested on Linux.)
Checks: Still running: 11 checks.
Also noticed (1; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Unproven: the reported Windows hand runs demonstrate manual overwrite, Back to list, and Save as New from the System tab; X from the list and several save lifecycle cases remain untested. This is not a performance change.
Other systems: The change affects save files, both quests, the save UI, input and host code on Windows and Linux. Master Quest, long rotations, disabling the mod with extended saves, and Linux save portability remain untested in game.
Switches: Adds Autosaves to keep (save_autosaves), 1–40, default 6, applied after restart; the default preserves the game's existing count. The built-in save-slots mod can also be disabled for the next run.
Reviewed:
711ee7d00cagainst4007f6eae4: Read AGENTS.md, CONTRIBUTING.md, save-slots README, newsave.rs, slots.rs, menu.rs and host-sys input.rs; inspected the changed-line diff, relevant input declarations and stores, commit log and diff summary. The remaining changed files, full base diff, translations and reported runs were not read in full.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run the project were executed. The author reports Windows hand runs and crate tests; CI is still running.
Overlaps and merge order: The description says this replaces #2818; #3218 and #3219 are optional related changes.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its rebase. Nothing was run; a maintainer decides.
On BeanBot's review 3513 (
711ee7d00):No new commit: the head stays
711ee7d00(BeanBot's merge ofmain).@rebase
This pull request has merge commits, so I brought it up to date by merging
main(302cdf0352) into it rather than rebasing (its history stays as it is): the new head isf809fcd6f9.Conflicts resolved
Nothing was built or run: read the resolution before merging.
Automated rebase by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
Recommendation: Request changes. Save as New still becomes an ordinary Save if the last free slot disappears before Save starts. The remaining save lifecycle and Linux runs are also outstanding.
The system mod adds a save list, Save as New, up to 50 slots per quest, and configurable autosave retention. It expands save management but adds complexity to save selection and folder handling.
Blocking (1): must change before merging.
game/mods/save-slots/src/menu.rs:535: A Save as New request still falls through to an ordinary Save when no free slot remains at Save start. When: If the last free slot is taken between the System tab's X check and begin(), begin() proceeds to the ordinary list or confirm, which can overwrite an existing save. Do: Cancel or refuse the requested Save as New when begin() finds no free slot, rather than entering the ordinary Save path.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L1.Since the last review (on
711ee7d00c)Still open: L1 (A Save as New request still falls through to an ordinary Save when no free slot remains at…); L4 (The remaining save lifecycle paths need an in-game run.); L5 (The new save and host paths have not been tested on Linux.)
Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven: recorded Windows runs demonstrate several save and list paths, but X from the list, Master Quest, extended rotation, disabling the mod with extended saves, and Linux remain untested in game.
Other systems: The change affects both quests, existing and extended save folders, the host input and thread interfaces, and layout resources. Windows has recorded play results; Linux and cross-platform save movement remain untested.
Switches: Autosaves to keep is added as a Gameplay setting, default 6, range 1–40, taking effect after restart. The recorded runs do not yet establish its behavior through a long rotation.
Reviewed:
f809fcd6f9against302cdf0352: Read the Save start and free-slot checks in menu.rs and newsave.rs and the recorded PR testing and comments. The rest of the changed code, repository rules, and translations were not read in full in this re-check.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run the project were executed. The PR reports Windows hand testing; CI is still running.
Overlaps and merge order: #3218 and #3219 are described as related improvements; the PR states it stands alone.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its rebase. Nothing was run; a maintainer decides.