fix(mods): a patch mod turned off or on keeps the profile's game folder #3213
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!3213
Loading…
Reference in a new issue
No description provided.
Delete branch "snaildev99/Longshot:mods/switch-folder"
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
Turning a patch mod on or off in the Mods tab should need only a restart: the build puts its ExeFS patches in behind
a switch whether it is on or off, and the game sets them at its start. Through the builder it builds the game again
every time. The game folder's name (
builds/<stamp>, the mods stamp) leaves out the patches of a mod that is off, so amod turned off or on names another folder, and the restart (or the next Play) builds a whole new one: about 4 minutes,
and a folder of about 2 GB for each set of switches.
profiles.mdsays a mod switched that a build takes either waychanges nothing, which is what the game's own check does; the builder's name did not.
With this change:
a mod keeps the folder, and a switch's restart builds nothing. A mod of the emulators' layout whose patches an
accepted converted copy brings is left out of the name whether the copy is on or off, so turning the copy off or on
keeps the folder too.
"mods", the stamp the game checks too) with the modsnow, with the folder's switch table: a mod whose patches the build fixed in (no switch: past the eighth, or sharing
bytes with one that is no switch) turned on or off is built again, in the same folder. Before, that took a folder of
its own. The same goes for a converted copy turned off or on: the build takes the original only while the copy is
off (as on
main), so the original comes in or goes, and that is built again in the folder.game_files::code_mods::Scan), sothe check finds and hashes them once.
How to see it on
main:turning_a_patch_mod_off_or_on_keeps_its_game_folder(build-driver) turns an accepted patchmod off; on
mainthe profile's game folder becomes another one (builds/defaultfor its only mod).turning_a_converted_copy_off_or_on_keeps_its_game_folderturns a converted copy off, both copies accepted; onmainthat names another folder too.
Read first:
game_files::code_mods::mods_stampandScan, thenbuild_driver::play::rebuild_reason.Testing
Tested: Windows 11 Pro, RTX 3090, NVIDIA 610.88, in the game, with this PR's two commits on top of the other open
mod compatibility ports (none of which this depends on), adult Link in Kakariko. The profile's only mods are
four patch-only test mods (IPS32, one instruction each in the HUD's per-frame update), all four built in behind a
switch; update off, the three others on. The first Play built the folder once (
builds/67a4f9165b5fdc6b, now the namefor every on/off state of the four). Then call A turned off and the game restarted through its builder (
longshot-builder mod relaunch, the request the menu's Restart now makes):in the same folder; turned on again, the next restart was
up to date (4.6 ms)with its patches on, and the save loadsand plays. The same restart on
main's builder, with a copy of the same profile:and a new folder (
builds/df2f3ed58c2e961a). On both sides the switch was set inprofile.json, as the Mods tabwrites it, and the restart is the menu's.
After the rebase onto
main@3a0f7d8f7and the review's fixes, here @04de1a894, built with the other portsmerged (929bf025a), the same profile: call A turned off, the restart through the builder was
fast check: up to date (15.8 ms)in the same folder (builds/67a4f9165b5fdc6b) with call A off, and on againup to date (4.1 ms)with iton. The review's case of a converted copy (a second profile with Rupee Counter and
local/rupee-counter-off, theimported copy of an Atmosphere patch set that undoes Rupee Counter's hook, built in fixed, not behind a switch, with
the set's own folder off): the copy turned off was
fast check: the mods that need a build changed (5.0 ms), then abuild into the same folder (
builds/72764e29350b3da6), and the rupee counter came back in the game.Game-free:
turning_a_patch_mod_off_or_on_keeps_its_game_folderandturning_a_converted_copy_off_or_on_keeps_its_game_folderinbuild-driver(below).mise run test, run locally while CI's run waits for approval (Windows 11,tests/run_all.py --strict, 12 checks atonce), here @
04de1a894and onmain@3a0f7d8f7: 843 passed, 16 failed, 52 skipped here; 845 passed, 14 failed, 52skipped on
main. 13 of the 16 also fail onmain: test_dlssg, test_fsr4_tune, test_lifter, test_no_game_title,test_no_map_reload, test_present_acquire_ahead, test_present_geometry_trace, test_present_held_image,
test_present_image_free, test_program_cache_store_record, test_sync_watch_event, test_turf_budget, test_ui_renderer.
The other three hit their timeouts while other work ran on the PC: test_audio_voice_biquad and
test_audio_wave_buffer_release pass here run alone (
--exact); test_dev_update times out the same way onmain@3a0f7d8f7beside the same load. This PR touches none of the sources they read. The checks that readplay.rsandcode_mods.rs(test_game_start, test_recomplauncher_json) pass unchanged.
cargo test -p modtool --lib -- testing_game::tests::the_menu_passes_its_tests, the onemodtoolfailure, againon an idle PC (nothing else in the queue), twice here and twice on
main@f359e2621: it fails all four times, the sameway:
every frame's script under 2.00 ms(the budget it measures, 2.00 to 2.30 ms) withsearchthe one over it, at2.62 and 3.21 ms here and 3.28 and 2.72 ms on
main. It ismain's, and this PR touches nomodtoolcode.Still to test:
main(measurement, the review's L4)Measurements
Verdict: It works: a switched patch mod turned off or on restarts in the same folder with no build (the fast check
in 4.6 ms), where
mainbuilds a whole new folder.Setup:
cargo teston Windows 11 (the before side is the test commit,41cf0028c:main's code @3a0f7d8f7with thenew tests),
then the restart in the game as Testing says (its before side is
main's builder @f577a1aea, the base of the modports;
mods_stampandrebuild_reason, the lines this changes, are the same there and atf359e2621).3a0f7d8f7(modtool's row:f359e2621; the game's row:f577a1aea)04de1a894(modtool's and the game's rows:ddd6fa8dd)turning_a_patch_mod_off_or_on_keeps_its_game_folderturned off: the same game folder(leftNone:builds/default)turning_a_converted_copy_off_or_on_keeps_its_game_folderthe copy turned off: the same game foldercargo test -p build-driver --libcargo test -p game-files --lib,-p mods-stamp --libcargo test -p modtool --libmain)fast check: not built yet, a build of 5 min 22 s (two test suites running) into a new 1.9 GB folderfast check: up to date (4.5 ms), no build, the same folderThe two
build-driverfailures fail onmain's code too and touch nothing here:dev_runtime::tests::prepare_only_says_in_one_line_when_the_caches_stand(this PC's test runner setsLONGSHOT_NO_PREPARE) andtools::tests::the_repository_s_lock_and_the_table_agree(tools.lock's Linux compilerstamp is not the one the test pins).
Risks
state kept a folder (the second switch back was no build).
folder each time too (the original comes into the build or leaves it, which the game's own check needs as well);
before, each state kept a folder.
before this change: one build at the first play after updating.
game_files::code_modsnow finds and hashes the mods once (Scan) for the folder's name, the record's stamp andthe stamp now. The rule is the same (
ordered,stampandcurrent_stampgive what they gave; their tests passunchanged), but a mistake there would show as a build at every play or a folder not rebuilt.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). (run locally, Testing names them; CI's run waits for approval)main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/that reads changed source is updated, not weakened. (tests/test_game_start.pyandtests/test_recomplauncher_json.pyreadplay.rsandcode_mods.rs: they pass unchanged)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 Pro, RTX 3090, NVIDIA 610.88, adult Link in Kakariko: four patch-only test mods built behind switches; call A turned off, then on, each a restart through the builder: fast check up to date (4.5 ms, 4.6 ms), the same game folder, its patches off then on at the start, the save loads and plays. On main's builder the same restart builds a new folder (fast check: not built yet).
Possibly related, for context:
mise run test, run locally while CI's run waits for approval: 847 passed, 12 failed, 52 skipped here @
ddd6fa8dd; all 12 also fail on main @f359e2621run alone, with the same messages (named in Testing). test_game_start and test_recomplauncher_json, which read play.rs and code_mods.rs, pass unchanged. Boxes ticked.WIP: fix(mods): a patch mod turned off or on keeps the profile's game folderto fix(mods): a patch mod turned off or on keeps the profile's game folderRecommendation: Approve. The reported Windows run shows that an ordinary switched patch mod can restart without another build. The fixed-in patch path and Linux behavior still need a run before merge, and CI is still running. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.
Patch mods generally keep the same game folder when toggled, avoiding a new build for patches controlled by a runtime switch. The fast check now reads the mods and switch table again, and fixed-in patches rebuild in the same folder when their state changes.
Should fix (1): not blocking, but worth doing before merging.
builder/crates/game-files/src/code_mods.rs:36: A converted patch mod and its original emulator-layout copy can still change the folder when the converted mod is toggled. (more on the line) Do: Make folder naming account consistently for the suppressed original and converted copy across the toggle, and add a regression test for both accepted copies.Testing before merging (3) (runs on the systems it can change; it doesn't hold the recommendation)
builder/crates/build-driver/src/play.rs:776: The fixed-in patch rebuild path has not been exercised in the game. (more on the line) Do: Run a fixed-in patch mod off and on through the builder, checking that each required rebuild completes and the resulting game has the requested patch state.builder/crates/build-driver/src/play.rs:777: The changed builder path has not been tested on Linux. (more on the line) Do: On Linux, build a profile with a switch-backed patch mod and toggle it off and on through the builder, checking folder reuse and the patch state.builder/crates/build-driver/src/play.rs:777: The added mod scan's startup cost is unmeasured for a substantial mod collection. (more on the line) Do: Compare warm and cold fast-check times on main and this branch with a representative large profile, using repeated runs. (@fixdoes its part first: Reuse the already discovered and hashed mod data for the folder stamp and current record comparison.)@fixcan do L1 and L4.Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes for the tested case: on Windows, the reported restart reused the folder with a 4.5–4.6 ms fast check; the main-branch comparison built a new 1.9 GB folder in 5 min 22 s. Those are single reported runs, and do not establish the startup cost for larger mod collections.
Other systems: The builder path affects Windows and Linux independently of GPU. The reported run covers switched patches on Windows; fixed-in patches and Linux have not been demonstrated in game. Saves, rendering, audio and input are not directly changed.
Switches: None added, changed or removed.
Reviewed:
ddd6fa8dd3againstf359e26213: Read AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md, the pull request template, the diff and commit messages. Read the changed code and the surrounding stamp, build-record, switch-planning and restart paths; skimmed existing tests and the changed reference documentation. docs/review-checklist.md and ../Tooling/AGENTS.md are absent from this checkout.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no commands from the project or tests were run. The author reports the Windows game run and game-free results; CI remains in progress.
Overlaps and merge order: Unknown; the network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, as snaildev99 took it out of WIP. Nothing was run; a maintainer decides.
@ -772,1 +773,4 @@}// (in the folder the mods name, what the build took against what the game would take now: a patch mod turned on// or off names the same folder, and only patches the build fixed in need it again, as the game's start finds)if let Some(built) = &rec.modsL2 (should fix): The fixed-in patch rebuild path has not been exercised in the game.
When: The reported game run uses four switch-backed mods; the new game-free test supplies a synthetic switch table and record. A real mod beyond the switch limit or sharing bytes with a fixed-in patch follows a different build and restart path.
Do: Run a fixed-in patch mod off and on through the builder, checking that each required rebuild completes and the resulting game has the requested patch state.
@ -773,0 +774,4 @@// (in the folder the mods name, what the build took against what the game would take now: a patch mod turned on// or off names the same folder, and only patches the build fixed in need it again, as the game's start finds)if let Some(built) = &rec.mods&& !::mods_stamp::compare(built, &game_files::code_mods::current_stamp(folder, Some(profile), Some(&mod_store())))L3 (should fix): The changed builder path has not been tested on Linux.
When: Linux players use the same folder selection and fast check, but the only reported in-game restart was on Windows.
Do: On Linux, build a profile with a switch-backed patch mod and toggle it off and on through the builder, checking folder reuse and the patch state.
L4 (should fix): The added mod scan's startup cost is unmeasured for a substantial mod collection.
When: Every up-to-date play now computes current_stamp after computing the folder stamp, reading and hashing the profile's mod code again; the reported timing covers four one-instruction patches.
Do: Compare warm and cold fast-check times on main and this branch with a representative large profile, using repeated runs.
@ -29,3 +34,3 @@let mods = ordered(Some(profile), store, &choices);let from: Vec<(String, String)> = mods.iter().map(|m| (m.id.clone(), m.from.clone())).collect();let stamp = profile_mods::stamp(&layout, &found_of(mods, &choices), &from, &[]);let every: Vec<String> = mods.iter().map(|m| m.id.clone()).collect();L1 (should fix): A converted patch mod and its original emulator-layout copy can still change the folder when the converted mod is toggled.
When: When both copies are accepted, ordered() suppresses the original while the converted copy is on, but includes it when the converted copy is off. The new all-switch stamp therefore hashes different mod lists and the next restart selects another folder.
Do: Make folder naming account consistently for the suppressed original and converted copy across the toggle, and add a regression test for both accepted copies.
The menu test (modtool's one failure) again on an idle PC, nothing else in the queue: it fails twice here and twice on main @
f359e2621the same way, search over the per-frame script budget (2.62 and 3.21 ms here, 3.28 and 2.72 ms on main, against 2.00 to 2.30 ms). It is main's; this PR touches no modtool code. Moved into Tested.ddd6fa8dd304de1a894fRebased onto main @
3a0f7d8f7for the base conflict; here @04de1a894. Tested (the game again on this head),mise run test(against main @3a0f7d8f7: the failures main doesn't have are timeouts under load, each passing alone or timing out on main beside the same load) and Measurements are updated. Answers to the review below.L1 (a converted copy and its original change the folder when the copy is toggled): fixed, in the fix commit (
04de1a894). Thefolder's name (
game_files::code_mods::mods_stamp) now leaves a mod of the emulators' layout to an accepted copy thatbrings its patches whether the copy is on or off, so both states name the same folder. The toggle is still built again
there, as a fixed-in patch is: the game takes the original only while the copy is off (
code_mods::ordered, thegame's own
code_statusrule), and the two have different ids, so the build's mods really change and the game's ownstamp check needs the build either way. The fast check finds that from the folder's record. The game's rule and the
build's choice of mods are unchanged; only the name moved. Test, in the test commit (
41cf0028c):turning_a_converted_copy_off_or_on_keeps_its_game_folder(build-driver), both copies accepted: the copy turned offnames the same folder and the check says
Mods(the original comes in), built again, then on again: the same folder,Modsagain (the original left to the copy). It fails on the earlier head (the copy turned off: the same game folder:2fbd9adb882a1aeaagainstdf7807c38f44d64f) and onmain. Docs (builder.md,profiles.md) and Risks sayso.
L2 (the fixed-in rebuild path in the game): run on this head, built with the other ports merged. A profile with
Rupee Counter and
local/rupee-counter-off(the imported copy of an Atmosphere patch set that undoes Rupee Counter'shook, built in fixed): the copy turned off and the game restarted through its builder gave
fast check: the mods that need a build changed (5.0 ms), then a build into the same folder (builds/72764e29350b3da6), and the rupee countercame back in the game. That covers the converted copy (L1) and the fixed-in path at once. Testing says so.
L3 (Linux): not run here; for a Linux run.
L4 (the fast check reads and hashes the mods twice): the code part is fixed, in the fix commit (
04de1a894). The mods are nowfound once per check (
game_files::code_mods::Scan:code_mods::findonce, each mod's code hash and patch hash madeonce), and the folder's name and the stamp now both come from that one scan (
play::checkandensure_builtpass itto
rebuild_reason). Before this, a play found and hashed the mods twice (the name, then the stamp now), and hashedeach accepted mod's code more than once inside each pass. The results don't change: the existing stamp and fast-check
tests pass unchanged. The name and the comparison now also read the same files at the same moment. The timing on a
large profile is still to measure.
Still to test now lists the measurement the review asked for, which the answers above say is still to run.
@review
Recommendation: Approve. The code is ready: only testing is left. The patch toggle avoids the unnecessary rebuild in the recorded Windows run, and the converted-copy case now keeps the same folder. A Linux run and the large-profile fast-check measurement remain outstanding. Recommend approval; not approved on the forge.
Patch mods built behind switches can be toggled without creating and building another game folder. Fixed-in patches and converted copies still rebuild when needed; the shared scan avoids reading and hashing mods twice.
Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
builder/crates/build-driver/src/play.rs:777: The changed builder path has not been tested on Linux. When: Linux players use the same folder selection and fast check, but the only reported in-game restart was on Windows. Do: On Linux, build a profile with a switch-backed patch mod and toggle it off and on through the builder, checking folder reuse and the patch state.builder/crates/build-driver/src/play.rs:777: The fast check's startup cost on a substantial mod collection remains unmeasured. When: A player with a large mod collection runs the fast check; the cost relative to main is unknown. Do: Measure repeated fast checks on the same substantial profile and machine against main. (@fixdoes its part first: Reuse the already discovered and hashed mod data for the folder stamp and current record comparison.)@fixcan do L4.Since the last review (on
ddd6fa8dd3)Resolved: L1 (A converted patch mod and its original emulator-layout copy can still change the folder wh…); L2 (The fixed-in patch rebuild path has not been exercised in the game.)
Still open: L3 (The changed builder path has not been tested on Linux.); L4 (The fast check's startup cost on a substantial mod collection remains unmeasured.)
Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes. In the recorded Windows run, turning a switched patch off reused the folder with a 4.5 ms fast check; the comparison on main built a new 1.9 GB folder in 5 minutes 22 seconds. The large-profile startup cost remains unmeasured.
Other systems: The builder path also runs on Linux, where it has not yet been tested. The changed code does not depend on GPU vendor; fixed-in patches and converted copies can still require a rebuild.
Switches: None added, changed or removed.
Reviewed:
04de1a894fagainst3a0f7d8f7f: Read the repository rules, PR template, standards, changed code and diff, relevant stamp and rebuild paths, description, comments and recorded results. Skimmed the remaining surrounding tests and documentation; no generated files or translations changed.; nothing run (a code review).Checked and fine:
Testing: Recorded Windows game runs and game-free tests cover the main toggle and converted-copy cases. Linux and large-profile timing remain outstanding; CI is still running. No commands from the pull request were run in this review.
Overlaps and merge order: none found
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.