Read low_end_gpu's and shader_carry's off words the same in the low-end mode and in make_game.py as in the game's other readers.

The review of the commit that taught nx2navi.ini's readers off, false and no found three readers it left behind. cfg.c
lowend_of reads low_end_gpu through raw_get, which skips switch_word, and still took anything but "0" as on: with
"low_end_gpu = off" cfg_get, cfg_bool and the menu said off while cfg_low_end_active() was 1, so the mode's defaults
and its LOWEND_ONLY keys stayed in effect, and F-7's check, which now accepts the word, logged nothing. lowend_of now
takes the value through switch_of as cfg_bool does: 0 and the off words are off, anything else set is on (an
environment value "0 ; x" stays on, as cfg_bool reads it). tools/make_game.py read the file on its own too:
shader_carry took only "0" as off and kept a comment in the value, so with "shader_carry = off" or "shader_carry = 0 ;
note" an update skipped the full shader preparation and left the shaders to a game that no longer carries them over;
guest_opt_ini took low_end_gpu as on for anything but "" and "0". shader_carry now reads the switch as the game does
(the environment wins over the file and is taken as written, the file's last line with a value wins, a comment after
a blank is cut unless the value is in double quotes, make_game.py ini_choice, and 0, off, false and no in any case are
off); guest_opt_ini keeps its cut and takes the same words as off.

tests/cfg_parse_check gains a lowend case (low_end_gpu = Off, = 0 ; note and = yes from the file, FALSE and "0 ; x"
from the environment; two of them fail on the old lowend_of), and launcher_test's MakeGameTest two tests of
shader_carry's and guest_opt_ini's reading, which fail on the old make_game.py. cfg_rows_check reports 0 problems, and
the -Wall compile of cfg.c shows no warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-13 19:35:01 -05:00
parent b6709da852
commit 8c9011d56f
5 changed files with 103 additions and 15 deletions

View File

@@ -1627,10 +1627,15 @@ def pgo_gen_record(out, clang, env):
(raw / PGO_TRAINING).write_text(json.dumps(record, indent=1) + '\n', encoding='utf-8')
# The values a switch (a row of runtime/cfg.c metas[] whose set is 0|1) reads as off, in any case (cfg.c switch_of).
SWITCH_OFF = ('0', 'off', 'false', 'no')
def guest_opt_ini(out):
"""NX2NAVI_GUEST_OPT from nx2navi.ini next to the exe (the low-end GPU rows of the menu's Game tab write it there)
when the environment does not set it: the next build of the game folder out takes it. Only while low_end_gpu = 1
is in the file too: the mode's settings count only with the mode on (runtime/cfg.c LOWEND_ONLY)."""
when the environment does not set it: the next build of the game folder out takes it. Only while low_end_gpu is on
in the file too (not empty, 0, off, false or no, as runtime/cfg.c lowend_of reads it): the mode's settings count
only with the mode on (runtime/cfg.c LOWEND_ONLY)."""
if os.environ.get('NX2NAVI_GUEST_OPT', '').strip():
return
found, low = '', False
@@ -1642,7 +1647,7 @@ def guest_opt_ini(out):
if eq and key in ('guest_opt', 'nx2navi_guest_opt') and value:
found = value
if eq and key in ('low_end_gpu', 'nx2navi_low_end_gpu'):
low = value not in ('', '0')
low = value.lower() not in ('', *SWITCH_OFF)
except OSError:
pass
if found and low:
@@ -2186,20 +2191,37 @@ def note_cache_translator(out):
os.replace(tmp, ids)
def ini_choice(raw):
"""The value of a setting with a set of values as runtime/cfg.c cfg_load reads it from nx2navi.ini, raw being the
text after '=': unless the whole value is in double quotes, it ends at the first blank followed by ';' or '#'
(cfg.c cut_comment); a value in double quotes then loses them."""
v = raw.strip()
if not (len(v) >= 2 and v[0] == v[-1] == '"'):
m = re.search(r'[ \t][;#]', raw)
if m:
v = raw[:m.start()].strip()
return v[1:-1] if len(v) >= 2 and v[0] == v[-1] == '"' else v
def shader_carry(out):
"""Whether the game carries the shaders prepared before an update over (runtime/gfx_shader.c, NX2NAVI_SHADER_CARRY,
on unless the environment or nx2navi.ini sets it to 0) and there are some: shader-prepared.bin is written by a
finished preparation, and the cache must name the translator its translations are of (SHADER_IDS,
note_cache_translator), else the game has nothing to carry them over by."""
if os.environ.get('NX2NAVI_SHADER_CARRY', '').strip() == '0':
on unless set to 0, off, false or no) and there are some: shader-prepared.bin is written by a finished
preparation, and the cache must name the translator its translations are of (SHADER_IDS, note_cache_translator),
else the game has nothing to carry them over by. The switch is read as the game reads it (runtime/cfg.c): the
environment wins over nx2navi.ini and is taken as written; in the file the last line with a value wins, its
comment cut (ini_choice). Where this read differs from the game's, an update skips a preparation the game will not
carry over, or prepares what it would."""
v = os.environ.get('NX2NAVI_SHADER_CARRY', '').strip()
if not v:
try:
for line in (out / 'nx2navi.ini').read_text(encoding='utf-8-sig', errors='replace').splitlines():
k, eq, raw = line.strip().partition('=')
if eq and k.strip().upper().removeprefix('NX2NAVI_') == 'SHADER_CARRY' and ini_choice(raw):
v = ini_choice(raw)
except OSError:
pass
if v.lower() in SWITCH_OFF:
return False
try:
for line in (out / 'nx2navi.ini').read_text(encoding='utf-8-sig', errors='replace').splitlines():
k, eq, v = line.strip().partition('=')
if eq and k.strip().upper().removeprefix('NX2NAVI_') == 'SHADER_CARRY' and v.strip().strip('"') == '0':
return False
except OSError:
pass
return (out / 'shader-prepared.bin').is_file() and bool(cache_identities(out))