fix(menu): the chosen memory budget survives a restart #2376

Merged
thomas-montano merged 1 commit from fix/options-budget-once into main 2026-11-11 17:00:32 +00:00
thomas-montano commented 2026-11-11 16:38:36 +00:00 (Migrated from github.com)

The memory budget you pick in the options does not stick: at the next start the game goes back to the one the options file had before, and the file gains one more memory_budget= line each time the options are saved.

What changed

save() in gpu/vk/vk_menu.cpp writes the lines it owns, then copies every other line the options file had. It writes memory_budget= itself (the budget is not a menu row), but memory_budget was not among the keys it counted as its own, so the file's old line was copied after the new one. The reader at start-up keeps the last line, so the old budget won. memory_budget is now one of save()'s own keys, beside microphone_device and options_version.

Tests

  • New tests/test_options_budget_once.py: every key save() writes with fprintf must be one it owns. It fails on current main and passes with the change.
  • python -I -B tests/run_all.py menu: 14 passed (Linux).
  • Not run in the game, and not run on Windows: the change is to which lines a save keeps, so nothing shows on screen.
The memory budget you pick in the options does not stick: at the next start the game goes back to the one the options file had before, and the file gains one more `memory_budget=` line each time the options are saved. ## What changed `save()` in `gpu/vk/vk_menu.cpp` writes the lines it owns, then copies every other line the options file had. It writes `memory_budget=` itself (the budget is not a menu row), but `memory_budget` was not among the keys it counted as its own, so the file's old line was copied after the new one. The reader at start-up keeps the last line, so the old budget won. `memory_budget` is now one of save()'s own keys, beside `microphone_device` and `options_version`. ## Tests - New `tests/test_options_budget_once.py`: every key `save()` writes with `fprintf` must be one it owns. It fails on current `main` and passes with the change. - `python -I -B tests/run_all.py menu`: 14 passed (Linux). - Not run in the game, and not run on Windows: the change is to which lines a save keeps, so nothing shows on screen.
hckrman101 (Migrated from github.com) approved these changes 2026-11-11 16:49:25 +00:00
hckrman101 (Migrated from github.com) left a comment

Looks right. I read save() and the start-up reader at this sha.

  • Cause confirmed: save() writes memory_budget= itself but copied the file's old line afterwards as an "other" line, and the reader keeps the last one, so the old budget won. Adding it to the owned keys fixes exactly that.
  • Existing files with duplicate lines heal on the next save: every old memory_budget= line is now dropped and one is written. Until then the reader still takes the last line, same as before.
  • Other keys: only the one string is added to the mine test, so pad_/key_, discord_app_id= and any other unknown lines are still kept as before.
  • Windows/Linux: the read and write code is shared (plain fopen/fgets, no platform branch), so both behave the same.
  • The new test is declared-free and reads only the source, so it runs without a dump. It's a bit text-bound (the bool mine = ...; and fprintf(f, "key= shapes), but it fails loudly if they change, which is fine.

Only CI check listed is the title check, still pending when I looked.

Looks right. I read save() and the start-up reader at this sha. - Cause confirmed: save() writes `memory_budget=` itself but copied the file's old line afterwards as an "other" line, and the reader keeps the last one, so the old budget won. Adding it to the owned keys fixes exactly that. - Existing files with duplicate lines heal on the next save: every old `memory_budget=` line is now dropped and one is written. Until then the reader still takes the last line, same as before. - Other keys: only the one string is added to the `mine` test, so pad_/key_, discord_app_id= and any other unknown lines are still kept as before. - Windows/Linux: the read and write code is shared (plain fopen/fgets, no platform branch), so both behave the same. - The new test is declared-free and reads only the source, so it runs without a dump. It's a bit text-bound (the `bool mine = ...;` and `fprintf(f, "key=` shapes), but it fails loudly if they change, which is fine. Only CI check listed is the title check, still pending when I looked.
Commenting is not possible because the repository is archived.
No description provided.