Repository navigation
reset inited flags and fix language bugs - #7835
Conversation
The unit tests parse the tables once per test; a parse teardown should reset flags so that subsequent tests work properly. weapon_close() and ship_close() now reset Weapons_inited and Ships_inited, so a later init parses the tables again instead of skipping them. lcl_xstr_close() now resets Xstr_inited, and lcl_xstr_init() skips parsing if the tables are already loaded. This uses a separate Xstr_tables_parsed flag, since FRED and qtfred set Xstr_inited without parsing anything. lcl_close() now clears Lcl_languages, and lcl_init() only builds the language list when it is empty. Previously a second lcl_init() added English again at index 1 and skipped the built-in languages. Game shutdown now calls lcl_close() instead of lcl_xstr_close(). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dustinspace217
left a comment
There was a problem hiding this comment.
The Lcl_languages fix and the separate Xstr_tables_parsed flag both check out. Since the goal is a re-parse that matches a fresh start, a few pieces of table state still survive a close:
- Fighter_bomber_valid is only ever set to true, and the Ship_type indices only change inside the lookup branch (ship.cpp:6369-6375). Reload with tables lacking fighter and bomber, and a "fighter/bomber" ship-type-destroyed reads Ship_type_counts[-1] (sexp.cpp:8072).
- Wing_formations is never cleared, so a second parse hits "Formation %s already exists".
- The two pending proximity maps and Default_cmeasure_name in weapon_close. Our #7850 already clears the maps there, so whichever lands second keeps those lines.
Engine_wash_info is handled by #7909. Its ShipSharedModelTest resets Ships_inited by hand ("ship_close() doesn't reset this"); whichever lands second can drop that, and it becomes a test for this PR.
Smaller: test_options_manager.cpp:109 (from #7561) and the "only from game_shutdown" notes on ship_close and weapon_close go stale, and an mprintf on the new early return in lcl_xstr_init would keep a missed lcl_xstr_close visible.
ship_init() now resets the fighter/bomber special-case state and clears Wing_formations before parsing, and weapon_init() clears the pending proximity lists and Default_cmeasure_name. Otherwise a second parse kept values from the first: a stale Fighter_bomber_valid could index Ship_type_counts with -1, and every wing formation was reported as a duplicate. Also update comments that described ship_close() and weapon_close() as shutdown-only, and the test comment that said Xstr_inited stays set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@dustinspace217 ok, addressed. I didn't add a log line on the early return because none of the other early returns have one. |
dustinspace217
left a comment
There was a problem hiding this comment.
All points now look green to me.
Kestrellius
left a comment
There was a problem hiding this comment.
Everything checks out.
The unit tests parse the tables once per test; a parse teardown should reset flags so that subsequent tests work properly.
weapon_close() and ship_close() now reset Weapons_inited and Ships_inited, so a later init parses the tables again instead of skipping them.
lcl_xstr_close() now resets Xstr_inited, and lcl_xstr_init() skips parsing if the tables are already loaded. This uses a separate Xstr_tables_parsed flag, since FRED and qtfred set Xstr_inited without parsing anything.
lcl_close() now clears Lcl_languages, and lcl_init() only builds the language list when it is empty. Previously a second lcl_init() added English again at index 1 and skipped the built-in languages. Game shutdown now calls lcl_close() instead of lcl_xstr_close().