Skip to content

reset inited flags and fix language bugs - #7835

Merged
Goober5000 merged 2 commits into
scp-fs2open:masterfrom
Goober5000:fix/inited
Nov 17, 2026
Merged

Goober5000 merged 2 commits into
scp-fs2open:masterfrom
Goober5000:fix/inited

Conversation

@Goober5000

Copy link
Copy Markdown
Contributor

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().

@Goober5000 Goober5000 added fix A fix for bugs, not-a-bugs, and/or regressions. localization / translation (XSTR) A feature or issue related to language localization and translations. labels Oct 7, 2026
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 dustinspace217 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@Goober5000

Goober5000 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor Author

@dustinspace217 ok, addressed. I didn't add a log line on the early return because none of the other early returns have one.

@dustinspace217 dustinspace217 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All points now look green to me.

@Kestrellius Kestrellius left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything checks out.

@Goober5000
Goober5000 merged commit 03adc81 into scp-fs2open:master Nov 17, 2026
18 checks passed
@Goober5000
Goober5000 deleted the fix/inited branch November 17, 2026 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix A fix for bugs, not-a-bugs, and/or regressions. localization / translation (XSTR) A feature or issue related to language localization and translations.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants