Skip to content

refactor(WideChar): centralize project wide-character type - #3321

Open
CryoTheRenegade wants to merge 5 commits into
TheSuperHackers:mainfrom
CryoTheRenegade:refactor/wide-char-type
Open

CryoTheRenegade wants to merge 5 commits into
TheSuperHackers:mainfrom
CryoTheRenegade:refactor/wide-char-type

Conversation

@CryoTheRenegade

Copy link
Copy Markdown

As requested here

Centralize the existing WideChar typedef in Lib/WideChar.h and replace direct project uses of wchar_t with it. Standard wide strings now use std::basic_string<WideChar>.

This prepares for later ICU work while preserving the current representation and behavior. WideChar still aliases wchar_t, and existing string containers remain in place. Changing the representation later will also require adapting wide literals, character traits, and CRT/platform APIs.

AI assistance was used to validate this refactor

@coderabbitai

coderabbitai Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: e0d59b72-62d6-4f56-bb7c-149074dd2c77

📥 Commits

Reviewing files that changed from the base of the PR and between 02d13e7 and 84ec924.

📒 Files selected for processing (1)
  • Dependencies/Utility/CMakeLists.txt

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


Walkthrough

The change adds shared WideChar, stl::string, and stl::wstring aliases. Wide-character APIs, buffers, and string storage across WWLib, GameSpy, Autorun, and game tools now use these project-defined types.

Changes

WideChar type migration

