fix(host): on/off switches read true, yes and on as on, by the one rule #980
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
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
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!980
Loading…
Reference in a new issue
No description provided.
Delete branch "zeldaootr/Longshot:host-env-on-switches"
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?
Type: fix · Risk: medium · Tested on: Linux, Steam Deck (RADV VANGOGH) · Needs: Windows, any GPU
Why
HOS_FULLSCREEN=truedid nothing, andHOS_AUDIO=truemuted the game. The switch reference says an on/off switch is on for any value but0,false,offorno, yet 30 switches inhost/were still read withatoi, which takestrue,yesandonfor 0. They follow the one rule now. No issue in the tracker reports it; #62 lists the switches and does not change how they are read.How to reproduce
Seen on: Linux and a Steam Deck (any OS: the reads are the same code)
Settings and switches:
HOS_AUDIO=true, orHOS_FULLSCREEN=truewith a windowSteps: start the game with the switch set to the word
Expected: sound as without the switch (it is on by default); fullscreen
Actual: on main,
HOS_AUDIO=trueopens no sound device (atoi("true")is 0, read as "off"), andHOS_FULLSCREEN=truestarts in a windowWhat changed
Every on/off switch of
host/is read by the rule the switch reference states, and a check keeps it so.gpu/vk/compat/longshot_env.h:env_on_or(name, def)(new): unset, the default; set, asenv_onreads it (set and empty is off).host/: 30 switches readenv_on,env_on_ororenv_value_offinstead ofatoi(the table below):hos_thread.c,hos_main.c,display.c,posix/display_sdl.c,nn_vi.c,nn_audio.c,nn_hid.c,nn_applet.c,nn_video.c,nvn_native.c,discord_rpc.c,oot_heap_retry.c,oot_voice.c,hos_wide_ui.c,mouse_native.c,texts.c.gpu/vk/vk_menu.cpp: its copy of theHOS_HANDHELDrule (a new install's Output resolution) reads the value ashost/nn_applet.cdoes, so the two still agree.gpu/vk/vk_replay.cpp:RX_VK_PRESENT_AFTER_SIGNALreadsenv_on_or(name, gate_on()), the same answer as before in one call.tests/test_env_on.pyfails on main over this line (#622 settles it in the check instead: whichever lands second rebases).tests/test_env_on.py: checksenv_on_or; letsvk_menu.cppask whetherHOS_FULLSCREENis set at all, by name; and names any switch ofhost/read withatoi, asatoi(getenv(name))or asatoi(e)within a few lines ofe = getenv(name), that is not in its list of numbers. (It caughtHOS_VOICE_OPTION_FOLLOW,HOS_TEXTSand a second read ofHOS_AUDIO, which main gained while this was open.)tests/test_hud_layout.pyandtests/test_mods_size_table.pycompile copies of changed files and bring the rule's header, as does main's newtests/test_frame_rate_cap_30.py, whose fakegetenvthe rule now reads through (it counts one read ofHOS_MOVIE_PACE, where the old line read it twice when set).-include, astest_frame_rate_cap_stepdoes):test_movie_frame_count,test_oot_heap_retry,test_output_resolution,test_screensaver,test_vcore_escape,test_motion_background,test_wide_ui,test_oot_voice_option;test_threaded_renderingpins the new line.docs/development.md: the switch reference says how a switch that is on by default reads.Left as they are: switches that take a number (
HOS_CORES,HOS_COND_RECORD,HOS_FPS_TARGET, ...), andgpu/vk's on/off switches still read withatoi(RX_VK_FRAME_GATE,RX_VK_FRAMEGEN, ...): a follow-up.Measurements
Verdict: nothing to measure: each switch is read once into a static, no default changes, and no per-frame path reads differently. It passes: the words were seen to take effect in the game on a Steam Deck (Testing).
Flags and settings
30 switches change how they read a word (26 from when this opened, and four that main has added since:
HOS_NFP_TRACE,HOS_NFP_SEARCH,HOS_SWITCH2,HOS_SWITCH2_RUMBLE_TEST); none is added, renamed or given another default. For each:0,false,off,no, unset and every number but 0 (negative ones too) read as before. A valueatoitook for 0 that is not one of those words (true,yes,on,00,0x1) now means on.HOS_FULLSCREEN,HOS_PRESENT_POLL,HOS_GAME_INTERVAL,HOS_INPUT_FRAME_CLOCK,HOS_NO_RENDERER_WAIT,HOS_NVN_HOLD,HOS_POWER_THROTTLING,HOS_RESERVE_CORE,HOS_VIDEO_RGBA,HOS_NFP_TRACE,HOS_NFP_SEARCH,HOS_SWITCH2_RUMBLE_TESTtrue,yes,on: offtrue,yes,on: onHOS_AUDIO,HOS_VCORES,HOS_CACHE_CORES,HOS_DISCORD,HOS_FPS_MOVIE,HOS_FPS_STEP,HOS_MOVIE_PACE,HOS_KEEP_DISPLAY,HOS_GPU_ALLOC_RETRY,HOS_VOICE_OPTION_FOLLOW,HOS_TEXTS,HOS_SWITCH2,HOS_WIDE_UI(still on when set and empty)true,yes,on: offtrue,yes,on: on (the default)HOS_AUDIO=trueno longer mutes the gameHOS_AUDIO=off,HOS_DISCORD=nooff, andHOS_VCORES=yes,HOS_FPS_STEP=on,HOS_WIDE_UI=true,HOS_CACHE_CORES=on,HOS_KEEP_DISPLAY=trueon; the rest untested in the gameHOS_HANDHELD,HOS_GUEST_MEMFD,HOS_PRESENT_NOWAIT,HOS_INPUT_BACKGROUND,HOS_MOUSE_NATIVEtrue,yes,on: offtrue,yes,on: onHOS_INPUT_BACKGROUND=yesran; the rest untested in the gameRX_VK_PRESENT_AFTER_SIGNALDocumented in
docs/development.md, "Switches for testing and debugging" (the rule's paragraph).Testing
Tested:
a8a30c22(v3.0.0-rc.4-120-gd01328f1: this PR with the retire-later holder and the options reader), built for x86-64-v3, not this branch alone; this branch has been rebased ontobbe421f5since (2026-11-16); the lines forHOS_VOICE_OPTION_FOLLOW,HOS_TEXTSand main's newHOS_AUDIOread (#1001'soutput_route_update, and the report it added where the device is not opened) came after that run. A run withHOS_AUDIO=off HOS_DISCORD=no HOS_VCORES=yes HOS_FPS_STEP=on HOS_KEEP_DISPLAY=true HOS_WIDE_UI=true HOS_INPUT_BACKGROUND=yes HOS_CACHE_CORES=on, beside runs with none of them: to the Field and through its sample at the same pace as the others (about 20 frames a second, shaders compiling as it went: not a measurement). With the switches the log has noaudio: output on the default deviceline and nodiscord:line (both there without them), and still has thevcores:lines,vi: real-time step onand thewide ui:line.python3 -I -B tests/run_all.pyon maine4d035e9and on this branch rebased onto it, the same day and PC (6 at once, the PC busy with other builds): main 609 passed, 28 failed, 26 skipped; this branch 609 / 28 / 26. By name every failure here is one of main's buttests/test_pipeline_cache_file.py, a timed check that passes alone on both, andtests/test_hud_layout.py, which compiles a copy ofhos_wide_ui.cand wanted the rule's header: it has it now and passes.tests/test_mods_size_table.pyfails here as on main (prompts.c'shos_options_fileis not linked in its fixture).test_oot_state_tapandtest_pipeline_state_sourcesfailed on main's run only (timing). The branch was then rebased onto mainbbe421f5(two files of main's, neither touched here) and then ontof7922126(one conflict, innn_vi.cbeside main's 30 fps cap), and pushed; the full run was not repeated for those steps, but the checks of every file the branch changes were (run_all.py --changed: 275 passed, 10 failed, 3 skipped; nine of the ten fail on main, and the tenth,test_frame_rate_cap_30, wanted the header and passes now).host/*.c,-fsyntax-only -Werror=implicit-function-declaration, gcc and clang for Linux and llvm-mingw 20261104 for Windows, with a stand-in for the generateda64_suyu.h: no error from this PR's lines.scripts/, the tests,run-vk.ps1): only0,1or empty, which read as before.HOS_HANDHELDcopy, four switches read asatoi(e)and the check's narrower exception forHOS_FULLSCREENcome from it.Not tested: Windows, in the game.
HOS_FULLSCREEN=trueitself (the Deck runs were headless). Checks that only run on Windows and pastehost/display.cor the other files: one of them may want the rule's header as the eight above did.Must be tested:
python -I -B tests/run_all.py, expecting the same results as on main; and a start withHOS_FULLSCREEN=true, expecting fullscreen, and withHOS_AUDIO=off, expecting no sound (Test Farm: @Beanstalk windows, the game-free checks and a start with HOS_FULLSCREEN=true; or by hand)Risks
What could break: a script that set one of these switches to a word
atoiread as 0 gets the other answer:HOS_VCORES=yeskept the virtual cores off and now leaves them on. Nothing in the repository sets them so. It touchestests/test_env_on.py, which #622 also edits, and lines beside the options-reader PR of this set innn_applet.c,nn_vi.canddiscord_rpc.c: whichever lands second rebases.Turning it off: revert the commit.
Compatibility: Nothing changes for a player who sets none of these switches. One who set a word (
true,yes,on) gets what the word says.Checklist
Everyone
type(scope): description) of the status line's type.can't be run by hand is in Testing's Not testable by hand, with why.
in Risks.
main(f7922126, 2026-11-16; head88de20a8).python -I -B tests/run_all.pypasses (any failure that also fails onmainis named).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.tests/that reads changed source updated in this PR, not weakened.host/read the one rule, withenv_on_orfor the ones on by defaultTested in game: Steam Deck OLED, SteamOS 3.9.5 (20261023.100), AMD Custom GPU 0932 (RADV VANGOGH), Mesa 26.2.0-devel. A build of this branch merged with the two other branches of its set on main
a8a30c22(v3.0.0-rc.4-120-gd01328f1), headless at 1280x720, from empty shader caches: the child save in Kokiri Forest, a teleport to Hyrule Field and 45 s there, four runs, each to its end with no device loss. One run with HOS_AUDIO=off HOS_DISCORD=no HOS_VCORES=yes HOS_FPS_STEP=on HOS_KEEP_DISPLAY=true HOS_WIDE_UI=true HOS_INPUT_BACKGROUND=yes HOS_CACHE_CORES=on: no 'audio: output on the default device' and no 'discord:' line in its log (both are there without the switches), and the vcores, real-time step and wide ui lines still there. HOS_FULLSCREEN=true was not run (headless), and HOS_VOICE_OPTION_FOLLOW's line was added after the run.WIP: fix(host): on/off switches read true, yes and on as on, by the one ruleto fix(host): on/off switches read true, yes and on as on, by the one rulePossibly related, for context:
676cbac476262e05be27Rebased onto main
bbe421f5; the description names what changed with it.Rebased onto main
f7922126(a conflict innn_vi.c); the description names what changed with it.262e05be2788de20a880Code-only review of
88de20a880; informational findings, with final approval left to another reviewer.No confirmed new correctness defect found in the switch conversions. The unset defaults and menu/system fallbacks remain intact, including the paired handheld and native-mouse reads. The existing empty-value exception for
HOS_WIDE_UIis preserved. The fixture adjustment from twogetenvreads to one follows the actual helper change rather than relaxing its behavior assertion.The remaining validation is the Windows run already named in Testing: compare the game-free checks against main, verify
HOS_FULLSCREEN=truestarts fullscreen, andHOS_AUDIO=offdisables output. The documented Deck run is useful evidence, but it was headless, combined three branches, and predates the later voice/text/audio-route conversions; it cannot establish those Windows results. The helper tests exercise defaults and word parsing, while the source scan checks call-site spelling rather than every switch's runtime effect.Merge coordination: the options-reader PR is complementary; preserve both its option-reader substitutions and these environment overrides when resolving adjacent hunks. The environment-test PR also edits the guard; preserve its coverage when integrating.
Read the full diff, affected callers/helper, extraction-fixture changes, existing reports and relevant overlapping diffs. No tests, builds or game runs performed for this review.
Brought up to the ready-for-review standard (#1454): the checklist's Everyone list has two new boxes, added here from what this PR's description and comments show (please check they match what you know).
88de20a88005e3134245Rebased onto main
430eef4f2(it conflicted). Main moved theHOS_FULLSCREENread tohost/fullscreen_monitor.cand gaveHOS_WIDE_UIa menu-row fallback: both keep main's code and read the switch by the rule there. The check named four on/off switches main added since (HOS_NFP_TRACE,HOS_NFP_SEARCH,HOS_SWITCH2,HOS_SWITCH2_RUMBLE_TEST): they read by the rule now, and the description's count and table include them;HOS_PROFILE_EVERYandHOS_SHADOW_BUCKETare numbers and joined the check's list.tests/run_all.pyon Linux at this head and on main430eef4f2in the same environment: no check fails here that passes on main. Not rerun in the game since the rebase.The description now counts 30 switches and its table names the four main added (the previous comment said so before the edit had applied).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.