refactor(host): one reader for longshot_options.ini's lines, not six #979
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
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!979
Loading…
Reference in a new issue
No description provided.
Delete branch "zeldaootr/Longshot:host-options-reader"
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: refactor · Risk: medium · Tested on: Linux, Steam Deck (RADV VANGOGH) · Needs: Windows, any GPU
Why
Nothing a player should notice: this is a code-structure change. Main has one place that says where
longshot_options.iniis (host/options_path.c), but six files of the runtime still each open it and loop over its lines their own way (nn_applet.c,nn_hid.c,nn_audio.c,prompts.c,discord_rpc.c,hos_main.c), andnn_vi.cdeclaredhos_ini_optionby hand. A change to how a line is read had to be made six times. Now one header reads the lines, with its own check. No issue in the tracker covers it.What changed
One header-only reader over
hos_options_file()replaces the six loops; it does not find the file. Each reader sees what it saw before, but for one case named below.host/options_read.h(new):hos_options_each: the onefgetsloop, a visit perkey=valueline, the line buffer the caller's.hos_options_textandhos_options_int: the last line that sets a key, as text or asatoireads it.host/nn_applet.c:ini_textandhos_ini_optionare gone;handheld_profileandoutput_resread through the header.host/nn_vi.cincludes it forframe_rate_capinstead of declaringhos_ini_option.host/nn_audio.c(au_menu_output),host/prompts.c(choose_face),host/hos_main.c(the aspect ratio'sultrawideandoptions_version): one call each.host/nn_hid.c:binds_loadvisits every line throughhos_options_each.host/discord_rpc.c:read_app_idkeeps its own 128-byte line, and its own rule that a later invaliddiscord_app_id=does not erase an earlier valid one.tests/test_options_file.py+tests/options_file_test.c(new): a missing file, an empty path, an absent key, a repeated key,\r\n, an empty value, a line longer than the buffer, a key that is another's prefix. Nine checks that paste or pin the changed code compile the real header now:test_output_resolution,test_frame_rate_cap_step,test_audio_output_menu,test_bound_keys,test_ocarina_note_bindings,test_ocarina_notes,test_walk_key,test_pad_layout,test_aspect_default.What differs:
\rthat no\nfollows, for every reader. The readers that took a number read past it before (audio_output=\r3was 3 and is 0; a file with CR-only line ends gavebinds_loada comma from the next line). The menu writes no such line.hos_main.creads the file twice at startup (once per key) where it read it once.The header is not part of
options_path.c, and does not includeoptions_path.h: the checks that paste a reader bring astatichos_options_fileof their own and link no.c.Not touched, on purpose:
host/hos_crash_dialog.c(it prints the whole file),host/audio_output_devices.c(main's #1001, added while this was open: it reads a device id with a reader and line length of its own), the renderer's own readers ingpu/vk(another module), and the menu, which writes the file.Measurements
Verdict: nothing to measure: the readers run once at startup, off any per-frame path. It passes: every row the six readers take was seen to apply in the game on a Steam Deck.
Flags and settings
None.
Testing
Tested:
a8a30c22(v3.0.0-rc.4-120-gd01328f1: this PR with the retire-later holder and the switch rule), built for x86-64-v3, not this branch alone; this branch has been rebased ontobbe421f5since (2026-11-16); the one conflict was an#includeline innn_audio.cbeside main's #1001. The log, with the fixture's options file (output_res=1280x720, no bindings) and then withkey_x=75,key_y=74,76,options_version=3,frame_rate_cap=1,audio_output=2,button_prompts=2and adiscord_app_idadded:nn_applet.c,output_resoe: output resolution 1280x720nn_vi.c,frame_rate_capvi: frame rate cap 90: pacing, the game's limiter and its time step follow itnn_hid.c,binds_loadhid: 2 controls from longshot_options.iniprompts.c,button_promptsprompts: auto: controller "Steam Deck Controller": steamdeckprompts: xbox icons, 16 buttons on these pad's controlsnn_audio.c,audio_outputaudio: stereo for the game (the default output has 2 channels)audio: 5.1 for the game (the Insert menu's Audio output)discord_rpc.c,discord_app_iddiscord: no Discord client is running; trying again every 15 spython3 -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 611 / 27 / 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;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 pushed; the full run was not repeated for that step.=, commas, digits, spaces,\r,\nand lines past 80 bytes. 1,688 differed, every one by a lone\r(above); none with it out of the alphabet.host/*.c,-fsyntax-only: gcc for Linux and llvm-mingw 20261104 for Windows, with a stand-in for the generateda64_suyu.h. Clean.Not tested: Windows, in the game.
hos_main.c'sultrawideon a screen wider than 16:9 (the run was headless at 16:9, so both answers give the same picture).test_mods_size_table(nohos_options_fileat its link) andtest_walk_key(its own code no longer matchesnn_hid.c) fail on main, so they say nothing aboutprompts.cand the Walk key's part ofbinds_loadhere.Must be tested:
hid: N controls from longshot_options.iniin the log (Test Farm: @Beanstalk windows, a start with saved options; or by hand)Risks
What could break: a saved option ignored at startup (bindings back to defaults, the wrong output size, speakers or prompts) if a reader no longer finds a key. It touches
nn_applet.c,nn_vi.canddiscord_rpc.cnext to the lines the switch-rule PR of this set touches: whichever lands second rebases.Turning it off: revert the commit.
Compatibility: Nothing changes:
longshot_options.iniis read as before, but for a value with a lone\rin it.Checklist
Everyone
type(scope): description) of the status line's type.main(bbe421f5, 2026-11-16; headc1698a93).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/options_read.h: one reader for the lines oflongshot_options.ini15efd7a63dnn_applet.candnn_vi.cread the options throughoptions_read.h564547d17fnn_audio.creadsaudio_outputthroughoptions_read.h3856542f42nn_hid.c'sbinds_loadvisits the options throughoptions_read.h9f8a927c43prompts.creadsbutton_promptsthroughoptions_read.h9247257c2ddiscord_rpc.creadsdiscord_app_idthroughoptions_read.h4fb8e1e119hos_main.creadsultrawideandoptions_versionthroughoptions_read.hTested 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. With the fixture's options file the log has 'oe: output resolution 1280x720', auto prompts and stereo; with key_x, key_y, frame_rate_cap=1, audio_output=2, button_prompts=2 and a discord_app_id added it has 'hid: 2 controls from longshot_options.ini', 'vi: frame rate cap 90', 'prompts: xbox icons' and 'audio: 5.1 for the game (the Insert menu's Audio output)'.WIP: refactor(host): one reader for longshot_options.ini's lines, not sixto refactor(host): one reader for longshot_options.ini's lines, not sixe436d19538c1698a9397Rebased onto main
bbe421f5; the description names what changed with it.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.