A game with a mod plugin no longer stops at start: plugin_trace has its row in the settings table (#845)

plugin_init.c reads TOTK_PLUGIN_TRACE through cfg_bool, which stops the game when the key is unset and metas[] has no
row. Every test run set the key, so only a plain start hit it. tests/settings_doc_check.py now fails on any
cfg_value/cfg_int/cfg_double/cfg_bool reading without a metas[] row that is not guarded by cfg_get of the same key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Valiantsin DzerakhandClaude Opus 5.5 committed 2026-11-17 12:49:27 +03:00
1 parent 4957dc78e3
commit a5c3e0f9f5
3 files changed
+15 -2

No files matched your search

+1 -1
View File
@@ -25,7 +25,7 @@ Many rows below are developer tools that only act together with another setting
| `barrier_merge` (default `0`) | Experimental. `1` keeps a render pass open through the game's Barrier calls that ask only for fragment ordering and texture invalidation, when no draw of the pass can write a storage buffer or image; the next draw that samples a written target gets a by-region barrier in the pass (the feedback layout). In scenes with about a thousand such barriers a frame this cuts the passes from about 1200 to 130 and the GPU time from 24.5 to 7.8 ms. | The game's barrier orders every pixel, the in-pass by-region barrier only the pixel a draw writes: a driver that runs it per screen tile can show flicker or squares at the edges of water, decals or particles. | Caution |
| `menu_cursor_log` | `1` logs what the menu cursor code reads at every screen change. | Only adds log lines. | Safe |
| `plugin_tick_offset` (default `0`) | Added to every GetSystemTick in the plugin service run (`totk.exe --plugin-init DIR`), so `tools/exefs_plugins.py` can run a plugin's init twice with other ticks and compare the records. | Has no effect outside `--plugin-init`; a plugin's init at the start of the game gets the plain ticks. | Safe |
| `plugin_trace` | `1` logs the first call of each entry of a mod plugin's hooks (its callbacks, replace and call targets) as `plugins: hook entry ... reached`. | Each such call goes through a counting step; nothing changes without a mod plugin. | Safe |
| `plugin_trace` (default `0`) | `1` logs the first call of each entry of a mod plugin's hooks (its callbacks, replace and call targets) as `plugins: hook entry ... reached`. | Each such call goes through a counting step; nothing changes without a mod plugin. | Safe |
| `perf_slow_ms` (default `50`) | Frames at least this many milliseconds long get a `perf: slow frame` log line with the time blocked per cause. | Changes how many frames are logged; a small value fills the log. | Safe |
| `replay_check` | `1` reads every texture read-back a second time after a full drain of the replay queue and compares the two. | Stalls the replay queue at every read-back, so frames get much slower; mismatches are only counted and logged. | Caution |
| `resolve_check` | `1` compares every cached pool lookup with the locked lookup and stops on a difference. | Slows every pool lookup; the game stops if the two ever differ. | Caution |
+2 -1
View File
@@ -115,7 +115,7 @@ static const struct { const char *key, *section; } sections[] = {
{"OPTREF_GUARD", "performance"}, {"ABILITY_GUARD", "performance"}, {"REPORT_GUARD", "performance"},
{"TRACE", "diagnostics"}, {"FLIGHT", "diagnostics"}, {"PASS_CRUMBS", "diagnostics"}, {"ADDR_REPORT", "diagnostics"}, {"FLIGHT_SPIKE_MS", "diagnostics"},
{"WB_FENCE_LIMIT", "diagnostics"}, {"WB_MERGE", "diagnostics"}, {"WB_EXACT", "diagnostics"},
{"MV_SURVEY", "diagnostics"},
{"MV_SURVEY", "diagnostics"}, {"PLUGIN_TRACE", "diagnostics"},
{"GAMEPLAY_TWEAKS_ENABLED", "gameplay tweaks"}, {"GAMEPLAY_ULTRAHAND_ROTATE", "gameplay tweaks"},
{"GAMEPLAY_ULTRAHAND_C_AXIS", "gameplay tweaks"}, {"GAMEPLAY_ULTRAHAND_DISTANCE", "gameplay tweaks"},
{"GAMEPLAY_ITEM_WHEEL", "gameplay tweaks"}, {"GAMEPLAY_ITEM_AD", "gameplay tweaks"},
@@ -233,6 +233,7 @@ static const CfgMeta metas[] = {
{"WB_FENCE_LIMIT", "65536", "0..1073741824", RESTART}, {"WB_MERGE", "1", "0|1", RESTART}, {"WB_EXACT", "1", "0|1", RESTART},
{"PASS_CRUMBS", "", "0|1", RESTART}, // vk_crumbs.c pass marks; unset: VK_AMD_buffer_marker only
{"ADDR_REPORT", "0", "0|1", RESTART}, // vk_device.c GPU address map for device faults
{"PLUGIN_TRACE", "0", "0|1", RESTART}, // plugin_init.c: the first call of each mod plugin hook entry
{"INPUT_RECORD", "", NULL, RESTART},
};
+12
View File
@@ -45,6 +45,18 @@ def main():
problems = [f'{name}: in runtime/cfg.c known[], described in neither totk.ini.example nor docs/settings.md'
for name in sorted(known - in_example - in_doc)]
problems += [f'{name}: in docs/settings.md, not in runtime/cfg.c known[]' for name in sorted(in_doc - known)]
# cfg_value and the cfg_int/cfg_double/cfg_bool over it stop the game when the key is unset and metas[] has no row;
# a line that tests cfg_get of the same key first reads it only when it is set
metas = set(re.findall(r'\{"([A-Z0-9_]+)", "[^"]*", (?:"[^"]*"|NULL)', cfg))
unsafe = set()
for path in sorted((ROOT / 'runtime').rglob('*')):
if path.suffix in ('.c', '.cpp', '.h'):
for line in path.read_text(encoding='utf-8', errors='replace').splitlines():
for name in re.findall(r'\bcfg_(?:value|int|double|bool)\("TOTK_([A-Z0-9_]+)"\)', line):
if name not in metas and f'cfg_get("TOTK_{name}")' not in line:
unsafe.add((name, path.relative_to(ROOT).as_posix()))
problems += [f'{name}: {where} reads it through cfg_value, runtime/cfg.c metas[] has no row: the game stops '
f'when it is unset' for name, where in sorted(unsafe)]
defaults = code_defaults(cfg)
for name, written, _ in rows:
code = defaults.get(name.upper())