Commit Graph
118 Commits
Author SHA1 Message Date
fd2c74727e Make LANGUAGE switchable in runtime (#653)
squashed into a single commit because doing it in steps that all
compiled involved a lot of boilerplate that is pointless to commit to
the repository. GH still has the PR for reference.

g_lang, MAX_MESSAGES_ON_MAP_BOTTOM, and GetLanguagePrefix() were
compile-time constants selected by the ENGLISH/GERMAN/... build
define. They're now runtime, defaulting to the same per-exe value the
define used to pick, and overridable at startup from [Ja2 Settings]
LANGUAGE in Ja2.ini.

-

XMLTacticalMessages is filled at runtime from NewTacticalMessages.xml,
never from compiled-in per-language data: all 8 per-language definitions
were the identical all-zero { L"" }. Delete them and define one shared
buffer in Utils/XML_Language.cpp (the loader) instead of pointer-rebinding
it like the static tables — this drops 9 dead 800KB zero-buffers (8
namespaced copies in LanguageStrings.cpp plus the standalone one) and
leaves no bind-ordering hazard for the XML load path.

-

ExportStrings.cpp privately recompiled one language's full text table
by #including the raw _<LANG>Text.cpp inside namespace Loc, keyed off
the exe-level ENGLISH/GERMAN/... compile macro (whichever the build
happened to select). That's redundant with the pointer globals every
other subsystem already uses (Text.h / LanguageStrings.cpp).

Drop the private copy; the unqualified table names in Loc::ExportStrings
now resolve to the global pointer externs, which BindLanguageStrings has
already rebound to the runtime g_lang by the time this runs (EXPORT_STRINGS
ini flag, checked after GetRuntimeSettings in sgp.cpp). gs_Lang (used only
by Loc::Translate for the Polish/Russian byte remap on raw .edt exports) is
now derived from g_lang via ToLocLanguage, so the export always matches
whatever language is actually active instead of a compile-time pick.

-

Editor/popupmenu.cpp and Strategic/Scheduling.cpp kept their own
call-site extern of gszScheduleActions as CHAR16[NUM_SCHEDULE_ACTIONS][20]
after the real definition changed into a rebindable pointer
(CHAR16 (*)[20], LanguageStrings.cpp). MSVC decays the outer array
dimension when mangling globals, so both declarations produce the same
symbol (?gszScheduleActions@@3PAY0BE@_WA) and the mismatch linked
silently -- but the array-typed TUs then indexed the 4-byte pointer
slot itself as string data, so the editor schedule popup and the map
schedule message text read garbage.

-

add text.def to be single-source of truth on symbol names and use it
 .much simpler, less error prone if adding more strings

-

add pseudo interface for language state. MAX_SAGES_ON_BOTTOM must always
 change in lockstep with g_lang. this isn't foolproof but better

---------

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-07-21 05:33:03 -03:00
Asdow 8b3e417872 Guard against illegal array access
Hovering mouse over an option long enough that the popup text appears and scrolling to last page with mouse wheel would run into assertion error in gprintfdirty()  Assert(pFontString!=NULL); if the option was one of the last ones that didn't have a text box in the last option page.
2026-05-28 17:44:21 +03:00
GreysaandGitHub 0a758179c2 Advanced repairs skill check (#581)
* Add technician level skill check for advanced repair

* changed readability
2026-03-17 10:35:29 +01:00
Asdow f8b6ee1672 Use externalized emails 2026-01-03 17:27:43 +02:00
Asdow aba3688b4b Add framework for adding externalized emails
Emails from new GameDir file TableData/Email/Emails.xml can be added via lua scripting using calls to AddEmailFromXML & AddPreReadEmailFromXML. The order of emails in Emails.xml acts as the index to be referenced and provided when calling lua  functions.

An error message  will be displayed if an email is added with an out-of-scope index but game will be able to continue.

Localization is supported and was tested on Chinese localization.
2026-01-03 17:27:43 +02:00
Asdow 4fcf03d31a Include cleanup Tactical/.*cpp 2025-12-09 00:35:18 +02:00
Asdow fb8feca896 include cleanup 2025-12-03 23:52:05 +02:00
Asdow be70cd18a2 Formatting 2025-12-03 23:52:05 +02:00
Asdow 6a1b84e53b include cleanup 2025-12-03 23:52:05 +02:00
Asdow 584e10d14f include cleanup 2025-12-03 23:52:05 +02:00
Asdow 4f0f6f9f23 set function static 2025-12-03 23:52:05 +02:00
Asdow 2f13ef79b6 Remove unused function declaration 2025-12-03 23:52:05 +02:00
Asdow f8f9c18cda Remove duplicate includes 2025-12-03 23:52:05 +02:00
Asdow 37c081f3db Formatting 2025-12-03 23:52:05 +02:00
Asdow e684f61f55 include cleanup 2025-12-03 23:52:05 +02:00
Asdow c2f4ca5da1 Set functions static 2025-12-03 23:52:05 +02:00
Asdow 5befb47881 Include cleanup 2025-12-03 23:52:05 +02:00
Asdow 780831611d Remove unused #defines 2025-12-03 23:52:05 +02:00
Asdow bb13225778 Include cleanup 2025-12-03 23:52:05 +02:00
Asdow 2f62d6fe44 Set functions static 2025-12-03 23:52:05 +02:00
Asdow 6e94ac144b formatting 2025-12-03 23:52:05 +02:00
Asdow 6e45ca9825 include cleanup 2025-12-03 23:52:05 +02:00
Asdow 142de9b02e Formatting 2025-12-03 23:52:05 +02:00
Asdow 7a024aecd7 include cleanup 2025-12-03 23:52:05 +02:00
Asdow c81d290957 Remove duplicate include 2025-12-03 23:52:05 +02:00
Asdow 3c498abe82 Set function static 2025-12-03 23:52:05 +02:00
Asdow fdf494c28a Remove unused LaserLock system 2025-12-03 23:52:05 +02:00
Asdow b903ead06a Formatting 2025-12-03 23:52:05 +02:00
Asdow 591a1a63c8 include cleanup 2025-12-03 23:52:05 +02:00
Asdow e60dcbc3e9 Remove unused function 2025-12-03 23:52:05 +02:00
Asdow d73d56d85a Formatting 2025-12-03 23:52:05 +02:00
Asdow d21293d4ad include cleanup 2025-12-03 23:52:05 +02:00
Asdow 297d052670 Formatting 2025-12-03 23:52:05 +02:00
Asdow f21508ad15 include cleanup 2025-12-03 23:52:05 +02:00
Asdow 4c53bb70f3 Formatting 2025-12-03 23:52:05 +02:00
Asdow 6c5f94c0cc Combine JA2UB ifdefs 2025-12-03 23:52:05 +02:00
Asdow 65e5c1768a include cleanup 2025-12-03 23:52:05 +02:00
Asdow 04f03fb2cc formatting 2025-12-03 23:52:05 +02:00
Asdow a8218462e1 include cleanup 2025-12-03 23:52:05 +02:00
Asdow 00c8bd0aa7 Remove duplicate include 2025-12-03 23:52:05 +02:00
Asdow d3cd51e7eb Formatting 2025-12-03 23:52:05 +02:00
Asdow 37795bb73c Remove unused and transitive includes 2025-12-03 23:52:05 +02:00
Asdow 5b4099a828 Set functions static 2025-12-03 23:52:05 +02:00
Asdow 977b7a5b2d Remove unused includes 2025-12-03 23:52:05 +02:00
Asdow e6824bf15d set function static 2025-12-03 23:52:05 +02:00
Asdow 63a58502d1 Remove duplicate includes 2025-12-03 23:52:05 +02:00
Asdow 173f786f55 Remove unused includes 2025-12-03 23:52:05 +02:00
Asdow ea1a3a9e9e Set functions static 2025-12-03 23:52:05 +02:00
Asdow b562b45c00 Externalize tunnel sectors for adding enemies to 2025-11-27 22:38:29 +02:00
Asdow 20ee284e42 Remove transitive include 2025-11-23 18:28:17 +02:00