Read a comment after a setting's value, and off, false and no for a switch, as players mean them in nx2navi.ini.

A hand-edited "pace_smooth = 0 ; off" kept the comment in the value, which the readers took as on, "fps_limit = 144 #
monitor" gave 60, and "fullscreen = false" or "rtss = off" were on, since every reader took anything but "0" as on;
the log only named these lines (the check added for F-7). Now, for a key whose row has a set of values, cfg_load cuts
an unquoted value at the first blank followed by ';' or '#' after the '=' ("key = ; note" is unset) and logs the line
once; free text keeps its whole value (window_size, monitor, audio_device and keys without a row such as mods_dir,
pipeline_cache and the bindings, where a path or name may hold " #"), as do a value in double quotes and the
environment's values. A switch (a row whose set is 0|1) written as false, off or no reads as 0 and as true, on or yes
as 1 through cfg_get itself, so every reader agrees (cfg_bool, rt_knob, the readers that compare with "0" or parse a
number); cfg_bool and rt_knob also take those words for keys of other rows, and rt_knob no longer logs them. F-7's
check now names a switch value only when it is none of those, and a comment kept in a value only where it stays
(free text, the environment). The launcher's reader (launcher/gameini.py) cuts the same way for keys the caller
says have a set of values; its mods keys stay free text. The menu's save still writes a changed key's line again
without its comment.

This changes what existing files with such lines do, which is what was approved. tests/cfg_parse_check.py,
tests/rt_knob_check.py and launcher_test PlayerIniTest cover the cut, the words, free text, quotes and the
environment, and pass; cfg_rows_check reports 0 problems; the runtime compile check and the -Wall comparison of cfg.c
and perf.c show no new warnings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-13 19:14:43 -05:00
parent 1c26907abe
commit b6709da852
9 changed files with 264 additions and 59 deletions

View File

@@ -3,6 +3,8 @@
// cfg.c logged ("log: ...") and what the case reads back ("got: ...").
// load cfg_load on the file; then cfg_init's check of the environment (the variables the script set)
// full cfg_load on the file, then two cfg_set of keys the file does not have
// read cfg_load on the file and cfg_init's check of the environment; then what cfg_get, cfg_bool and cfg_int give
// for a list of keys
// norow cfg_int and cfg_double of a key without a row whose value (the environment's) does not parse
#include <stdarg.h>
#include <stdint.h>
@@ -81,6 +83,24 @@ int main(int argc, char **argv) {
printf("got: vk_present %s\n", cfg_get("NX2NAVI_VK_PRESENT") ? cfg_get("NX2NAVI_VK_PRESENT") : "(unset)");
return 0;
}
if (!strcmp(argv[1], "read")) {
if (!cfg_load(ini)) return printf("cfg_load failed\n"), 2;
printf("--- environment\n");
cfg_init();
static const char *const keys[] = {"PACE_SMOOTH", "FULLSCREEN", "FPS_LIMIT", "VK_PRESENT", "ASPECT", "RTSS",
"HDR_LIVE", "CLOTH_REALTIME", "WINDOW_SIZE", "DLSS_PRESET", "MODS_DIR",
"DYN_RES", "SHADOW_PCF"};
for (size_t i = 0; i < sizeof keys / sizeof *keys; i++) {
char name[64];
snprintf(name, sizeof name, "NX2NAVI_%s", keys[i]);
const char *v = cfg_get(name);
printf("got: %s '%s'", keys[i], v ? v : "(unset)");
const CfgMeta *m = cfg_meta(name);
if (m && m->values && !strcmp(m->values, "0|1")) printf(" bool %d int %d", cfg_bool(name), cfg_int(name));
printf("\n");
}
return 0;
}
if (!strcmp(argv[1], "norow")) {
if (!cfg_load(ini)) return printf("cfg_load failed\n"), 2;
printf("got: cfg_int %d cfg_double %g\n", cfg_int("NX2NAVI_NO_ROW_CHECK"), cfg_double("NX2NAVI_NO_ROW_CHECK"));