Layer / File(s) Summary
Shared WideChar contract
Dependencies/Utility/*, Core/Libraries/Include/Lib/BaseType.h, Core/Libraries/Source/WWVegas/WWLib/WWCommon.h, Core/Tools/Launcher/Toolkit/Support/UTypes.h
Adds the shared WideChar and stl string aliases. Utility targets include the new headers and force-include WideChar.h.
WWLib wide-character APIs
Core/Libraries/Include/Lib/PathUtil.h, Core/Libraries/Source/WWVegas/WWLib/*
Updates path, INI, line-reading, string, trimming, and UTF-8 interfaces from wchar_t to WideChar. Existing processing behavior remains unchanged.
GameSpy and language handling
Core/GameEngine/Include/GameNetwork/GameSpy/*, Core/GameEngine/Source/GameNetwork/GameSpy/*, Core/GameEngine/Source/GameClient/LanguageFilter.cpp
Uses stl::wstring for GameSpy text values and conversion results. Uses WideChar for language-filter buffers and variables.
Autorun text and utility APIs
Core/Tools/Autorun/*
Updates text, locale, font, path, message, and buffer APIs to use WideChar. Replaces direct wide-string storage with stl::wstring where applicable.
Game and tool consumers
Core/Tools/Babylon/transcs.cpp, Generals*/Code/GameEngine/Source/*, GeneralsMD/Code/Tools/WorldBuilder/src/playerlistdlg.cpp
Updates translation, save-game, replay, and WorldBuilder wide-character buffers and parameters to use WideChar.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Refactor

Merge Risk: 🟠 High · up to 84ec9

The Autorun error-message path may fail to compile or format messages after the string migration, leaving a serious merge-blocking compatibility risk.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: centralizing the project-wide WideChar type.
Description check ✅ Passed The description accurately explains the WideChar centralization, wchar_t replacements, string changes, preserved behavior, and future ICU preparation.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[High risk] Replaces wide-character type across 46 files.

The PR appears safe to merge based on the reviewed changes.

Summary

The PR centralizes the native wide-character alias and introduces stl::wstring as std::basic_string<unichar>. Changes since the previous review are formatting-only.

  • Updates project wide-character declarations and string uses across engine, library, and tool code.
  • Keeps the underlying representation as wchar_t.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["wchar_t"] --> B["unichar"]
  B --> C["WideChar"]
  B --> D["stl::wstring"]
  C --> E["Project wide-character APIs"]
  D --> F["Wide string uses"]
Loading

Reviews (7) · Last reviewed commit: "style: preserve original formatting in w..."

Comment thread Dependencies/Utility/Utility/WideChar.h Outdated
Comment thread Core/GameEngine/Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp Outdated
Comment thread Core/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 718733c9-df83-434c-8c04-9d8f36bf2e55

📥 Commits

Reviewing files that changed from the base of the PR and between afb9d15 and 02d13e7.

📒 Files selected for processing (44)
  • Core/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h
  • Core/GameEngine/Include/GameNetwork/GameSpy/ThreadUtils.h
  • Core/GameEngine/Source/GameClient/LanguageFilter.cpp
  • Core/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp
  • Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PeerThread.cpp
  • Core/GameEngine/Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp
  • Core/Libraries/Include/Lib/BaseType.h
  • Core/Libraries/Include/Lib/PathUtil.h
  • Core/Libraries/Source/WWVegas/WWLib/INI.h
  • Core/Libraries/Source/WWVegas/WWLib/WWCommon.h
  • Core/Libraries/Source/WWVegas/WWLib/ini.cpp
  • Core/Libraries/Source/WWVegas/WWLib/readline.cpp
  • Core/Libraries/Source/WWVegas/WWLib/readline.h
  • Core/Libraries/Source/WWVegas/WWLib/stringex.h
  • Core/Libraries/Source/WWVegas/WWLib/trim.cpp
  • Core/Libraries/Source/WWVegas/WWLib/trim.h
  • Core/Libraries/Source/WWVegas/WWLib/utf8.cpp
  • Core/Libraries/Source/WWVegas/WWLib/utf8.h
  • Core/Tools/Autorun/DrawButton.cpp
  • Core/Tools/Autorun/DrawButton.h
  • Core/Tools/Autorun/GameText.cpp
  • Core/Tools/Autorun/GameText.h
  • Core/Tools/Autorun/Locale_API.cpp
  • Core/Tools/Autorun/Locale_API.h
  • Core/Tools/Autorun/TTFont.cpp
  • Core/Tools/Autorun/TTFont.h
  • Core/Tools/Autorun/Utils.cpp
  • Core/Tools/Autorun/Utils.h
  • Core/Tools/Autorun/Wnd_File.h
  • Core/Tools/Autorun/Wnd_file.cpp
  • Core/Tools/Autorun/autorun.cpp
  • Core/Tools/Autorun/locale.cpp
  • Core/Tools/Babylon/transcs.cpp
  • Core/Tools/Launcher/Toolkit/Support/UTypes.h
  • Dependencies/Utility/CMakeLists.txt
  • Dependencies/Utility/Utility/WideChar.h
  • Dependencies/Utility/Utility/string_adapter.h
  • Generals/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp
  • Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupReplay.cpp
  • Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp
  • GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp
  • GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupReplay.cpp
  • GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp
  • GeneralsMD/Code/Tools/WorldBuilder/src/playerlistdlg.cpp
💤 Files with no reviewable changes (33)
  • Dependencies/Utility/Utility/WideChar.h
  • GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp
  • Generals/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp
  • Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp
  • Core/Tools/Babylon/transcs.cpp
  • Core/Tools/Autorun/DrawButton.cpp
  • Core/Libraries/Source/WWVegas/WWLib/readline.h
  • Core/Tools/Autorun/TTFont.h
  • Core/GameEngine/Source/GameClient/LanguageFilter.cpp
  • GeneralsMD/Code/Tools/WorldBuilder/src/playerlistdlg.cpp
  • Core/Libraries/Source/WWVegas/WWLib/trim.h
  • GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupReplay.cpp
  • Core/Tools/Autorun/Utils.h
  • Core/Libraries/Source/WWVegas/WWLib/ini.cpp
  • Core/Tools/Autorun/GameText.h
  • Core/Tools/Autorun/Wnd_File.h
  • Core/Tools/Autorun/locale.cpp
  • Core/Tools/Autorun/DrawButton.h
  • Core/Libraries/Source/WWVegas/WWLib/utf8.cpp
  • Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupReplay.cpp
  • GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp
  • Core/Libraries/Source/WWVegas/WWLib/INI.h
  • Core/Libraries/Include/Lib/PathUtil.h
  • Core/Libraries/Source/WWVegas/WWLib/trim.cpp
  • Core/Tools/Launcher/Toolkit/Support/UTypes.h
  • Core/Tools/Autorun/Utils.cpp
  • Core/Libraries/Source/WWVegas/WWLib/stringex.h
  • Core/Libraries/Source/WWVegas/WWLib/readline.cpp
  • Core/Libraries/Source/WWVegas/WWLib/utf8.h
  • Core/Tools/Autorun/Wnd_file.cpp
  • Core/Tools/Autorun/Locale_API.h
  • Core/Tools/Autorun/Locale_API.cpp
  • Core/Tools/Autorun/TTFont.cpp

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread Core/Tools/Autorun/autorun.cpp

@xezon xezon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Needs to desloppify more.

Comment thread Dependencies/Utility/Utility/WideChar.h Outdated
Comment thread Dependencies/Utility/Utility/stringex.h Outdated
Comment thread Dependencies/Utility/Utility/WideChar.h Outdated
Comment thread Dependencies/Utility/Utility/WideChar.h
Comment thread Dependencies/Precompiled/Precompiled/unichar.h
Comment thread Dependencies/Utility/Utility/stringex.h Outdated
Comment thread Core/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h Outdated
@xezon xezon added the Refactor Edits the code with insignificant behavior changes, is never user facing label Oct 2, 2026
Comment thread Dependencies/Precompiled/Precompiled/precompiled.h Outdated
Comment thread Core/Libraries/Source/WWVegas/WWLib/INI.h Outdated
Comment thread Core/Libraries/Source/WWVegas/WWLib/INI.h Outdated
Comment thread Core/Libraries/Source/WWVegas/WWLib/WWCommon.h Outdated
Comment thread Core/GameEngine/Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp Outdated

@xezon xezon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There are still several unrelated refactors made. Probably autoformat by the IDE (try disable it)

Comment thread Core/Tools/Autorun/Wnd_File.h Outdated
Comment thread Core/Tools/Autorun/DrawButton.h Outdated
Comment thread Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PeerThread.cpp Outdated
@xezon

xezon commented Oct 4, 2026

Copy link
Copy Markdown

The change description is outdated.

/****************************************************************************/
int Locale_Init ( int language, char *file );
void Locale_Restore ();
const wchar_t* Locale_GetString( const char *id, wchar_t *buffer = nullptr, int size = _MAX_PATH );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Autorun, same as WWVegas, currently does not use game base types. Therefore it should refer to unichar for now.

wchar_t wc;
wchar_t mb;
WideChar wc;
WideChar mb;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

unichar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactor Edits the code with insignificant behavior changes, is never user facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants