fix(cheats): Switch age reaches the save, so Link loads at the age he was saved at #3107
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3107
Loading…
Reference in a new issue
No description provided.
Delete branch "llun/Longshot:fix/age-switch-save"
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 cheats' Switch age changed Link's age on screen but not in the save. A player saved in Ganon's Castle as an adult and loaded as a child, still wearing the adult's sword and shield.
Cause. The game keeps Link's age twice: in play, and in the save. Switch age wrote only the one in play (
GameData::set_bool), so every save made after it held the old age. In the runs here, a map of one age (HyruleField_Adult) loaded Link at that age whatever the save said, which hides the wrong save.InsideGanonCastleis one map for both ages, so there the save's age decided. It was the same before #2822.Fix.
set_bool_queued), as #3089 does for songs.When the game answers 0. It sometimes drops such a request (6 of 159, says the comment on
dropped).How to see it on main: load a child save, use Switch age, teleport to Ganon's Castle, save from the pause menu, restart and load: Link is a child.
Read first:
toggle_age,age_takenandfollowupingame/crates/game-core/src/travel.rs, then the tests that useAgeGame. #1411 wrote both copies in the old C code.Testing
Tested: Windows 11, RTX 5080, NVIDIA 621.47, headless, from the repository save
castle-gate. No MSVC. The change is the same in every run (git patch-id); only the main under it differs.In the game:
7c3c16f0a45d1863b245d1863b276092c5e576092c5e576092c5e5dev.py smokepasses on45d1863b2.With a private build that never sends Switch age's map change, as if the game dropped it (
76092c5e5, sandbox on):Game-free, on this head (main
299ed5b70):--no-deps) and formatting pass.note_linesis an unused import insandbox_windows.rs:384. Plain main299ed5b70stops there too.Game-free, earlier:
76092c5e5).The whole suite ran on the first version, over main
0aeb68589, and not again since: 835 passed, 4 failed, 51 skipped. All four were run on plain main then and failed there too:test_utf8_paths,test_run_all_junit(it runstest_utf8_paths),test_cursor_hidden_linuxandtest_lifter. Every Rust test with--no-fail-fastthen: 3467 passed, 3 failed, all 3 on plain main too.Still to test:
Measurements
Verdict: the save now holds the age Switch age gave Link, and Ganon's Castle loads him at that age.
Setup: Windows 11, RTX 5080, NVIDIA 621.47, headless, one run each. The age in the file is the saved
Sequence_IsChildhood, read back fromprogress.sav.1a86a938b9fe318ae0(the same change, before its rebase)The Before numbers are of main
1a86a938b, and were not measured again. None of the commits from there to299ed5b70changes how the age is written:toggle_age,flags.rsand the save files (host/nn_fs.c) are the same. Ganon's Castle was run with this PR again on45d1863b2and7c3c16f0a.Risks
sites.tomlhas has it.setAge, recordings) change. A revert is enough.Checklist
Ready for review
main; the title is a Conventional Commit. (on299ed5b70, main when it was rebased)mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.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 5080, NVIDIA 621.47, sandbox on, headless. Switch age to adult, Ganon's Castle, save from the pause menu, restart: a child on main, an adult with this change; the files saved by hand and by autosave say child on main and adult here (Hyrule Field, the Market). With a private build that drops Switch age's map change, Link's old age came back (Hyrule Field, Ganon's Castle), and he became an adult when only the first was dropped (Kakariko). The smoke run passes. Run on this same change before its last rebase (c6941060c and 23f7f811a).
@review
Recommendation: Request changes. The tested switch now reaches the save, but the rollback can leave a save with the wrong age after a dropped request.
The change queues the game’s age setter so saves retain a cheat-driven age switch, and adds recovery for dropped map changes. Its recovery depends on a single delayed snapshot that cannot distinguish every successful transition from a dropped one.
Blocking (1): must change before merging.
game/crates/game-core/src/travel.rs:730: A dropped map request can persist the new age in a save before the follow-up restores the old age. (more on the line) Do: Keep saves consistent while the map change is unresolved, for example by preventing saving until the transition succeeds or rollback completes, or by arranging the age commit so a dropped request cannot be saved. Cover a save during the dropped-request window.Testing before merging (1) (the change behaves the same on every system: one run of the change itself is enough; it doesn't hold the recommendation)
@fixcan do L1.Questions (1) (not confirmed from the code; they don't hold the recommendation)
game/crates/game-core/src/travel.rs:791: Can a zero-answer same-map reload complete before the follow-up runs?Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes. The reported Windows run loaded an adult in Ganon’s Castle after the switch, where main loaded a child; hand saves and autosaves also held the new age. The runs were on earlier bases, and the reverse direction and Linux remain untested in game.
Other systems: The same travel path serves the cheats menu, control bridge, mods and recordings. The changed state is owned by Link’s update thread; no new cross-thread state or platform-specific file handling is introduced. The age change is game logic rather than GPU-specific code.
Switches: None added, changed or removed.
Reviewed:
d44640a79bagainst76092c5e5a: Read AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md, the pull request template, the complete diff and changed travel code, the queued flag setter, its caller and the travel queue. Skimmed the remaining inventory and travel tests and other callers. docs/review-checklist.md and ../Tooling/AGENTS.md were not present; no generated files or recorded runs changed.; nothing run (a code review).Checked and fine:
Testing: No commands that build, run tests or execute project code were run during review. CI was still running in the supplied status.
Overlaps and merge order: None identified in the supplied review context; the network was unavailable.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
@ -697,0 +727,4 @@let sent = self.teleport_as(g, actor, target, Some(!child)).inspect_err(|_| {log::info("cheats: age toggle not made, the map change was not requested");})?;if m.set_bool_queued(g, layout::SEQ_IS_CHILDHOOD, !child).is_err() {L1 (blocking): A dropped map request can persist the new age in a save before the follow-up restores the old age.
When: After a child-to-adult switch whose map request is dropped, the queued setter updates the save’s age while Link remains on the child map. A manual save or autosave before the 1.5-second check, or before the second check after a retry, writes adult to disk; putting the age back later does not repair that already-written save.
Do: Keep saves consistent while the map change is unresolved, for example by preventing saving until the transition succeeds or rollback completes, or by arranging the age commit so a dropped request cannot be saved. Cover a save during the dropped-request window.
Measurements now says why the numbers of main
1a86a938bstill hold on76092c5e5. Seven commits lie between them, and none changes travel, flags, the cheats, the hook sites, the save files, the control bridge or Skip title. #3093's file helper change is already in the Ganon's Castle run with this PR. Nothing was run again.BeanBot's L1 (a save made before a dropped switch is put back keeps the new age) is right: the description's Risks already names it, and it was not tested. A fix follows.
BeanBot's points, on the new head
9fe318ae0:an_age_switch_the_game_drops_never_changes_the_agechecks the age at that moment, and fails with the first version's way.One more hole closed on the way: the wait ends after 8 seconds, so pausing and loading another save can't change that save's age.
The whole suite was not run again after this change. game-core's and the cheats' 451 tests pass. The branch is on
76092c5e5because newest main (ca5d30781) does not build on Windows: #3113 callsnote_lineswhere it is not in scope (sandbox_windows.rs:1654).d44640a79b9fe318ae03@review
Recommendation: Approve. The code is ready: only testing is left. The dropped-request save bug is fixed, and the reported Windows runs show the age survives saving and restarting. The Linux game path still needs the run listed in the pull request. Recommend approval; not approved on the forge.
Switch age now queues the saved age only after the map change is accepted or observed, keeping the old age when a request is dropped. This fixes the reported save mismatch with added follow-up state and timing logic.
Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
Since the last review (on
d44640a79b)Resolved: L1 (A dropped map request can persist the new age in a save before the follow-up restores the…)
Still open: L2 (The Linux game path still needs the run listed in the pull request.)
Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes. The reported Windows Ganon’s Castle run loaded a child on main and an adult with this change; manual and autosave files also held the new age. The reported reverse switch loaded a child.
Other systems: The control bridge, mods and recordings use the same age-switch path. Windows was tested in game; Linux remains untested. The change does not alter rendering or GPU-specific code.
Switches: None added, changed or removed.
Reviewed:
9fe318ae03against76092c5e5a: Read the pull request, comments, ledger, diff, repository rules, pull request template, age-switch and follow-up implementation, related flag setter and caller, and changed tests. The full travel.rs output was truncated, so the rest of that file was skimmed; the developer standards and other referenced documentation were not read in full.; nothing run (a code review).Checked and fine:
Testing: No commands that execute project code or tests were run. The author reports Windows game runs and 451 game-core and cheats tests passing; CI is still running.
Overlaps and merge order: Not checked; network access is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
9fe318ae03d3fcff5709Rebased onto main
6318f4056(headd3fcff570). The change is the same (git patch-idunchanged), and main changed nothing in game-core or the cheats.Nothing was run on the new base on Windows: main does not build there (
note_linesinsandbox_windows.rs:1654, from #3113), not even game-core's tests alone. The Windows tests and game runs are from76092c5e5, the last main that built here. That fix is not in this PR.d3fcff57098243662eb8Rebased onto main
674489ddf(head8243662eb). The change is the same (git patch-idunchanged).in the AppContainerin the log). Main now has it off by default (#3132); Switch age was not run that way.travel.rson main: #3069's change there counts the inventory's reads, away from Switch age. It also changes the cheats' rows and queues some of their actions. Switch age was not run with that.note_lineserror insandbox_windows.rs:1654(#3113) that stopped the Windows builds ofca5d30781and6318f4056. The Windows tests and game runs are from76092c5e5, the last main that built here.8243662eb8e903891406Rebased onto main
309af878f(heade90389140). The change is the same (git patch-idunchanged).system_mod.rs:733).76092c5e5, with the sandbox on. Still to test now lists the new cheats page (#3069) and the sandbox off (#3132).e903891406d6681f0cbeRebased onto main
68fc87175(headd6681f0cb). The change is the same (git patch-idunchanged).video.rs(#3031, fast-forward) since the last rebase.d6681f0cbeb4a97e8e39Rebased onto main
299ed5b70(headb4a97e8e3). The change is the same (git patch-idunchanged).New game runs on Windows, each ending with a save and a restart in Ganon's Castle, and each an adult:
7c3c16f0a.45d1863b2. The smoke run passes there too.On this head: 456 tests of game-core and sysmod-cheats pass. Clippy with warnings as errors stops in build-core on an unused import (
sandbox_windows.rs:384), and stops the same way on plain main.Not run: the game on
299ed5b70(its one commit since7c3c16f0a, #3139, is about the menu's text fields), Linux, and the whole suite since the first version. Main has moved by three commits since the rebase.@review
Recommendation: Approve. The code is ready: only testing is left. The Windows runs show that Switch age now persists through a save and restart, including in both age directions. The requested Linux save-and-restart run remains outstanding, and CI is still running. Recommend approval; not approved on the forge.
Switch age queues the game's saved age after the map change is accepted, keeping dropped requests from changing the saved age. This fixes the reported save behavior at the cost of follow-up state and a bounded wait for uncertain map changes.
Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
Since the last review (on
9fe318ae03)Still open: L2 (The Linux game path still needs the run listed in the pull request.)
Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes: on Windows, the reported Ganon's Castle save reloaded as adult with the change and as child on main; adult-to-child also reloaded correctly. Linux has not yet been tested.
Other systems: The change affects Switch age requests from the cheats page, control bridge, mods and recordings. Windows runs cover sandbox on and off; Linux remains unverified. GPU-specific behavior is not expected from this game-state change.
Switches: None.
Reviewed:
b4a97e8e39against299ed5b704: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the diff and commits, and the changed travel logic and its age tests. Skimmed the remaining travel.rs content and setter and caller references; the combined file output was truncated.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run project code were executed. Reported game-free tests pass on this head; CI is still running.
Overlaps and merge order: none found
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.