WIP: fix(mods): switching one mod off while the game runs no longer stops every other mod the start turned on #2829
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!2829
Loading…
Reference in a new issue
No description provided.
Delete branch "llun/Longshot:fix/mod-api-live-switch"
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
For #2822 (into
mod-api). Switching one mod off while the game runs, in the Mods tab or by the launcher changingprofile.json, stops every player's mod and development mod that the start turned on, not just the one switched. The log names each asturned off in the Mods tab.The cause: a player's and a development mod's row is made off (
Row::new(…, false)ingame/crates/api/src/loader/mod.rs) and then turned on by the profile's list or by the run. At the start's end the loader bringsstart_enabledup to date with that switch, but notswitch_on, the live switch. Only the system mods' rows set that (put_systems). So every player's and development mod ran withswitch_onfalse. The first switch pass while the game ran (switch_frame) took that as "off" and stopped them all. The Mods tab reads the same field for a live mod (tab.rs,row_of), so it also showed running mods as off. This setsswitch_ontogether withstart_enabledat the start.To see it on
mod-api: a profile listing two script mods as on; start the game; switch one off in the Mods tab, or inprofile.jsonwhile it runs. Both stop.Read first: the end of
Loader::scaningame/crates/api/src/loader/mod.rs.Testing
Tested: Windows 11, RTX 5080, NVIDIA 621.40, the game confined through
longshot-builder gamewith a profile listinglocal/rupee-alarmandlocal/heart-logas on, plus a development mod (LONGSHOT_DEV_MODS,local/first-mod). 40 s in,heart-logwas switched off inprofile.json.mods: local/heart-log switched off (at once), thenlocal/first-mod: turned off in the Mods tab,local/heart-log turned off in the Mods tabandlocal/rupee-alarm turned off in the Mods tab.local/heart-log turned off in the Mods tabalone; rupee-alarm and first-mod ran on.Both runs are on
mod-apiwith #2726's save-folder fix and its broker change applied locally, beneath this PR: on plainmod-apia confined Windows start with a profile stops at the save folder.Checks: the new
loader::tests::a_mod_switched_off_while_the_game_runs_stops_alonelists two script mods as on, runs them, and switches one off. It fails onmod-api@eaf4a48b(a/one runs on,left: Off) and passes here, on Linux (WSL Ubuntu 24.04, Rust 1.99.1:cargo test -p api, all 443 pass) and on Windows (--target x86_64-pc-windows-gnullvmwith llvm-mingw: 442 pass). The one failure on Windows,a_content_mods_changed_module_runs_again_and_its_outputs_are_served, fails the same way onmod-apiand passes on Linux.cargo fmt -p api --checkandcargo clippy -p api --all-targets --no-deps -- -D warnings(Windows target) pass, and so doesmise run lint.The sandbox's guard checks:
a_switch_while_the_game_runs_never_starts_a_mod_that_waits_for_its_permissionsanda_switch_in_a_game_not_confined_never_starts_a_held_scriptpass here (and onmod-api). The fix keeps the permission and confinement gates; these pin them.Still to test:
Measurements
Verdict: fixed. A mod switched off while the game runs stops alone.
Baseline:
mod-api(#2822's head), the branch this PR goes into: the bug is there, not onmain. The in-game runs are both onmod-apiwith #2726's save-folder fix and broker change applied locally, beneath this PR.Setup: Windows 11, RTX 5080, NVIDIA 621.40, the game confined, the same profile and development mod.
heart-logswitched off inprofile.json40 s in. The mods the log says were turned off, and the test.eaf4a48be4c1acb9heart-logis switched offa_mod_switched_off_while_the_game_runs_stops_alonea/one: Off)Risks
The sandbox: a switch's pass still starts nothing the start held back. It starts a switched-on mod only after the confinement's check and through
can_start's grants, and a held row (Waits,Cannot,Held) is never one it starts. Two new checks pin this:a_switch_while_the_game_runs_never_starts_a_mod_that_waits_for_its_permissions, anda_switch_in_a_game_not_confined_never_starts_a_held_script.A live mod's switch now starts as the list says. The switch passes (
switch_frame) and the Mods tab read the same field, so the change also fixes running mods showing as off in the tab. Rows the start turns off keepswitch_onfalse, as before. A revert is enough. Players notice that switching one mod no longer stops the others.Checklist
Ready for review
mod-api(#2822's head); the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). (The checks this change reaches pass:cargo test -p api, as above.mod-api's whole suite has failures on Windows that this PR doesn't change: #2825 and #2826 fix eight of them.)main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here. (It fails onmod-api, where the bug is.)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 the game: Windows 11, RTX 5080, NVIDIA 621.40, confined through
longshot-builder game, a profile listinglocal/rupee-alarmandlocal/heart-logas on plus a development mod (local/first-mod);heart-logswitched off inprofile.json40 s in (onmod-apiwith #2726's save-folder fix and its broker change applied locally, beneath this PR). Before: heart-log, rupee-alarm and first-mod were all "turned off in the Mods tab". After:local/heart-log turned off in the Mods tabalone; rupee-alarm and first-mod ran on.Possibly related, for context:
6d4bccd24bdc4deb403aRebased onto mod-api's new squash
eaf4a48b(the same tree as9e6b9c57, which this branch was on): the diff is this PR's own commits again. The checks and runs above hold as they are (the tree under them is unchanged); the description's commits are the new ones.Pushed two guard checks for the sandbox: a switch while the game runs never starts a mod that waits for its permissions, and in a game the sandbox did not confine never starts a held script. Both pass: the fix keeps can_start's grants and the confinement's check, and these pin them. Risks says so.
2b8e3c2c014f8c8bb6aeRebased onto mod-api's newest (
4cc50ca1: main's newest merged in), with no conflict; this PR's own checks were run again on the rebased head and pass as before. The merge touched none of this PR's files (#2827: only a comment in host/hos_main.c, far from its change), so the measurements and runs above hold; the After commit is the rebased head.4f8c8bb6aeeb4ee5c106Rebased onto
mod-api@816d2354(#2837, headless shots of the mods' UI), noweb4ee5c1. No conflict, and the diff is the same as before (samegit patch-id). #2837 touches none of this PR's files.eb4ee5c1065af7d9a3e15af7d9a3e1e4c1acb9caRebased onto
mod-api@c5e5b676: it was re-squashed onto main @46291934(#2833) twice today (cdbb8551, thenc5e5b676), which made this PR show main's and the whole mod API's diff. Nowe4c1acb9, the same diff as before (samegit patch-id), no conflict. The changes underneath touch none of this PR's files, so its checks still hold.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.