From c38d1f350d19d3a6a0abe14e37359507aae2a6d5 Mon Sep 17 00:00:00 2001 From: Jacob Ledbetter Date: Sat, 19 Sep 2026 10:07:28 -0600 Subject: [PATCH 1/6] refactor: centralize project wide-character type --- .../Include/GameNetwork/GameSpy/PeerThread.h | 9 ++-- .../Include/GameNetwork/GameSpy/ThreadUtils.h | 5 +- .../Source/GameClient/LanguageFilter.cpp | 9 ++-- .../GameSpy/Thread/BuddyThread.cpp | 6 ++- .../GameNetwork/GameSpy/Thread/PeerThread.cpp | 10 +++- .../GameSpy/Thread/ThreadUtils.cpp | 11 +++-- Core/Libraries/Include/CMakeLists.txt | 1 + Core/Libraries/Include/Lib/PathUtil.h | 10 ++-- Core/Libraries/Include/Lib/WideChar.h | 20 ++++++++ .../Precompiled/Precompiled/BaseTypes.h | 3 +- Core/Libraries/Source/WWVegas/WWLib/INI.h | 6 ++- Core/Libraries/Source/WWVegas/WWLib/ini.cpp | 7 +-- .../Source/WWVegas/WWLib/readline.cpp | 5 +- .../Libraries/Source/WWVegas/WWLib/readline.h | 4 +- Core/Libraries/Source/WWVegas/WWLib/trim.cpp | 7 +-- Core/Libraries/Source/WWVegas/WWLib/trim.h | 4 +- Core/Libraries/Source/WWVegas/WWLib/utf8.cpp | 25 +++++----- Core/Libraries/Source/WWVegas/WWLib/utf8.h | 12 +++-- Core/Tools/Autorun/DrawButton.cpp | 3 +- Core/Tools/Autorun/DrawButton.h | 12 +++-- Core/Tools/Autorun/GameText.cpp | 15 +++--- Core/Tools/Autorun/GameText.h | 4 +- Core/Tools/Autorun/Locale_API.cpp | 31 ++++++------ Core/Tools/Autorun/Locale_API.h | 6 ++- Core/Tools/Autorun/TTFont.cpp | 5 +- Core/Tools/Autorun/TTFont.h | 4 +- Core/Tools/Autorun/Utils.cpp | 35 +++++++------- Core/Tools/Autorun/Utils.h | 12 +++-- Core/Tools/Autorun/Wnd_File.h | 4 +- Core/Tools/Autorun/Wnd_file.cpp | 15 +++--- Core/Tools/Autorun/autorun.cpp | 47 ++++++++++--------- Core/Tools/Autorun/locale.cpp | 3 +- Core/Tools/Babylon/transcs.cpp | 5 +- Core/Tools/Launcher/Toolkit/Support/UTypes.h | 8 ++-- Dependencies/Utility/CMakeLists.txt | 1 + Dependencies/Utility/Utility/WideChar.h | 24 ++++++++++ Dependencies/Utility/Utility/stringex.h | 45 ++++++++++++------ .../Common/System/SaveGame/GameState.cpp | 5 +- .../GUI/GUICallbacks/Menus/PopupReplay.cpp | 5 +- .../GUI/GUICallbacks/Menus/ReplayMenu.cpp | 3 +- .../Common/System/SaveGame/GameState.cpp | 5 +- .../GUI/GUICallbacks/Menus/PopupReplay.cpp | 5 +- .../GUI/GUICallbacks/Menus/ReplayMenu.cpp | 3 +- .../Tools/WorldBuilder/src/playerlistdlg.cpp | 3 +- 44 files changed, 295 insertions(+), 167 deletions(-) create mode 100644 Core/Libraries/Include/Lib/WideChar.h create mode 100644 Dependencies/Utility/Utility/WideChar.h diff --git a/Core/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h b/Core/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h index b958d15c0b7..620f3860cba 100644 --- a/Core/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h @@ -28,6 +28,9 @@ #pragma once +#include "Lib/WideChar.h" +#include + #include "gamespy/peer/peer.h" #include "GameNetwork/NetworkDefs.h" @@ -69,7 +72,7 @@ class PeerRequest } peerRequestType; std::string nick; // only used by login, but must be outside the union b/c of copy constructor - std::wstring text; // can't be in a union + std::basic_string text; // can't be in a union std::string password; std::string email; std::string id; @@ -248,13 +251,13 @@ class PeerResponse std::string nick; // can't be in a union std::string oldNick; // can't be in a union - std::wstring text; // can't be in a union + std::basic_string text; // can't be in a union std::string locale; // can't be in a union std::string stagingServerGameOptions; // full string from UTMs // game opts sent with PEERRESPONSE_STAGINGROOM - std::wstring stagingServerName; + std::basic_string stagingServerName; std::string stagingServerPingString; std::string stagingServerLadderIP; std::string stagingRoomMapName; diff --git a/Core/GameEngine/Include/GameNetwork/GameSpy/ThreadUtils.h b/Core/GameEngine/Include/GameNetwork/GameSpy/ThreadUtils.h index 0db2a8df67e..d80d3392c73 100644 --- a/Core/GameEngine/Include/GameNetwork/GameSpy/ThreadUtils.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpy/ThreadUtils.h @@ -28,5 +28,8 @@ #pragma once -std::wstring MultiByteToWideCharSingleLine( const char *orig ); +#include "Lib/WideChar.h" +#include + +std::basic_string MultiByteToWideCharSingleLine( const char* orig ); std::string WideCharStringToMultiByte( const WideChar *orig ); diff --git a/Core/GameEngine/Source/GameClient/LanguageFilter.cpp b/Core/GameEngine/Source/GameClient/LanguageFilter.cpp index 93c2513baae..0400786e5ba 100644 --- a/Core/GameEngine/Source/GameClient/LanguageFilter.cpp +++ b/Core/GameEngine/Source/GameClient/LanguageFilter.cpp @@ -24,6 +24,7 @@ #include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine +#include "Lib/WideChar.h" #include "GameClient/LanguageFilter.h" #include "Common/FileSystem.h" @@ -50,7 +51,7 @@ void LanguageFilter::init() { return; } - wchar_t word[128]; + WideChar word[128]; while (readWord(file1, word)) { Int wordLen = wcslen(word); if (wordLen == 0) { @@ -76,7 +77,7 @@ void LanguageFilter::reset() { void LanguageFilter::update() { } -wchar_t ignoredChars[] = L"-_*'\""; +WideChar ignoredChars[] = L"-_*'\""; void LanguageFilter::filterLine(UnicodeString &line) { @@ -87,7 +88,7 @@ void LanguageFilter::filterLine(UnicodeString &line) UnicodeString token; while (newLine.nextToken(&token, L" ;,.!?:=\\/><`~()&^%#\n\t")) { - wchar_t *pos = wcsstr(buf, token.str()); + WideChar* pos = wcsstr(buf, token.str()); if (pos == nullptr) { DEBUG_CRASH(("Couldn't find the token in its own string.")); continue; @@ -114,7 +115,7 @@ void LanguageFilter::unHaxor(UnicodeString &word) { Int len = word.getLength(); UnicodeString newWord; for (Int i = 0; i < len; ++i) { - wchar_t c = word.getCharAt(i); + WideChar c = word.getCharAt(i); if ((c == L'p') || (c == L'P')) { if (((i + 1) < len) && ((word.getCharAt(i+1) == L'h') || (word.getCharAt(i+1) == L'H'))) { newWord.concat(L'f'); diff --git a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp index fb8f1b88d08..dc697c4823e 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp @@ -30,6 +30,8 @@ // Author: Matthew D. Campbell, June 2002 #include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine +#include "Lib/WideChar.h" +#include #include "GameNetwork/GameSpy/BuddyThread.h" #include "GameNetwork/GameSpy/PeerThread.h" @@ -517,7 +519,7 @@ void BuddyThreadClass::messageCallback( GPConnection *con, GPRecvBuddyMessageArg // get info about the person asking to be our buddy gpGetInfo( con, arg->profile, GP_CHECK_CACHE, GP_BLOCKING, (GPCallback)getNickForMessage, &messageResponse); - std::wstring s = MultiByteToWideCharSingleLine( arg->message ); + std::basic_string s = MultiByteToWideCharSingleLine( arg->message ); wcslcpy(messageResponse.arg.message.text, s.c_str(), MAX_BUDDY_CHAT_LEN); messageResponse.arg.message.date = arg->date; DEBUG_LOG(("Got a buddy message from %d [%ls]", arg->profile, s.c_str())); @@ -636,7 +638,7 @@ void BuddyThreadClass::requestCallback( GPConnection *con, GPRecvBuddyRequestArg // get info about the person asking to be our buddy gpGetInfo( con, arg->profile, GP_CHECK_CACHE, GP_BLOCKING, (GPCallback)getInfoResponseForRequest, &response); - std::wstring s = MultiByteToWideCharSingleLine( arg->reason ); + std::basic_string s = MultiByteToWideCharSingleLine( arg->reason ); wcslcpy(response.arg.request.text, s.c_str(), GP_REASON_LEN); TheGameSpyBuddyMessageQueue->addResponse( response ); diff --git a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PeerThread.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PeerThread.cpp index 178a1b1ad3c..0f1e12b77ce 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PeerThread.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PeerThread.cpp @@ -30,6 +30,8 @@ // Author: Matthew D. Campbell, June 2002 #include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine +#include "Lib/WideChar.h" +#include #include "Common/Registry.h" #include "Common/OptionPreferences.h" @@ -232,7 +234,11 @@ class PeerThreadClass : public ThreadClass UnsignedInt exeCRC() { return m_exeCRC; } UnsignedInt iniCRC() { return m_iniCRC; } UnsignedInt gameVersion() { return m_gameVersion; } - std::wstring getLocalStagingServerName() { return m_localStagingServerName; } + std::basic_string getLocalStagingServerName() + { + return m_localStagingServerName; + } + Int getLocalRoomID() { return m_localRoomID; } std::string ladderIP() { return m_ladderIP; } UnsignedShort ladderPort() { return m_ladderPort; } @@ -314,7 +320,7 @@ class PeerThreadClass : public ThreadClass Int m_nextStagingServer; std::map m_stagingServers; - std::wstring m_localStagingServerName; + std::basic_string m_localStagingServerName; Int m_localRoomID; void doQuickMatch( PEER peer ); diff --git a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp index 84ce0c9b19a..c327c22c6a2 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp @@ -27,19 +27,24 @@ // Author: Matthew D. Campbell, July 2002 #include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine +#include "Lib/WideChar.h" +#include #include "WWLib/utf8.h" //------------------------------------------------------------------------- // TheSuperHackers @refactor bobtista 02/04/2026 Use WWLib UTF-8 functions instead of raw Win32 API calls -std::wstring MultiByteToWideCharSingleLine( const char *orig ) +std::basic_string MultiByteToWideCharSingleLine( const char* orig ) { const size_t srcLen = strlen(orig); const size_t dstLen = Utf8_To_Wide_Len(orig, srcLen); if (dstLen == 0) - return std::wstring(); - std::wstring ret; + { + return std::basic_string(); + } + + std::basic_string ret; if (dstLen == UTF8_INVALID) { // Not UTF-8. Fall back to a 1:1 byte cast so legacy data keeps its characters, matching diff --git a/Core/Libraries/Include/CMakeLists.txt b/Core/Libraries/Include/CMakeLists.txt index 86274a44b28..67cb0c97188 100644 --- a/Core/Libraries/Include/CMakeLists.txt +++ b/Core/Libraries/Include/CMakeLists.txt @@ -13,6 +13,7 @@ set(LIBRARIES_INCLUDE_SRC Lib/Region3D.h Lib/RGBColor.h Lib/trig.h + Lib/WideChar.h rts/debug.h rts/profile.h Precompiled/Precompiled/BaseAlgorithm.h diff --git a/Core/Libraries/Include/Lib/PathUtil.h b/Core/Libraries/Include/Lib/PathUtil.h index 6fcdc91fadf..0822353b4d5 100644 --- a/Core/Libraries/Include/Lib/PathUtil.h +++ b/Core/Libraries/Include/Lib/PathUtil.h @@ -20,6 +20,8 @@ #pragma once +#include "Lib/WideChar.h" + #include "BaseType.h" #include @@ -76,7 +78,7 @@ inline const char* getLastPathSeparator(const char* path) return path ? maxPtr(strrchr(path, '/'), strrchr(path, '\\')) : nullptr; } -inline const wchar_t* getLastPathSeparator(const wchar_t* path) +inline const WideChar* getLastPathSeparator(const WideChar* path) { return path ? maxPtr(wcsrchr(path, L'/'), wcsrchr(path, L'\\')) : nullptr; } @@ -108,16 +110,16 @@ inline const char* getExtension(const char* path) return lastDot; } -inline const wchar_t* getExtension(const wchar_t* path) +inline const WideChar* getExtension(const WideChar* path) { - const wchar_t* lastDot = wcsrchr(path, L'.'); + const WideChar* lastDot = wcsrchr(path, L'.'); if (!lastDot) { return nullptr; } - const wchar_t* lastSeparator = getLastPathSeparator(path); + const WideChar* lastSeparator = getLastPathSeparator(path); // Check if the dot is contained in the filename if (lastSeparator && lastDot < lastSeparator) diff --git a/Core/Libraries/Include/Lib/WideChar.h b/Core/Libraries/Include/Lib/WideChar.h new file mode 100644 index 00000000000..ce980cdf6ce --- /dev/null +++ b/Core/Libraries/Include/Lib/WideChar.h @@ -0,0 +1,20 @@ +/* +** Copyright 2026 TheSuperHackers +** +** This program is free software: you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation, either version 3 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program. If not, see . +*/ + +#pragma once + +#include diff --git a/Core/Libraries/Include/Precompiled/Precompiled/BaseTypes.h b/Core/Libraries/Include/Precompiled/Precompiled/BaseTypes.h index 468bd761e53..e119130f375 100644 --- a/Core/Libraries/Include/Precompiled/Precompiled/BaseTypes.h +++ b/Core/Libraries/Include/Precompiled/Precompiled/BaseTypes.h @@ -17,6 +17,8 @@ #pragma once +#include "Lib/WideChar.h" + // Fundamental type definitions typedef float Real; @@ -34,6 +36,5 @@ typedef char Byte; typedef unsigned char UnsignedByte; typedef char Char; -typedef wchar_t WideChar; typedef bool Bool; diff --git a/Core/Libraries/Source/WWVegas/WWLib/INI.h b/Core/Libraries/Source/WWVegas/WWLib/INI.h index a1dc6fbbe4a..af49dd2b3b6 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/INI.h +++ b/Core/Libraries/Source/WWVegas/WWLib/INI.h @@ -36,6 +36,8 @@ #pragma once +#include "Lib/WideChar.h" + #include //#include "listnode.h" @@ -138,7 +140,7 @@ class INIClass { int Get_Int(char const * section, char const * entry, int defvalue=0) const; int Get_String(char const * section, char const * entry, char const * defvalue, char * buffer, int size) const; const StringClass& Get_String(StringClass& new_string, char const * section, char const * entry, char const * defvalue="") const; - const WideStringClass& Get_Wide_String(WideStringClass& new_string, char const * section, char const * entry, wchar_t const * defvalue=L"") const; + const WideStringClass& Get_Wide_String(WideStringClass& new_string, const char* section, const char* entry, const WideChar* defvalue=L"") const; int Get_List_Index(char const * section, char const * entry, int const defvalue, char *list[]); int * Get_Alloc_Int_Array(char const * section, char const * entry, int listend); int Get_Int_Bitfield(char const * section, char const * entry, int defvalue, char *list[]); @@ -170,7 +172,7 @@ class INIClass { bool Put_Point(char const * section, char const * entry, TPoint3D const & value); bool Put_Point(char const * section, char const * entry, TPoint3D const & value); bool Put_Point(char const * section, char const * entry, TPoint2D const & value); - bool Put_Wide_String(char const * section, char const * entry, wchar_t const * string); + bool Put_Wide_String(const char* section, const char* entry, const WideChar* string); // protected: diff --git a/Core/Libraries/Source/WWVegas/WWLib/ini.cpp b/Core/Libraries/Source/WWVegas/WWLib/ini.cpp index 0b32b043afc..ecb6c2bc69e 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/ini.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/ini.cpp @@ -85,6 +85,7 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "always.h" +#include "Lib/WideChar.h" #include "b64pipe.h" #include "b64straw.h" #include "cstraw.h" @@ -988,9 +989,9 @@ int INIClass::Get_UUBlock(char const * section, void * block, int len) const * HISTORY: * * 11/6/2001 4:27PM ST : Created * *=============================================================================================*/ -const WideStringClass& INIClass::Get_Wide_String(WideStringClass& new_string, char const * section, char const * entry, wchar_t const * defvalue) const +const WideStringClass& INIClass::Get_Wide_String(WideStringClass& new_string, const char* section, const char* entry, const WideChar* defvalue) const { - wchar_t out[1024]; + WideChar out[1024]; char buffer[1024]; Base64Pipe b64pipe(Base64Pipe::DECODE); @@ -1027,7 +1028,7 @@ const WideStringClass& INIClass::Get_Wide_String(WideStringClass& new_string, ch * HISTORY: * * 11/6/2001 4:29PM ST : Created * *=============================================================================================*/ -bool INIClass::Put_Wide_String(char const * section, char const * entry, wchar_t const * string) +bool INIClass::Put_Wide_String(const char* section, const char* entry, const WideChar* string) { if (section == nullptr || entry == nullptr || string == nullptr) { return(false); diff --git a/Core/Libraries/Source/WWVegas/WWLib/readline.cpp b/Core/Libraries/Source/WWVegas/WWLib/readline.cpp index a63730e8198..0b57130c8fd 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/readline.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/readline.cpp @@ -38,6 +38,7 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "always.h" +#include "Lib/WideChar.h" #include "readline.h" #include "trim.h" #include "WWFILE.h" @@ -117,13 +118,13 @@ int Read_Line(Straw & file, char * buffer, int len, bool & eof) return(strlen(buffer)); } -int Read_Line(Straw & file, wchar_t * buffer, int len, bool & eof) +int Read_Line(Straw & file, WideChar* buffer, int len, bool & eof) { if (len == 0 || buffer == nullptr) return(0); int count = 0; for (;;) { - wchar_t c; + WideChar c; if (file.Get(&c, sizeof(c)) != sizeof(c)) { eof = true; buffer[count] = L'\0'; diff --git a/Core/Libraries/Source/WWVegas/WWLib/readline.h b/Core/Libraries/Source/WWVegas/WWLib/readline.h index 1a9f019cc56..ae51f424254 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/readline.h +++ b/Core/Libraries/Source/WWVegas/WWLib/readline.h @@ -36,10 +36,12 @@ #pragma once +#include "Lib/WideChar.h" + #include "STRAW.h" #include "WWFILE.h" #include int Read_Line(FileClass & file, char * buffer, int len, bool & eof); int Read_Line(Straw & file, char * buffer, int len, bool & eof); -int Read_Line(Straw & file, wchar_t * buffer, int len, bool & eof); +int Read_Line(Straw & file, WideChar* buffer, int len, bool & eof); diff --git a/Core/Libraries/Source/WWVegas/WWLib/trim.cpp b/Core/Libraries/Source/WWVegas/WWLib/trim.cpp index ccc97c2ff88..eb3f87568c8 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/trim.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/trim.cpp @@ -35,6 +35,7 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "always.h" +#include "Lib/WideChar.h" #include "trim.h" #ifdef _UNIX @@ -85,11 +86,11 @@ char* strtrim(char* buffer) } -wchar_t* wcstrim(wchar_t* buffer) +WideChar* wcstrim(WideChar* buffer) { if (buffer) { /* Strip leading white space from the string. */ - wchar_t* source = buffer; + WideChar* source = buffer; while ((*source != 0) && ((unsigned int)*source <= 32)) { ++source; @@ -97,7 +98,7 @@ wchar_t* wcstrim(wchar_t* buffer) if (source != buffer) { // TheSuperHackers @fix Mauller 04/04/2025 Replace wcscpy with safer memmove as memory regions can overlap when part of string is copied to itself - memmove(buffer, source, (wcslen(source) + 1) * sizeof(wchar_t)); + memmove(buffer, source, (wcslen(source) + 1) * sizeof(WideChar)); } /* Clip trailing white space from the string. */ diff --git a/Core/Libraries/Source/WWVegas/WWLib/trim.h b/Core/Libraries/Source/WWVegas/WWLib/trim.h index cdb550eaa9a..48a60224753 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/trim.h +++ b/Core/Libraries/Source/WWVegas/WWLib/trim.h @@ -36,7 +36,9 @@ #pragma once +#include "Lib/WideChar.h" + #include char * strtrim(char * buffer); -wchar_t * wcstrim(wchar_t * buffer); +WideChar* wcstrim(WideChar* buffer); diff --git a/Core/Libraries/Source/WWVegas/WWLib/utf8.cpp b/Core/Libraries/Source/WWVegas/WWLib/utf8.cpp index 578299fbe3d..b01b35a4271 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/utf8.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/utf8.cpp @@ -17,11 +17,12 @@ */ #include "always.h" +#include "Lib/WideChar.h" #include "utf8.h" -// wchar_t is a 16-bit UTF-16 code unit on Windows and a 32-bit UTF-32 codepoint on most other +// WideChar is a 16-bit UTF-16 code unit on Windows and a 32-bit UTF-32 codepoint on most other // platforms. WCHAR_MAX lets us distinguish the two at compile time so the surrogate-pair paths -// are excluded entirely (not just constant-folded) where wchar_t is wide enough to hold a codepoint. +// are excluded entirely (not just constant-folded) where WideChar is wide enough to hold a codepoint. #if defined(WCHAR_MAX) && (WCHAR_MAX <= 0xFFFF) #define UTF8_WCHAR_IS_UTF16 1 #else @@ -138,11 +139,11 @@ static size_t Utf8_Decode(const char* src, size_t srcLen, unsigned int& cp) } // Read one codepoint at src, with srcLen wide characters remaining. Returns the number of wide -// characters consumed (1-2) and sets cp. Combines UTF-16 surrogate pairs where wchar_t is 16-bit; -// treats each element as a whole codepoint where wchar_t is 32-bit. Wide data that has no UTF-8 +// characters consumed (1-2) and sets cp. Combines UTF-16 surrogate pairs where WideChar is 16-bit; +// treats each element as a whole codepoint where WideChar is 32-bit. Wide data that has no UTF-8 // representation is reported as U+FFFD, so the encoder never emits a sequence that the decoder // would reject. -static size_t Wide_Read(const wchar_t* src, size_t srcLen, unsigned int& cp) +static size_t Wide_Read(const WideChar* src, size_t srcLen, unsigned int& cp) { size_t consumed = 1; #if UTF8_WCHAR_IS_UTF16 @@ -179,22 +180,22 @@ static size_t Wide_Encoded_Length(unsigned int cp) } // Write one codepoint to a wide buffer, which is assumed to have room. Returns wide characters written. -static size_t Wide_Write(wchar_t* dest, unsigned int cp) +static size_t Wide_Write(WideChar* dest, unsigned int cp) { #if UTF8_WCHAR_IS_UTF16 if (cp >= 0x10000) { cp -= 0x10000; - dest[0] = (wchar_t)(0xD800 + (cp >> 10)); - dest[1] = (wchar_t)(0xDC00 + (cp & 0x3FF)); + dest[0] = (WideChar)(0xD800 + (cp >> 10)); + dest[1] = (WideChar)(0xDC00 + (cp & 0x3FF)); return 2; } #endif - dest[0] = (wchar_t)cp; + dest[0] = (WideChar)cp; return 1; } -size_t Wide_To_Utf8_Len(const wchar_t* src, size_t srcLen) +size_t Wide_To_Utf8_Len(const WideChar* src, size_t srcLen) { size_t needed = 0; size_t i = 0; @@ -225,7 +226,7 @@ size_t Utf8_To_Wide_Len(const char* src, size_t srcLen) return needed; } -size_t Wide_To_Utf8(char* dest, size_t destLen, const wchar_t* src, size_t srcLen) +size_t Wide_To_Utf8(char* dest, size_t destLen, const WideChar* src, size_t srcLen) { size_t needed = 0; size_t out = 0; @@ -249,7 +250,7 @@ size_t Wide_To_Utf8(char* dest, size_t destLen, const wchar_t* src, size_t srcLe return needed; } -size_t Utf8_To_Wide(wchar_t* dest, size_t destLen, const char* src, size_t srcLen) +size_t Utf8_To_Wide(WideChar* dest, size_t destLen, const char* src, size_t srcLen) { size_t needed = 0; size_t out = 0; diff --git a/Core/Libraries/Source/WWVegas/WWLib/utf8.h b/Core/Libraries/Source/WWVegas/WWLib/utf8.h index 0a4f92f95ee..bdba2314ad0 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/utf8.h +++ b/Core/Libraries/Source/WWVegas/WWLib/utf8.h @@ -18,13 +18,15 @@ #pragma once +#include "Lib/WideChar.h" + #include #include // UTF-8 <-> wide-character transcoding, hand-rolled per RFC 3629, using no platform text APIs. -// The wide side is wchar_t, whose width is platform-dependent: on Windows it is a 16-bit UTF-16 +// The wide side is WideChar, whose width is platform-dependent: on Windows it is a 16-bit UTF-16 // code unit (astral codepoints use surrogate pairs); on most other platforms it is a 32-bit -// UTF-32 codepoint. Both are handled transparently based on the width of wchar_t. +// UTF-32 codepoint. Both are handled transparently based on the width of WideChar. // Returned by the decoding functions when the source is not well-formed UTF-8. A return of 0 means // an empty result, which is a success and must not be confused with a decoding failure. @@ -33,7 +35,7 @@ const size_t UTF8_INVALID = (size_t)-1; // Returns the number of UTF-8 bytes needed for the UTF-8 representation of srcLen wide characters // from src, not counting a null terminator. Returns 0 if srcLen is 0. Wide values that have no // UTF-8 representation are counted as U+FFFD. -size_t Wide_To_Utf8_Len(const wchar_t* src, size_t srcLen); +size_t Wide_To_Utf8_Len(const WideChar* src, size_t srcLen); // Returns the number of wide characters needed for the wide representation of srcLen bytes from the // UTF-8 string src, not counting a null terminator. Returns 0 if srcLen is 0, or UTF8_INVALID if @@ -46,7 +48,7 @@ size_t Utf8_To_Wide_Len(const char* src, size_t srcLen); // Returns the number of bytes the whole conversion needs, not counting a null terminator. A return // greater than destLen means the output was truncated on a codepoint boundary; retry with that many // bytes plus one for the terminator. Pass destLen 0 to measure without writing. -size_t Wide_To_Utf8(char* dest, size_t destLen, const wchar_t* src, size_t srcLen); +size_t Wide_To_Utf8(char* dest, size_t destLen, const WideChar* src, size_t srcLen); // Converts srcLen bytes from the UTF-8 string src to wide characters. destLen is the destination // buffer capacity in wide characters. Writes a null terminator if room remains, otherwise not. @@ -54,7 +56,7 @@ size_t Wide_To_Utf8(char* dest, size_t destLen, const wchar_t* src, size_t srcLe // A return greater than destLen means the output was truncated on a codepoint boundary; retry with // that many wide characters plus one for the terminator. Pass destLen 0 to measure without writing. // Returns UTF8_INVALID if src is not well-formed UTF-8, setting dest[0] to L'\0' if destLen > 0. -size_t Utf8_To_Wide(wchar_t* dest, size_t destLen, const char* src, size_t srcLen); +size_t Utf8_To_Wide(WideChar* dest, size_t destLen, const char* src, size_t srcLen); // Returns the largest length not greater than maxLen at which the srcLen bytes of the UTF-8 string // src can be cut without splitting a multibyte sequence, by backing off the continuation bytes at diff --git a/Core/Tools/Autorun/DrawButton.cpp b/Core/Tools/Autorun/DrawButton.cpp index 54ac3193ade..96df1de9332 100644 --- a/Core/Tools/Autorun/DrawButton.cpp +++ b/Core/Tools/Autorun/DrawButton.cpp @@ -43,6 +43,7 @@ #define STRICT #include +#include "Lib/WideChar.h" #include #include "autorun.h" #include "DrawButton.h" @@ -153,7 +154,7 @@ DrawButton::DrawButton ( int id, RECT button_rect, const char *normal, const cha Msg( __LINE__, TEXT(__FILE__), TEXT(" MyRect = [%d,%d,%d,%d]"), MyRect.X, MyRect.Y, MyRect.Width, MyRect.Height ); } -DrawButton::DrawButton ( int id, RECT button_rect, const char *normal, const char *focus, const char *pressed, const wchar_t *string, TTFontClass *fontptr ) +DrawButton::DrawButton ( int id, RECT button_rect, const char* normal, const char* focus, const char* pressed, const WideChar* string, TTFontClass* fontptr ) { Id = id; diff --git a/Core/Tools/Autorun/DrawButton.h b/Core/Tools/Autorun/DrawButton.h index faf44d347fb..a0ed5af9d6e 100644 --- a/Core/Tools/Autorun/DrawButton.h +++ b/Core/Tools/Autorun/DrawButton.h @@ -33,6 +33,8 @@ #pragma once +#include "Lib/WideChar.h" + #include #include #include "TTFont.h" @@ -52,7 +54,7 @@ class DrawButton }; DrawButton ( int id, RECT button_rect, const char *normal, const char *focus, const char *pressed, const char *string, TTFontClass *fontptr ); - DrawButton ( int id, RECT button_rect, const char *normal, const char *focus, const char *pressed, const wchar_t *string, TTFontClass *fontptr ); + DrawButton ( int id, RECT button_rect, const char* normal, const char* focus, const char* pressed, const WideChar* string, TTFontClass* fontptr ); char *Return_Normal_Bitmap () { return NormalBitmap; }; char *Return_Pressed_Bitmap () { return PressedBitmap; }; @@ -76,7 +78,11 @@ class DrawButton void Return_Area ( Rect *area ); void Return_Text_Area ( Rect *area ); TTFontClass *Return_Font_Ptr () { return( MyFontPtr ); }; - wchar_t *Return_Text () { return( String ); }; + WideChar* Return_Text() + { + return( String ); + }; + void Set_State ( BUTTON_STATE state ) { ButtonState = state; }; int Set_Stretched_Width ( int ); int Set_Stretched_Height ( int ); @@ -93,7 +99,7 @@ class DrawButton bool UseBitmaps; TTFontClass *MyFontPtr; - wchar_t String[ MAX_PATH ]; + WideChar String[ MAX_PATH ]; char NormalBitmap [ _MAX_FNAME ]; char PressedBitmap[ _MAX_FNAME ]; char FocusBitmap [ _MAX_FNAME ]; diff --git a/Core/Tools/Autorun/GameText.cpp b/Core/Tools/Autorun/GameText.cpp index 695bb18fa3a..4bd4c7f2d40 100644 --- a/Core/Tools/Autorun/GameText.cpp +++ b/Core/Tools/Autorun/GameText.cpp @@ -38,6 +38,7 @@ //---------------------------------------------------------------------------- #include +#include "Lib/WideChar.h" #include #include #include @@ -90,7 +91,7 @@ struct StringInfo { std::string label; - std::wstring text; + std::basic_string text; std::string speech; }; @@ -122,7 +123,7 @@ struct CSFHeader struct NoString { struct NoString *next; - std::wstring text; + std::basic_string text; }; @@ -142,7 +143,7 @@ class GameTextManager : public GameTextInterface virtual void update() {}; ///< update text manager virtual void reset(); ///< Resets the text system - virtual const wchar_t * fetch( const Char *label ); ///< Returns the associated labeled unicode text + virtual const WideChar* fetch( const Char* label ); ///< Returns the associated labeled unicode text protected: Int m_textCount; @@ -159,7 +160,7 @@ class GameTextManager : public GameTextInterface Bool m_munkee; NoString *m_noStringList; Int m_useStringFile; - std::wstring m_failed; + std::basic_string m_failed; void stripSpaces ( WideChar *string ); void removeLeadingAndTrailing ( Char *m_buffer ); @@ -1045,7 +1046,7 @@ Bool GameTextManager::parseStringFile( char *filename ) // *GameTextManager::fetch //============================================================================ -const wchar_t * GameTextManager::fetch( const Char *label ) +const WideChar* GameTextManager::fetch( const Char* label ) { DEBUG_ASSERTCRASH ( m_initialized, ("String Manager has not been m_initialized") ); @@ -1066,9 +1067,9 @@ const wchar_t * GameTextManager::fetch( const Char *label ) if( lookUp == nullptr ) { // See if we already have the missing string - wchar_t tmp[256]; + WideChar tmp[256]; swprintf(tmp, 256, L"MISSING: '%hs'", label); - std::wstring missingString = tmp; + std::basic_string missingString = tmp; NoString *noString = m_noStringList; diff --git a/Core/Tools/Autorun/GameText.h b/Core/Tools/Autorun/GameText.h index 1f23232a51e..f9b62257fde 100644 --- a/Core/Tools/Autorun/GameText.h +++ b/Core/Tools/Autorun/GameText.h @@ -35,6 +35,8 @@ #pragma once +#include "Lib/WideChar.h" + //---------------------------------------------------------------------------- // Includes //---------------------------------------------------------------------------- @@ -62,7 +64,7 @@ class GameTextInterface virtual ~GameTextInterface() {}; virtual void init() = 0; ///< Initlaizes the text system - virtual const wchar_t * fetch( const char *label ) = 0; ///< Returns the associated labeled unicode text + virtual const WideChar* fetch( const char* label ) = 0; ///< Returns the associated labeled unicode text }; diff --git a/Core/Tools/Autorun/Locale_API.cpp b/Core/Tools/Autorun/Locale_API.cpp index 8312b6b43b1..3abe48f1578 100644 --- a/Core/Tools/Autorun/Locale_API.cpp +++ b/Core/Tools/Autorun/Locale_API.cpp @@ -35,6 +35,7 @@ *****************************************************************************/ #include "locale.h" +#include "Lib/WideChar.h" #include "Locale_API.h" #include "Utils.h" #include "Wnd_File.h" @@ -44,7 +45,7 @@ #define MISSING_STRING_HINTS_MAX (20) -const wchar_t *localeStringsMissing[ MISSING_STRING_HINTS_MAX ] = +const WideChar* localeStringsMissing[ MISSING_STRING_HINTS_MAX ] = { { L"0 MissingInstall" }, { L"1 MissingExplore" }, @@ -104,7 +105,7 @@ int SubLanguage = SUBLANG_DEFAULT; /****************************************************************************/ /* LOCALE API */ /****************************************************************************/ -wchar_t * Remove_Quotes_Around_String ( wchar_t *old_string ); +WideChar* Remove_Quotes_Around_String ( WideChar* old_string ); //============================================================================= @@ -309,15 +310,15 @@ void Locale_Restore () const char* Locale_GetString( int StringID, char *String ) { static char buffer[ _MAX_PATH ]; - static wchar_t wide_buffer[ _MAX_PATH ]; + static WideChar wide_buffer[ _MAX_PATH ]; memset( buffer, '\0', _MAX_PATH ); memset( wide_buffer, '\0', _MAX_PATH ); #if( USE_MULTI_FILE_FORMAT ) - wcscpy( wide_buffer, (wchar_t *)LOCALE_getstring( StringID )); + wcscpy( wide_buffer, (WideChar*)LOCALE_getstring( StringID )); #else - wcscpy( wide_buffer, (wchar_t *)LOCALE_getstr( LocaleFile, StringID )); + wcscpy( wide_buffer, (WideChar*)LOCALE_getstr( LocaleFile, StringID )); #endif Remove_Quotes_Around_String( wide_buffer ); @@ -330,11 +331,11 @@ const char* Locale_GetString( int StringID, char *String ) return buffer; } -const wchar_t* Locale_GetString( const char *id, wchar_t *buffer, int size ) +const WideChar* Locale_GetString( const char* id, WideChar* buffer, int size ) { if (TheGameText) { - const wchar_t *fetched = TheGameText->fetch(id); + const WideChar* fetched = TheGameText->fetch(id); if (buffer) { wcsncpy(buffer, fetched, size); @@ -346,20 +347,20 @@ const wchar_t* Locale_GetString( const char *id, wchar_t *buffer, int size ) } /* -const wchar_t* Locale_GetString( int StringID, wchar_t *String ) +const WideChar* Locale_GetString( int StringID, WideChar* String ) { - static wchar_t wide_buffer[ _MAX_PATH ]; + static WideChar wide_buffer[ _MAX_PATH ]; memset( wide_buffer, '\0', _MAX_PATH ); #if( USE_MULTI_FILE_FORMAT ) - wcscpy( wide_buffer, (wchar_t *)LOCALE_getstring( StringID )); + wcscpy( wide_buffer, (WideChar*)LOCALE_getstring( StringID )); #else - wchar_t *localeStr = nullptr; + WideChar* localeStr = nullptr; if (TheGameText != nullptr) - localeStr = (wchar_t *)TheGameText->fetch( s_stringLabels[StringID] ); + localeStr = (WideChar*)TheGameText->fetch( s_stringLabels[StringID] ); if (localeStr == nullptr) { @@ -385,10 +386,10 @@ const wchar_t* Locale_GetString( int StringID, wchar_t *String ) /* formating strings */ /****************************************************************************/ -wchar_t *Remove_Quotes_Around_String ( wchar_t *old_string ) +WideChar* Remove_Quotes_Around_String ( WideChar* old_string ) { - wchar_t wide_buffer[ _MAX_PATH ]; - wchar_t *letter = old_string; + WideChar wide_buffer[ _MAX_PATH ]; + WideChar* letter = old_string; int length; //---------------------------------------------------------------------- diff --git a/Core/Tools/Autorun/Locale_API.h b/Core/Tools/Autorun/Locale_API.h index e5670c1f2bb..da7aaa81ebe 100644 --- a/Core/Tools/Autorun/Locale_API.h +++ b/Core/Tools/Autorun/Locale_API.h @@ -36,6 +36,8 @@ #pragma once +#include "Lib/WideChar.h" + #include /****************************************************************************/ @@ -53,10 +55,10 @@ extern int SubLanguage; /****************************************************************************/ 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 ); +const WideChar* Locale_GetString( const char* id, WideChar* buffer = nullptr, int size = _MAX_PATH ); /* const char* Locale_GetString ( int StringID, char *String ); -const wchar_t* Locale_GetString ( int StringID, wchar_t *String=nullptr ); +const WideChar* Locale_GetString ( int StringID, WideChar* String=nullptr ); */ bool Locale_Use_Multi_Language_Files (); //int Locale_Get_Language_ID () { return LanguageID; }; diff --git a/Core/Tools/Autorun/TTFont.cpp b/Core/Tools/Autorun/TTFont.cpp index b1976282685..8ad40c0dd8f 100644 --- a/Core/Tools/Autorun/TTFont.cpp +++ b/Core/Tools/Autorun/TTFont.cpp @@ -48,6 +48,7 @@ #define STRICT #include +#include "Lib/WideChar.h" #include #include #include @@ -663,7 +664,7 @@ int TTFontClass::Set_YSpacing( int y ) Point2D TTFontClass::Print( HDC hdc, - wchar_t const * string, + const WideChar* string, Rect const & cliprect, COLORREF forecolor, /* = TEXT_COLOR, */ COLORREF backcolor, /* = TEXT_SHADOW_COLOR, */ @@ -683,7 +684,7 @@ Point2D TTFontClass::Print( Point2D TTFontClass::Print( HDC hdc, - wchar_t const * string, + const WideChar* string, Rect const & cliprect, COLORREF forecolor, /* = TEXT_COLOR, */ COLORREF backcolor, /* = TEXT_SHADOW_COLOR, */ diff --git a/Core/Tools/Autorun/TTFont.h b/Core/Tools/Autorun/TTFont.h index 43823a27c5c..a96866d9243 100644 --- a/Core/Tools/Autorun/TTFont.h +++ b/Core/Tools/Autorun/TTFont.h @@ -38,6 +38,8 @@ #pragma once +#include "Lib/WideChar.h" + #include #include "POINT.h" #include "RECT.h" @@ -235,7 +237,7 @@ class TTFontClass virtual Point2D Print( HDC hdc, - wchar_t const * string, + const WideChar* string, Rect const & cliprect, COLORREF forecolor = TEXT_COLOR, COLORREF backcolor = TEXT_NORMAL_SHADOW_COLOR, diff --git a/Core/Tools/Autorun/Utils.cpp b/Core/Tools/Autorun/Utils.cpp index 565449b0f96..1f98c44e6e5 100644 --- a/Core/Tools/Autorun/Utils.cpp +++ b/Core/Tools/Autorun/Utils.cpp @@ -69,6 +69,7 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ #include +#include "Lib/WideChar.h" #include "ARGS.h" #include "assert.h" #include "Locale_API.h" @@ -131,11 +132,11 @@ void Fix_Single_Ampersands ( LPSTR pszString, bool upper_case ) strcpy((LPSTR)pszString, (LPSTR)pszTemp ); } -void Fix_Single_Ampersands ( wchar_t *pszString, bool upper_case ) +void Fix_Single_Ampersands ( WideChar* pszString, bool upper_case ) { - wchar_t pszTemp[ MAX_PATH ]; // variable to hold the string passed - wchar_t pszOld[ MAX_PATH ]; // variable to hold the string passed - wchar_t *letter; + WideChar pszTemp[ MAX_PATH ]; // variable to hold the string passed + WideChar pszOld[ MAX_PATH ]; // variable to hold the string passed + WideChar* letter; int i = 0; wcscpy( pszOld, pszString ); @@ -358,13 +359,13 @@ char *Make_Current_Path_To ( const char *filename, char *path ) return( path ); } -wchar_t *Make_Current_Path_To ( const wchar_t *filename, wchar_t *path ) +WideChar* Make_Current_Path_To ( const WideChar* filename, WideChar* path ) { - wchar_t szPath [ _MAX_PATH ]; - wchar_t drive [ _MAX_DRIVE]; - wchar_t dir [ _MAX_DIR ]; + WideChar szPath [ _MAX_PATH ]; + WideChar drive [ _MAX_DRIVE]; + WideChar dir [ _MAX_DIR ]; - wcscpy( szPath, (wchar_t *)Args->Get_argv(0)); + wcscpy( szPath, (WideChar*)Args->Get_argv(0)); _wsplitpath( szPath, drive, dir, nullptr, nullptr ); _wmakepath( szPath, drive, dir, nullptr, nullptr ); Path_Add_Back_Slash( szPath ); @@ -400,7 +401,7 @@ char *Path_Add_Back_Slash ( char *path ) return( path ); } -wchar_t *Path_Add_Back_Slash ( wchar_t *path ) +WideChar* Path_Add_Back_Slash ( WideChar* path ) { if ( path != nullptr && *path != '\0' ) { if ( path[ wcslen( path )-1 ] != '\\' ) { @@ -434,7 +435,7 @@ char *Path_Remove_Back_Slash ( char *path ) return( path ); } -wchar_t *Path_Remove_Back_Slash ( wchar_t *path ) +WideChar* Path_Remove_Back_Slash ( WideChar* path ) { if ( path != nullptr && *path != '\0' ) { if ( path[ wcslen( path )-1 ] == L'\\' ) { @@ -602,14 +603,14 @@ void PlugInProductName( char *szString, int nName ) /* */ /*--------------------------------------------------------------------------*/ -void PlugInProductName ( wchar_t *szString, const wchar_t *szName ) +void PlugInProductName ( WideChar* szString, const WideChar* szName ) { int nCount, nMsgLength; - wchar_t szTextBuf[ MAX_PATH ]; - wchar_t szOut[ MAX_PATH ]; - wchar_t szProduct[ MAX_PATH ]; - wchar_t *temp = nullptr; - wchar_t *next = nullptr; + WideChar szTextBuf[ MAX_PATH ]; + WideChar szOut[ MAX_PATH ]; + WideChar szProduct[ MAX_PATH ]; + WideChar* temp = nullptr; + WideChar* next = nullptr; if ( szName == nullptr || szName[0] == '\0' ) { return; diff --git a/Core/Tools/Autorun/Utils.h b/Core/Tools/Autorun/Utils.h index 894a7e43606..4ad449769c7 100644 --- a/Core/Tools/Autorun/Utils.h +++ b/Core/Tools/Autorun/Utils.h @@ -36,6 +36,8 @@ #pragma once +#include "Lib/WideChar.h" + #include @@ -54,17 +56,17 @@ void swap( T & left, T & right ) void Fix_Single_Ampersands ( LPSTR pszString, bool upper_case ); -void Fix_Single_Ampersands ( wchar_t *pszString, bool upper_case ); +void Fix_Single_Ampersands ( WideChar* pszString, bool upper_case ); //UnicodeString Fix_Single_Ampersands ( UnicodeString string, bool upper_case); void Fix_Double_Ampersands ( LPSTR string, bool upper_case ); void * Load_Alloc_Data ( char *filename, long *filesize=0 ); void * Load_File ( char *filename, long *filesize=0 ); char * Make_Current_Path_To ( const char *filename, char *path ); -wchar_t * Make_Current_Path_To ( const wchar_t *filename, wchar_t *path ); +WideChar* Make_Current_Path_To ( const WideChar* filename, WideChar* path ); char * Path_Add_Back_Slash ( char *path ); char * Path_Remove_Back_Slash ( char *path ); -wchar_t * Path_Add_Back_Slash ( wchar_t *path ); -wchar_t * Path_Remove_Back_Slash ( wchar_t *path ); +WideChar* Path_Add_Back_Slash ( WideChar* path ); +WideChar* Path_Remove_Back_Slash ( WideChar* path ); void PlugInProductName ( char *szString, int nName ); void PlugInProductName ( char *szString, char *szName ); -void PlugInProductName ( wchar_t *szString, const wchar_t *szName ); +void PlugInProductName ( WideChar* szString, const WideChar* szName ); diff --git a/Core/Tools/Autorun/Wnd_File.h b/Core/Tools/Autorun/Wnd_File.h index 5e4ece6d874..1b6879b6db3 100644 --- a/Core/Tools/Autorun/Wnd_File.h +++ b/Core/Tools/Autorun/Wnd_File.h @@ -41,6 +41,8 @@ #pragma once +#include "Lib/WideChar.h" + //------------------------------------------------------------------------------ // include files... //------------------------------------------------------------------------------ @@ -94,7 +96,7 @@ #ifdef RTS_DEBUG void __cdecl Msg( int line, const char *file, const char *fmt, ... ); -void __cdecl Msg( int line, const char *filename, const wchar_t *fmt, unsigned int codepage=1252, ... ); +void __cdecl Msg( int line, const char* filename, const WideChar* fmt, unsigned int codepage=1252, ... ); void Delete_Msg_File(); #else #define Msg diff --git a/Core/Tools/Autorun/Wnd_file.cpp b/Core/Tools/Autorun/Wnd_file.cpp index fac5af17ef6..ed42d5e6e42 100644 --- a/Core/Tools/Autorun/Wnd_file.cpp +++ b/Core/Tools/Autorun/Wnd_file.cpp @@ -42,6 +42,7 @@ // include files... //----------------------------------------------------------------------------- #include "windows.h" +#include "Lib/WideChar.h" #include #include #include "Wnd_File.h" @@ -170,8 +171,8 @@ void __cdecl Msg( int line, const char *filename, const char *fmt, ... ) * MSG -- Write Message to Debug file with line and filename. * * * * INPUT: int line -- line where message originated. * - * wchar_t *filename -- file where message originated. * - * wchar_t *fmt -- variable argument list. * + * WideChar* filename -- file where message originated. * + * WideChar* fmt -- variable argument list. * * * * OUTPUT: none. * * * @@ -181,13 +182,13 @@ void __cdecl Msg( int line, const char *filename, const char *fmt, ... ) * 08/19/1998 MML : Created. * *==========================================================================*/ -void __cdecl Msg( int line, const char *filename, const wchar_t *fmt, UINT codepage, ... ) +void __cdecl Msg( int line, const char* filename, const WideChar* fmt, UINT codepage, ... ) { - wchar_t szBuffer1[ MAX_PATH * 3 ]; - wchar_t szBuffer2[ MAX_PATH * 3 ]; + WideChar szBuffer1[ MAX_PATH * 3 ]; + WideChar szBuffer2[ MAX_PATH * 3 ]; char szBuffer3[ MAX_PATH * 3 ]; - wchar_t szFile[ MAX_PATH ]; - wchar_t szArgs[ MAX_PATH ]; + WideChar szFile[ MAX_PATH ]; + WideChar szArgs[ MAX_PATH ]; va_list va; int length; DWORD nBytes; diff --git a/Core/Tools/Autorun/autorun.cpp b/Core/Tools/Autorun/autorun.cpp index 5b66de18d54..0e81965777e 100644 --- a/Core/Tools/Autorun/autorun.cpp +++ b/Core/Tools/Autorun/autorun.cpp @@ -70,6 +70,7 @@ #define STRICT #include +#include "Lib/WideChar.h" #include #include #include @@ -221,12 +222,12 @@ char szProduct_Name [ _MAX_PATH ]; #ifdef LEAN_AND_MEAN -wchar_t szWideBuffer [ _MAX_PATH ]; -wchar_t szWideBuffer0 [ _MAX_PATH ]; -wchar_t szWideBuffer2 [ _MAX_PATH ]; -wchar_t szWideBuffer3 [ _MAX_PATH ]; -wchar_t szProductName [ _MAX_PATH ]; -wchar_t szFullProductName [ _MAX_PATH ]; +WideChar szWideBuffer [ _MAX_PATH ]; +WideChar szWideBuffer0 [ _MAX_PATH ]; +WideChar szWideBuffer2 [ _MAX_PATH ]; +WideChar szWideBuffer3 [ _MAX_PATH ]; +WideChar szProductName [ _MAX_PATH ]; +WideChar szFullProductName [ _MAX_PATH ]; /* enum @@ -1231,7 +1232,7 @@ BOOL MainWindow::Is_Product_Registered() BOOL result = FALSE; char key [_MAX_PATH]; - wchar_t szPath [_MAX_PATH]; + WideChar szPath [_MAX_PATH]; char aName [_MAX_PATH]; //jfs unsigned long Type; @@ -2566,9 +2567,9 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param static char szLicense[ _MAX_PATH ]; static char szButtonBitmap[_MAX_PATH]; - static wchar_t szString1[ 500 ]; - static wchar_t szString2[ 500 ]; - static wchar_t szWholeString[ 1000 ]; + static WideChar szString1[ 500 ]; + static WideChar szString2[ 500 ]; + static WideChar szWholeString[ 1000 ]; // static wchar_t szWSMsg1[ _MAX_PATH ]; #ifdef LEAN_AND_MEAN @@ -2577,8 +2578,8 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param static UnicodeString wsMsg1; #endif - static wchar_t szWSMsg2[ _MAX_PATH ]; - static wchar_t szWholeWSMsg[ 1000 ]; + static WideChar szWSMsg2[ _MAX_PATH ]; + static WideChar szWholeWSMsg[ 1000 ]; // static wchar_t szInstallWarningMsg[ _MAX_PATH ]; static HBITMAP hBitmap = 0; @@ -3733,8 +3734,8 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param // } /* if (success == 0) { - std::wstring wideBuffer = TheGameText->fetch("Autorun:CantRunAVIs"); - std::wstring wideBuffer2 = TheGameText->fetch("Autorun:Error"); + std::basic_string wideBuffer = TheGameText->fetch("Autorun:CantRunAVIs"); + std::basic_string wideBuffer2 = TheGameText->fetch("Autorun:Error"); int length = wideBuffer.length(); WideCharToMultiByte( CodePage, 0, wideBuffer.c_str(), length+1, szBuffer, _MAX_PATH, nullptr, nullptr ); length = wideBuffer2.length(); @@ -3747,11 +3748,11 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param case IDD_HELP: { - std::wstring wFileName; + std::basic_string wFileName; wFileName = Locale_GetString(HELP_FILENAME); std::string fname; - const wchar_t *tmp = wFileName.c_str(); + const WideChar* tmp = wFileName.c_str(); char hack[2] = "a"; while (*tmp) { @@ -3778,8 +3779,8 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param /* if (success == 0) { - std::wstring wideBuffer = TheGameText->fetch("Autorun:CantRunHelp"); - std::wstring wideBuffer2 = TheGameText->fetch("Autorun:Error"); + std::basic_string wideBuffer = TheGameText->fetch("Autorun:CantRunHelp"); + std::basic_string wideBuffer2 = TheGameText->fetch("Autorun:Error"); int length = wideBuffer.length(); WideCharToMultiByte( CodePage, 0, wideBuffer.c_str(), length+1, szBuffer, _MAX_PATH, nullptr, nullptr ); length = wideBuffer2.length(); @@ -4804,8 +4805,8 @@ BOOL Valid_Environment () result = WinVersion.Meets_Minimum_Version_Requirements(); if ( !result ) { - std::wstring wideBuffer = TheGameText->fetch("GUI:WindowsVersionText"); - std::wstring wideBuffer2 = TheGameText->fetch("GUI:WindowsVersionTitle"); + std::basic_string wideBuffer = TheGameText->fetch("GUI:WindowsVersionText"); + std::basic_string wideBuffer2 = TheGameText->fetch("GUI:WindowsVersionTitle"); length = wideBuffer.length(); WideCharToMultiByte( CodePage, 0, wideBuffer.c_str(), length+1, szBuffer, _MAX_PATH, nullptr, nullptr ); length = wideBuffer2.length(); @@ -5068,9 +5069,9 @@ void Cant_Find_MessageBox ( HINSTANCE hInstance, const char *szPath ) #else - std::wstring wideBuffer = TheGameText->fetch("Autorun:AutorunTitle"); - std::wstring wideBuffer2.format( wideBuffer.str(), productName.str() ); - std::wstring wideBuffer3 = TheGameText->fetch("Autorun:CantFind"); + std::basic_string wideBuffer = TheGameText->fetch("Autorun:AutorunTitle"); + std::basic_string wideBuffer2.format( wideBuffer.str(), productName.str() ); + std::basic_string wideBuffer3 = TheGameText->fetch("Autorun:CantFind"); WideCharToMultiByte( CodePage, 0, wideBuffer3.str(), wideBuffer3.getLength()+1, szBuffer3, _MAX_PATH, nullptr, nullptr ); WideCharToMultiByte( CodePage, 0, wideBuffer2.str(), wideBuffer2.getLength()+1, szBuffer2, _MAX_PATH, nullptr, nullptr ); diff --git a/Core/Tools/Autorun/locale.cpp b/Core/Tools/Autorun/locale.cpp index e7665813563..c60eed0e359 100644 --- a/Core/Tools/Autorun/locale.cpp +++ b/Core/Tools/Autorun/locale.cpp @@ -19,6 +19,7 @@ /* Copyright (C) Electronic Arts Canada Inc. 1998-1999. All rights reserved. */ #include +#include "Lib/WideChar.h" #include #include "gimex.h" /* for file and memory IO only */ #include "locale.h" @@ -769,7 +770,7 @@ const char* LOCALE_getstring( int StringID ) p = nullptr; } - Msg( __LINE__, __FILE__, L"%s", 1252, (wchar_t *)p ); + Msg( __LINE__, __FILE__, L"%s", 1252, (WideChar*)p ); return p; } diff --git a/Core/Tools/Babylon/transcs.cpp b/Core/Tools/Babylon/transcs.cpp index 67d9f164d2e..875e0e262ee 100644 --- a/Core/Tools/Babylon/transcs.cpp +++ b/Core/Tools/Babylon/transcs.cpp @@ -21,6 +21,7 @@ // #include "StdAfx.h" +#include "Lib/WideChar.h" #include #include #include @@ -32,8 +33,8 @@ void CreateTranslationTable () { int i; FILE *out; - wchar_t wc; - wchar_t mb; + WideChar wc; + WideChar mb; DWORD last_error; if ( ( out = fopen ( "utable.c", "wt" )) == nullptr) diff --git a/Core/Tools/Launcher/Toolkit/Support/UTypes.h b/Core/Tools/Launcher/Toolkit/Support/UTypes.h index f0a727c84cd..1af9b036ffc 100644 --- a/Core/Tools/Launcher/Toolkit/Support/UTypes.h +++ b/Core/Tools/Launcher/Toolkit/Support/UTypes.h @@ -36,6 +36,8 @@ #pragma once +#include "Lib/WideChar.h" + //! Signed integer value typedef int Int; @@ -67,11 +69,7 @@ typedef char Char; typedef unsigned char UChar; //! Wide character (Unicode) -#if defined(_MSC_VER) && _MSC_VER < 1300 -typedef unsigned short WChar; -#else -typedef wchar_t WChar; -#endif +typedef WideChar WChar; //! 32bit floating point value typedef float Float32; diff --git a/Dependencies/Utility/CMakeLists.txt b/Dependencies/Utility/CMakeLists.txt index 8f77d663e47..32bd79cf728 100644 --- a/Dependencies/Utility/CMakeLists.txt +++ b/Dependencies/Utility/CMakeLists.txt @@ -24,6 +24,7 @@ set(UTILITY_SRC Utility/time_compat.h Utility/utility_adapter.h Utility/wchar_compat.h + Utility/WideChar.h ) ## core_utility diff --git a/Dependencies/Utility/Utility/WideChar.h b/Dependencies/Utility/Utility/WideChar.h new file mode 100644 index 00000000000..8c1474b2fa2 --- /dev/null +++ b/Dependencies/Utility/Utility/WideChar.h @@ -0,0 +1,24 @@ +/* +** Copyright 2026 TheSuperHackers +** +** This program is free software: you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation, either version 3 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program. If not, see . +*/ + +#pragma once + +#include + +// Shared project wide-character type, currently using the native representation. +// Changing it also requires adapting wide literals, character traits, and CRT/platform APIs. +typedef wchar_t WideChar; diff --git a/Dependencies/Utility/Utility/stringex.h b/Dependencies/Utility/Utility/stringex.h index c54de55fc57..30ca4c26146 100644 --- a/Dependencies/Utility/Utility/stringex.h +++ b/Dependencies/Utility/Utility/stringex.h @@ -18,10 +18,10 @@ #pragma once +#include "Utility/WideChar.h" #include #include - // Declaration template size_t strlen_t(const T *str); @@ -29,7 +29,7 @@ template size_t strnlen_t(const T *str, size_t maxlen); #if defined(_MSC_VER) && _MSC_VER < 1300 size_t strnlen(const char *str, size_t maxlen); -size_t wcsnlen(const wchar_t *str, size_t maxlen); +size_t wcsnlen(const WideChar* str, size_t maxlen); #endif template size_t strlcpy_t(T *dst, const T *src, size_t dstsize); @@ -37,16 +37,16 @@ template size_t strlcat_t(T *dst, const T *src, size_t dstsize); size_t strlcpy(char *dst, const char *src, size_t dstsize); size_t strlcat(char *dst, const char *src, size_t dstsize); -size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t dstsize); -size_t wcslcat(wchar_t *dst, const wchar_t *src, size_t dstsize); +size_t wcslcpy(WideChar* dst, const WideChar* src, size_t dstsize); +size_t wcslcat(WideChar* dst, const WideChar* src, size_t dstsize); template size_t strlmove_t(T *dst, const T *src, size_t dstsize); template size_t strlmcat_t(T *dst, const T *src, size_t dstsize); size_t strlmove(char *dst, const char *src, size_t dstsize); size_t strlmcat(char *dst, const char *src, size_t dstsize); -size_t wcslmove(wchar_t *dst, const wchar_t *src, size_t dstsize); -size_t wcslmcat(wchar_t *dst, const wchar_t *src, size_t dstsize); +size_t wcslmove(WideChar* dst, const WideChar* src, size_t dstsize); +size_t wcslmcat(WideChar* dst, const WideChar* src, size_t dstsize); #if !(defined(_MSC_VER) && _MSC_VER < 1300) template size_t strlcpy_t(char (&dst)[Size], const char *src); @@ -63,7 +63,6 @@ template bool startsWithNoCase(const T *str, const T *prefix); template bool endsWithNoCase(const T *str, const T *suffix); template bool endsWithNoCase(const T *str, const T *suffix); - // Implementation // Templated strlen. @@ -89,7 +88,11 @@ template size_t strnlen_t(const T *str, size_t maxlen) #if defined(_MSC_VER) && _MSC_VER < 1300 inline size_t strnlen(const char *str, size_t maxlen) { return strnlen_t(str, maxlen); } -inline size_t wcsnlen(const wchar_t *str, size_t maxlen) { return strnlen_t(str, maxlen); } +inline size_t wcsnlen(const WideChar* str, size_t maxlen) +{ + return strnlen_t(str, maxlen); +} + #endif // Templated strlcpy. Prefer using this over strncpy. @@ -137,8 +140,15 @@ inline size_t strlcpy(char *dst, const char *src, size_t dstsize) { return strlc #ifndef HAVE_STRLCAT inline size_t strlcat(char *dst, const char *src, size_t dstsize) { return strlcat_t(dst, src, dstsize); } #endif -inline size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t dstsize) { return strlcpy_t(dst, src, dstsize); } -inline size_t wcslcat(wchar_t *dst, const wchar_t *src, size_t dstsize) { return strlcat_t(dst, src, dstsize); } +inline size_t wcslcpy(WideChar* dst, const WideChar* src, size_t dstsize) +{ + return strlcpy_t(dst, src, dstsize); +} + +inline size_t wcslcat(WideChar* dst, const WideChar* src, size_t dstsize) +{ + return strlcat_t(dst, src, dstsize); +} // Templated strlmove. Prefer using this over strlcpy if dst and src overlap. // Moves src into dst until dstsize minus one. Always null terminates. @@ -181,8 +191,15 @@ template size_t strlmcat_t(T *dst, const T *src, size_t dstsize) inline size_t strlmove(char *dst, const char *src, size_t dstsize) { return strlmove_t(dst, src, dstsize); } inline size_t strlmcat(char *dst, const char *src, size_t dstsize) { return strlmcat_t(dst, src, dstsize); } -inline size_t wcslmove(wchar_t *dst, const wchar_t *src, size_t dstsize) { return strlmove_t(dst, src, dstsize); } -inline size_t wcslmcat(wchar_t *dst, const wchar_t *src, size_t dstsize) { return strlmcat_t(dst, src, dstsize); } +inline size_t wcslmove(WideChar* dst, const WideChar* src, size_t dstsize) +{ + return strlmove_t(dst, src, dstsize); +} + +inline size_t wcslmcat(WideChar* dst, const WideChar* src, size_t dstsize) +{ + return strlmcat_t(dst, src, dstsize); +} #if !(defined(_MSC_VER) && _MSC_VER < 1300) template size_t strlcpy_t(char (&dst)[Size], const char *src) { return strlcpy_t(dst, src, Size); } @@ -220,9 +237,9 @@ inline char tolower_t(char c) return (char)tolower((unsigned char)c); } -inline wchar_t tolower_t(wchar_t c) +inline WideChar tolower_t(WideChar c) { - return (wchar_t)towlower(c); + return (WideChar)towlower(c); } // Templated strnicmp. diff --git a/Generals/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp b/Generals/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp index e89d086c98e..326033d3ca2 100644 --- a/Generals/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp +++ b/Generals/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp @@ -29,6 +29,7 @@ // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "PreRTS.h" +#include "Lib/WideChar.h" #include "Common/file.h" #include "Common/FileSystem.h" #include "Common/GameEngine.h" @@ -226,7 +227,7 @@ UnicodeString getUnicodeDateBuffer(SYSTEMTIME timeVal) return displayDateBuffer; } } - wchar_t dateBuffer[ DATE_BUFFER_SIZE ]; + WideChar dateBuffer[ DATE_BUFFER_SIZE ]; GetDateFormatW( LOCALE_USER_DEFAULT, DATE_SHORTDATE, &timeVal, @@ -259,7 +260,7 @@ UnicodeString getUnicodeTimeBuffer(SYSTEMTIME timeVal) } // setup time buffer for local region time format #define TIME_BUFFER_SIZE 256 - wchar_t timeBuffer[ TIME_BUFFER_SIZE ]; + WideChar timeBuffer[ TIME_BUFFER_SIZE ]; GetTimeFormatW( LOCALE_USER_DEFAULT, TIME_NOSECONDS, &timeVal, diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupReplay.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupReplay.cpp index fbce261d6a1..95a305c5128 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupReplay.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupReplay.cpp @@ -46,6 +46,7 @@ // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine +#include "Lib/WideChar.h" #include "Common/LocalFileSystem.h" #include "Common/MessageStream.h" @@ -282,7 +283,7 @@ void reallySaveReplay() { if(DeleteFile(filename.str()) == 0) { - wchar_t buffer[1024]; + WideChar buffer[1024]; FormatMessageW ( FORMAT_MESSAGE_FROM_SYSTEM, nullptr, GetLastError(), 0, buffer, ARRAY_SIZE(buffer), nullptr); UnicodeString errorStr; errorStr.set(buffer); @@ -307,7 +308,7 @@ void reallySaveReplay() // copy the replay to the right place if(CopyFile(oldFilename.str(),filename.str(), FALSE) == 0) { - wchar_t buffer[1024]; + WideChar buffer[1024]; FormatMessageW( FORMAT_MESSAGE_FROM_SYSTEM, nullptr, GetLastError(), 0, buffer, ARRAY_SIZE(buffer), nullptr); UnicodeString errorStr; errorStr.set(buffer); diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp index 683d9a242f0..9f3baae5d23 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp @@ -29,6 +29,7 @@ // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine +#include "Lib/WideChar.h" #include "Common/FileSystem.h" @@ -859,7 +860,7 @@ void copyReplay() newFilename.concat(translate); if(CopyFile(filename.str(),newFilename.str(), FALSE) == 0) { - wchar_t buffer[1024]; + WideChar buffer[1024]; FormatMessageW( FORMAT_MESSAGE_FROM_SYSTEM, nullptr, GetLastError(), 0, buffer, ARRAY_SIZE(buffer), nullptr); UnicodeString errorStr; errorStr.set(buffer); diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp index ab1029c812c..e32c12fbd66 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp @@ -29,6 +29,7 @@ // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "PreRTS.h" +#include "Lib/WideChar.h" #include "Common/file.h" #include "Common/FileSystem.h" #include "Common/GameEngine.h" @@ -226,7 +227,7 @@ UnicodeString getUnicodeDateBuffer(SYSTEMTIME timeVal) return displayDateBuffer; } } - wchar_t dateBuffer[ DATE_BUFFER_SIZE ]; + WideChar dateBuffer[ DATE_BUFFER_SIZE ]; GetDateFormatW( LOCALE_USER_DEFAULT, DATE_SHORTDATE, &timeVal, @@ -259,7 +260,7 @@ UnicodeString getUnicodeTimeBuffer(SYSTEMTIME timeVal) } // setup time buffer for local region time format #define TIME_BUFFER_SIZE 256 - wchar_t timeBuffer[ TIME_BUFFER_SIZE ]; + WideChar timeBuffer[ TIME_BUFFER_SIZE ]; GetTimeFormatW( LOCALE_USER_DEFAULT, TIME_NOSECONDS, &timeVal, diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupReplay.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupReplay.cpp index 1a05b46332c..8c288dc012a 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupReplay.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupReplay.cpp @@ -46,6 +46,7 @@ // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine +#include "Lib/WideChar.h" #include "Common/LocalFileSystem.h" #include "Common/MessageStream.h" @@ -282,7 +283,7 @@ void reallySaveReplay() { if(DeleteFile(filename.str()) == 0) { - wchar_t buffer[1024]; + WideChar buffer[1024]; FormatMessageW ( FORMAT_MESSAGE_FROM_SYSTEM, nullptr, GetLastError(), 0, buffer, ARRAY_SIZE(buffer), nullptr); UnicodeString errorStr; errorStr.set(buffer); @@ -307,7 +308,7 @@ void reallySaveReplay() // copy the replay to the right place if(CopyFile(oldFilename.str(),filename.str(), FALSE) == 0) { - wchar_t buffer[1024]; + WideChar buffer[1024]; FormatMessageW( FORMAT_MESSAGE_FROM_SYSTEM, nullptr, GetLastError(), 0, buffer, ARRAY_SIZE(buffer), nullptr); UnicodeString errorStr; errorStr.set(buffer); diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp index 8ba96a24e0e..34f316d97dd 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp @@ -29,6 +29,7 @@ // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine +#include "Lib/WideChar.h" #include "Common/FileSystem.h" @@ -859,7 +860,7 @@ void copyReplay() newFilename.concat(translate); if(CopyFile(filename.str(),newFilename.str(), FALSE) == 0) { - wchar_t buffer[1024]; + WideChar buffer[1024]; FormatMessageW( FORMAT_MESSAGE_FROM_SYSTEM, nullptr, GetLastError(), 0, buffer, ARRAY_SIZE(buffer), nullptr); UnicodeString errorStr; errorStr.set(buffer); diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/playerlistdlg.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/playerlistdlg.cpp index ec228afedaa..7b50cc46548 100644 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/playerlistdlg.cpp +++ b/GeneralsMD/Code/Tools/WorldBuilder/src/playerlistdlg.cpp @@ -20,6 +20,7 @@ // #include "StdAfx.h" +#include "Lib/WideChar.h" #include "WorldBuilder.h" #include "playerlistdlg.h" #include "mapobjectprops.h" @@ -845,7 +846,7 @@ void PlayerListDlg::OnChangePlayerdisplayname() } static void addSide(SidesList *sides, AsciiString faction, - AsciiString playerName, const wchar_t *playerUName) + AsciiString playerName, const WideChar* playerUName) { if (!sides->findSideInfo(playerName)) { From 4e3ceae90587466b202e4685549a0be2a27d1251 Mon Sep 17 00:00:00 2001 From: Jacob Ledbetter Date: Sun, 20 Sep 2026 14:24:44 -0600 Subject: [PATCH 2/6] refactor: share wide-character types through utility headers --- .../Include/GameNetwork/GameSpy/PeerThread.h | 9 ++++---- .../Include/GameNetwork/GameSpy/ThreadUtils.h | 5 ++-- .../Source/GameClient/LanguageFilter.cpp | 1 - .../GameSpy/Thread/BuddyThread.cpp | 7 +++--- .../GameNetwork/GameSpy/Thread/PeerThread.cpp | 7 +++--- .../GameSpy/Thread/ThreadUtils.cpp | 9 ++++---- Core/Libraries/Include/CMakeLists.txt | 1 - Core/Libraries/Include/Lib/PathUtil.h | 2 -- .../Precompiled/Precompiled/BaseTypes.h | 2 +- Core/Libraries/Source/WWVegas/WWLib/INI.h | 2 -- .../Libraries/Source/WWVegas/WWLib/WWCommon.h | 2 ++ Core/Libraries/Source/WWVegas/WWLib/ini.cpp | 1 - .../Source/WWVegas/WWLib/readline.cpp | 1 - .../Libraries/Source/WWVegas/WWLib/readline.h | 2 -- Core/Libraries/Source/WWVegas/WWLib/trim.cpp | 1 - Core/Libraries/Source/WWVegas/WWLib/trim.h | 2 -- Core/Libraries/Source/WWVegas/WWLib/utf8.cpp | 1 - Core/Libraries/Source/WWVegas/WWLib/utf8.h | 2 -- Core/Tools/Autorun/DrawButton.cpp | 1 - Core/Tools/Autorun/DrawButton.h | 2 -- Core/Tools/Autorun/GameText.cpp | 11 ++++----- Core/Tools/Autorun/GameText.h | 2 -- Core/Tools/Autorun/Locale_API.cpp | 1 - Core/Tools/Autorun/Locale_API.h | 2 -- Core/Tools/Autorun/TTFont.cpp | 1 - Core/Tools/Autorun/TTFont.h | 2 -- Core/Tools/Autorun/Utils.cpp | 1 - Core/Tools/Autorun/Utils.h | 2 -- Core/Tools/Autorun/Wnd_File.h | 2 -- Core/Tools/Autorun/Wnd_file.cpp | 1 - Core/Tools/Autorun/autorun.cpp | 23 +++++++++---------- Core/Tools/Autorun/locale.cpp | 1 - Core/Tools/Babylon/transcs.cpp | 1 - Core/Tools/Launcher/Toolkit/Support/UTypes.h | 2 -- Dependencies/Utility/CMakeLists.txt | 10 ++++++++ Dependencies/Utility/Utility/WideChar.h | 1 + .../Utility/Utility/string_adapter.h | 7 ++++++ .../Common/System/SaveGame/GameState.cpp | 1 - .../GUI/GUICallbacks/Menus/PopupReplay.cpp | 1 - .../GUI/GUICallbacks/Menus/ReplayMenu.cpp | 1 - .../Common/System/SaveGame/GameState.cpp | 1 - .../GUI/GUICallbacks/Menus/PopupReplay.cpp | 1 - .../GUI/GUICallbacks/Menus/ReplayMenu.cpp | 1 - .../Tools/WorldBuilder/src/playerlistdlg.cpp | 1 - 44 files changed, 53 insertions(+), 84 deletions(-) rename Core/Libraries/Include/Lib/WideChar.h => Dependencies/Utility/Utility/string_adapter.h (85%) diff --git a/Core/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h b/Core/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h index 620f3860cba..3977cb96ab2 100644 --- a/Core/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h @@ -28,8 +28,7 @@ #pragma once -#include "Lib/WideChar.h" -#include +#include #include "gamespy/peer/peer.h" #include "GameNetwork/NetworkDefs.h" @@ -72,7 +71,7 @@ class PeerRequest } peerRequestType; std::string nick; // only used by login, but must be outside the union b/c of copy constructor - std::basic_string text; // can't be in a union + stl::wstring text; // can't be in a union std::string password; std::string email; std::string id; @@ -251,13 +250,13 @@ class PeerResponse std::string nick; // can't be in a union std::string oldNick; // can't be in a union - std::basic_string text; // can't be in a union + stl::wstring text; // can't be in a union std::string locale; // can't be in a union std::string stagingServerGameOptions; // full string from UTMs // game opts sent with PEERRESPONSE_STAGINGROOM - std::basic_string stagingServerName; + stl::wstring stagingServerName; std::string stagingServerPingString; std::string stagingServerLadderIP; std::string stagingRoomMapName; diff --git a/Core/GameEngine/Include/GameNetwork/GameSpy/ThreadUtils.h b/Core/GameEngine/Include/GameNetwork/GameSpy/ThreadUtils.h index d80d3392c73..49c0691b6ee 100644 --- a/Core/GameEngine/Include/GameNetwork/GameSpy/ThreadUtils.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpy/ThreadUtils.h @@ -28,8 +28,7 @@ #pragma once -#include "Lib/WideChar.h" -#include +#include -std::basic_string MultiByteToWideCharSingleLine( const char* orig ); +stl::wstring MultiByteToWideCharSingleLine( const char* orig ); std::string WideCharStringToMultiByte( const WideChar *orig ); diff --git a/Core/GameEngine/Source/GameClient/LanguageFilter.cpp b/Core/GameEngine/Source/GameClient/LanguageFilter.cpp index 0400786e5ba..fc1d11a5cb7 100644 --- a/Core/GameEngine/Source/GameClient/LanguageFilter.cpp +++ b/Core/GameEngine/Source/GameClient/LanguageFilter.cpp @@ -24,7 +24,6 @@ #include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine -#include "Lib/WideChar.h" #include "GameClient/LanguageFilter.h" #include "Common/FileSystem.h" diff --git a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp index dc697c4823e..b16633e810c 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp @@ -30,8 +30,7 @@ // Author: Matthew D. Campbell, June 2002 #include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine -#include "Lib/WideChar.h" -#include +#include #include "GameNetwork/GameSpy/BuddyThread.h" #include "GameNetwork/GameSpy/PeerThread.h" @@ -519,7 +518,7 @@ void BuddyThreadClass::messageCallback( GPConnection *con, GPRecvBuddyMessageArg // get info about the person asking to be our buddy gpGetInfo( con, arg->profile, GP_CHECK_CACHE, GP_BLOCKING, (GPCallback)getNickForMessage, &messageResponse); - std::basic_string s = MultiByteToWideCharSingleLine( arg->message ); + stl::wstring s = MultiByteToWideCharSingleLine( arg->message ); wcslcpy(messageResponse.arg.message.text, s.c_str(), MAX_BUDDY_CHAT_LEN); messageResponse.arg.message.date = arg->date; DEBUG_LOG(("Got a buddy message from %d [%ls]", arg->profile, s.c_str())); @@ -638,7 +637,7 @@ void BuddyThreadClass::requestCallback( GPConnection *con, GPRecvBuddyRequestArg // get info about the person asking to be our buddy gpGetInfo( con, arg->profile, GP_CHECK_CACHE, GP_BLOCKING, (GPCallback)getInfoResponseForRequest, &response); - std::basic_string s = MultiByteToWideCharSingleLine( arg->reason ); + stl::wstring s = MultiByteToWideCharSingleLine( arg->reason ); wcslcpy(response.arg.request.text, s.c_str(), GP_REASON_LEN); TheGameSpyBuddyMessageQueue->addResponse( response ); diff --git a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PeerThread.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PeerThread.cpp index 0f1e12b77ce..48c5b443848 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PeerThread.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PeerThread.cpp @@ -30,8 +30,7 @@ // Author: Matthew D. Campbell, June 2002 #include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine -#include "Lib/WideChar.h" -#include +#include #include "Common/Registry.h" #include "Common/OptionPreferences.h" @@ -234,7 +233,7 @@ class PeerThreadClass : public ThreadClass UnsignedInt exeCRC() { return m_exeCRC; } UnsignedInt iniCRC() { return m_iniCRC; } UnsignedInt gameVersion() { return m_gameVersion; } - std::basic_string getLocalStagingServerName() + stl::wstring getLocalStagingServerName() { return m_localStagingServerName; } @@ -320,7 +319,7 @@ class PeerThreadClass : public ThreadClass Int m_nextStagingServer; std::map m_stagingServers; - std::basic_string m_localStagingServerName; + stl::wstring m_localStagingServerName; Int m_localRoomID; void doQuickMatch( PEER peer ); diff --git a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp index c327c22c6a2..05d32c5b8aa 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp @@ -27,24 +27,23 @@ // Author: Matthew D. Campbell, July 2002 #include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine -#include "Lib/WideChar.h" -#include +#include #include "WWLib/utf8.h" //------------------------------------------------------------------------- // TheSuperHackers @refactor bobtista 02/04/2026 Use WWLib UTF-8 functions instead of raw Win32 API calls -std::basic_string MultiByteToWideCharSingleLine( const char* orig ) +stl::wstring MultiByteToWideCharSingleLine( const char* orig ) { const size_t srcLen = strlen(orig); const size_t dstLen = Utf8_To_Wide_Len(orig, srcLen); if (dstLen == 0) { - return std::basic_string(); + return stl::wstring(); } - std::basic_string ret; + stl::wstring ret; if (dstLen == UTF8_INVALID) { // Not UTF-8. Fall back to a 1:1 byte cast so legacy data keeps its characters, matching diff --git a/Core/Libraries/Include/CMakeLists.txt b/Core/Libraries/Include/CMakeLists.txt index 67cb0c97188..86274a44b28 100644 --- a/Core/Libraries/Include/CMakeLists.txt +++ b/Core/Libraries/Include/CMakeLists.txt @@ -13,7 +13,6 @@ set(LIBRARIES_INCLUDE_SRC Lib/Region3D.h Lib/RGBColor.h Lib/trig.h - Lib/WideChar.h rts/debug.h rts/profile.h Precompiled/Precompiled/BaseAlgorithm.h diff --git a/Core/Libraries/Include/Lib/PathUtil.h b/Core/Libraries/Include/Lib/PathUtil.h index 0822353b4d5..b114ef87c3e 100644 --- a/Core/Libraries/Include/Lib/PathUtil.h +++ b/Core/Libraries/Include/Lib/PathUtil.h @@ -20,8 +20,6 @@ #pragma once -#include "Lib/WideChar.h" - #include "BaseType.h" #include diff --git a/Core/Libraries/Include/Precompiled/Precompiled/BaseTypes.h b/Core/Libraries/Include/Precompiled/Precompiled/BaseTypes.h index e119130f375..5927cedf6f7 100644 --- a/Core/Libraries/Include/Precompiled/Precompiled/BaseTypes.h +++ b/Core/Libraries/Include/Precompiled/Precompiled/BaseTypes.h @@ -17,7 +17,7 @@ #pragma once -#include "Lib/WideChar.h" +#include // Fundamental type definitions diff --git a/Core/Libraries/Source/WWVegas/WWLib/INI.h b/Core/Libraries/Source/WWVegas/WWLib/INI.h index af49dd2b3b6..e06e045a363 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/INI.h +++ b/Core/Libraries/Source/WWVegas/WWLib/INI.h @@ -36,8 +36,6 @@ #pragma once -#include "Lib/WideChar.h" - #include //#include "listnode.h" diff --git a/Core/Libraries/Source/WWVegas/WWLib/WWCommon.h b/Core/Libraries/Source/WWVegas/WWLib/WWCommon.h index e505e9b6bb1..9825dcd0053 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/WWCommon.h +++ b/Core/Libraries/Source/WWVegas/WWLib/WWCommon.h @@ -18,6 +18,8 @@ #pragma once +#include + #include "ref_ptr.h" #include "refcount.h" #include "Utility/STLUtils.h" diff --git a/Core/Libraries/Source/WWVegas/WWLib/ini.cpp b/Core/Libraries/Source/WWVegas/WWLib/ini.cpp index ecb6c2bc69e..e59fdf3342d 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/ini.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/ini.cpp @@ -85,7 +85,6 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "always.h" -#include "Lib/WideChar.h" #include "b64pipe.h" #include "b64straw.h" #include "cstraw.h" diff --git a/Core/Libraries/Source/WWVegas/WWLib/readline.cpp b/Core/Libraries/Source/WWVegas/WWLib/readline.cpp index 0b57130c8fd..943882d4e87 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/readline.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/readline.cpp @@ -38,7 +38,6 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "always.h" -#include "Lib/WideChar.h" #include "readline.h" #include "trim.h" #include "WWFILE.h" diff --git a/Core/Libraries/Source/WWVegas/WWLib/readline.h b/Core/Libraries/Source/WWVegas/WWLib/readline.h index ae51f424254..b48a4fe667a 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/readline.h +++ b/Core/Libraries/Source/WWVegas/WWLib/readline.h @@ -36,8 +36,6 @@ #pragma once -#include "Lib/WideChar.h" - #include "STRAW.h" #include "WWFILE.h" #include diff --git a/Core/Libraries/Source/WWVegas/WWLib/trim.cpp b/Core/Libraries/Source/WWVegas/WWLib/trim.cpp index eb3f87568c8..3a99d366616 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/trim.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/trim.cpp @@ -35,7 +35,6 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "always.h" -#include "Lib/WideChar.h" #include "trim.h" #ifdef _UNIX diff --git a/Core/Libraries/Source/WWVegas/WWLib/trim.h b/Core/Libraries/Source/WWVegas/WWLib/trim.h index 48a60224753..ddd5ff49dc5 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/trim.h +++ b/Core/Libraries/Source/WWVegas/WWLib/trim.h @@ -36,8 +36,6 @@ #pragma once -#include "Lib/WideChar.h" - #include char * strtrim(char * buffer); diff --git a/Core/Libraries/Source/WWVegas/WWLib/utf8.cpp b/Core/Libraries/Source/WWVegas/WWLib/utf8.cpp index b01b35a4271..4b81342d2d4 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/utf8.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/utf8.cpp @@ -17,7 +17,6 @@ */ #include "always.h" -#include "Lib/WideChar.h" #include "utf8.h" // WideChar is a 16-bit UTF-16 code unit on Windows and a 32-bit UTF-32 codepoint on most other diff --git a/Core/Libraries/Source/WWVegas/WWLib/utf8.h b/Core/Libraries/Source/WWVegas/WWLib/utf8.h index bdba2314ad0..b4de2054768 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/utf8.h +++ b/Core/Libraries/Source/WWVegas/WWLib/utf8.h @@ -18,8 +18,6 @@ #pragma once -#include "Lib/WideChar.h" - #include #include diff --git a/Core/Tools/Autorun/DrawButton.cpp b/Core/Tools/Autorun/DrawButton.cpp index 96df1de9332..6de56fc6642 100644 --- a/Core/Tools/Autorun/DrawButton.cpp +++ b/Core/Tools/Autorun/DrawButton.cpp @@ -43,7 +43,6 @@ #define STRICT #include -#include "Lib/WideChar.h" #include #include "autorun.h" #include "DrawButton.h" diff --git a/Core/Tools/Autorun/DrawButton.h b/Core/Tools/Autorun/DrawButton.h index a0ed5af9d6e..6682e31ce24 100644 --- a/Core/Tools/Autorun/DrawButton.h +++ b/Core/Tools/Autorun/DrawButton.h @@ -33,8 +33,6 @@ #pragma once -#include "Lib/WideChar.h" - #include #include #include "TTFont.h" diff --git a/Core/Tools/Autorun/GameText.cpp b/Core/Tools/Autorun/GameText.cpp index 4bd4c7f2d40..0902ea13f82 100644 --- a/Core/Tools/Autorun/GameText.cpp +++ b/Core/Tools/Autorun/GameText.cpp @@ -38,12 +38,11 @@ //---------------------------------------------------------------------------- #include -#include "Lib/WideChar.h" #include #include #include -#include +#include #include #include "GameText.h" @@ -91,7 +90,7 @@ struct StringInfo { std::string label; - std::basic_string text; + stl::wstring text; std::string speech; }; @@ -123,7 +122,7 @@ struct CSFHeader struct NoString { struct NoString *next; - std::basic_string text; + stl::wstring text; }; @@ -160,7 +159,7 @@ class GameTextManager : public GameTextInterface Bool m_munkee; NoString *m_noStringList; Int m_useStringFile; - std::basic_string m_failed; + stl::wstring m_failed; void stripSpaces ( WideChar *string ); void removeLeadingAndTrailing ( Char *m_buffer ); @@ -1069,7 +1068,7 @@ const WideChar* GameTextManager::fetch( const Char* label ) // See if we already have the missing string WideChar tmp[256]; swprintf(tmp, 256, L"MISSING: '%hs'", label); - std::basic_string missingString = tmp; + stl::wstring missingString = tmp; NoString *noString = m_noStringList; diff --git a/Core/Tools/Autorun/GameText.h b/Core/Tools/Autorun/GameText.h index f9b62257fde..4c589268b4f 100644 --- a/Core/Tools/Autorun/GameText.h +++ b/Core/Tools/Autorun/GameText.h @@ -35,8 +35,6 @@ #pragma once -#include "Lib/WideChar.h" - //---------------------------------------------------------------------------- // Includes //---------------------------------------------------------------------------- diff --git a/Core/Tools/Autorun/Locale_API.cpp b/Core/Tools/Autorun/Locale_API.cpp index 3abe48f1578..3b07a1aec93 100644 --- a/Core/Tools/Autorun/Locale_API.cpp +++ b/Core/Tools/Autorun/Locale_API.cpp @@ -35,7 +35,6 @@ *****************************************************************************/ #include "locale.h" -#include "Lib/WideChar.h" #include "Locale_API.h" #include "Utils.h" #include "Wnd_File.h" diff --git a/Core/Tools/Autorun/Locale_API.h b/Core/Tools/Autorun/Locale_API.h index da7aaa81ebe..fd038bdbe0a 100644 --- a/Core/Tools/Autorun/Locale_API.h +++ b/Core/Tools/Autorun/Locale_API.h @@ -36,8 +36,6 @@ #pragma once -#include "Lib/WideChar.h" - #include /****************************************************************************/ diff --git a/Core/Tools/Autorun/TTFont.cpp b/Core/Tools/Autorun/TTFont.cpp index 8ad40c0dd8f..68e1cfe3a5c 100644 --- a/Core/Tools/Autorun/TTFont.cpp +++ b/Core/Tools/Autorun/TTFont.cpp @@ -48,7 +48,6 @@ #define STRICT #include -#include "Lib/WideChar.h" #include #include #include diff --git a/Core/Tools/Autorun/TTFont.h b/Core/Tools/Autorun/TTFont.h index a96866d9243..8db2a9d2f7f 100644 --- a/Core/Tools/Autorun/TTFont.h +++ b/Core/Tools/Autorun/TTFont.h @@ -38,8 +38,6 @@ #pragma once -#include "Lib/WideChar.h" - #include #include "POINT.h" #include "RECT.h" diff --git a/Core/Tools/Autorun/Utils.cpp b/Core/Tools/Autorun/Utils.cpp index 1f98c44e6e5..282e5a86871 100644 --- a/Core/Tools/Autorun/Utils.cpp +++ b/Core/Tools/Autorun/Utils.cpp @@ -69,7 +69,6 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ #include -#include "Lib/WideChar.h" #include "ARGS.h" #include "assert.h" #include "Locale_API.h" diff --git a/Core/Tools/Autorun/Utils.h b/Core/Tools/Autorun/Utils.h index 4ad449769c7..0d5e4ed8625 100644 --- a/Core/Tools/Autorun/Utils.h +++ b/Core/Tools/Autorun/Utils.h @@ -36,8 +36,6 @@ #pragma once -#include "Lib/WideChar.h" - #include diff --git a/Core/Tools/Autorun/Wnd_File.h b/Core/Tools/Autorun/Wnd_File.h index 1b6879b6db3..35453063c66 100644 --- a/Core/Tools/Autorun/Wnd_File.h +++ b/Core/Tools/Autorun/Wnd_File.h @@ -41,8 +41,6 @@ #pragma once -#include "Lib/WideChar.h" - //------------------------------------------------------------------------------ // include files... //------------------------------------------------------------------------------ diff --git a/Core/Tools/Autorun/Wnd_file.cpp b/Core/Tools/Autorun/Wnd_file.cpp index ed42d5e6e42..63ef65583da 100644 --- a/Core/Tools/Autorun/Wnd_file.cpp +++ b/Core/Tools/Autorun/Wnd_file.cpp @@ -42,7 +42,6 @@ // include files... //----------------------------------------------------------------------------- #include "windows.h" -#include "Lib/WideChar.h" #include #include #include "Wnd_File.h" diff --git a/Core/Tools/Autorun/autorun.cpp b/Core/Tools/Autorun/autorun.cpp index 0e81965777e..caeed6da54a 100644 --- a/Core/Tools/Autorun/autorun.cpp +++ b/Core/Tools/Autorun/autorun.cpp @@ -70,7 +70,6 @@ #define STRICT #include -#include "Lib/WideChar.h" #include #include #include @@ -110,7 +109,7 @@ #include "WSYS_FileSystem.h" #include "WSYS_StdFileSystem.h" -#include +#include #include "GameText.h" #include "leanAndMeanAutorun.h" @@ -3734,8 +3733,8 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param // } /* if (success == 0) { - std::basic_string wideBuffer = TheGameText->fetch("Autorun:CantRunAVIs"); - std::basic_string wideBuffer2 = TheGameText->fetch("Autorun:Error"); + stl::wstring wideBuffer = TheGameText->fetch("Autorun:CantRunAVIs"); + stl::wstring wideBuffer2 = TheGameText->fetch("Autorun:Error"); int length = wideBuffer.length(); WideCharToMultiByte( CodePage, 0, wideBuffer.c_str(), length+1, szBuffer, _MAX_PATH, nullptr, nullptr ); length = wideBuffer2.length(); @@ -3748,7 +3747,7 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param case IDD_HELP: { - std::basic_string wFileName; + stl::wstring wFileName; wFileName = Locale_GetString(HELP_FILENAME); std::string fname; @@ -3779,8 +3778,8 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param /* if (success == 0) { - std::basic_string wideBuffer = TheGameText->fetch("Autorun:CantRunHelp"); - std::basic_string wideBuffer2 = TheGameText->fetch("Autorun:Error"); + stl::wstring wideBuffer = TheGameText->fetch("Autorun:CantRunHelp"); + stl::wstring wideBuffer2 = TheGameText->fetch("Autorun:Error"); int length = wideBuffer.length(); WideCharToMultiByte( CodePage, 0, wideBuffer.c_str(), length+1, szBuffer, _MAX_PATH, nullptr, nullptr ); length = wideBuffer2.length(); @@ -4805,8 +4804,8 @@ BOOL Valid_Environment () result = WinVersion.Meets_Minimum_Version_Requirements(); if ( !result ) { - std::basic_string wideBuffer = TheGameText->fetch("GUI:WindowsVersionText"); - std::basic_string wideBuffer2 = TheGameText->fetch("GUI:WindowsVersionTitle"); + stl::wstring wideBuffer = TheGameText->fetch("GUI:WindowsVersionText"); + stl::wstring wideBuffer2 = TheGameText->fetch("GUI:WindowsVersionTitle"); length = wideBuffer.length(); WideCharToMultiByte( CodePage, 0, wideBuffer.c_str(), length+1, szBuffer, _MAX_PATH, nullptr, nullptr ); length = wideBuffer2.length(); @@ -5069,9 +5068,9 @@ void Cant_Find_MessageBox ( HINSTANCE hInstance, const char *szPath ) #else - std::basic_string wideBuffer = TheGameText->fetch("Autorun:AutorunTitle"); - std::basic_string wideBuffer2.format( wideBuffer.str(), productName.str() ); - std::basic_string wideBuffer3 = TheGameText->fetch("Autorun:CantFind"); + stl::wstring wideBuffer = TheGameText->fetch("Autorun:AutorunTitle"); + stl::wstring wideBuffer2.format( wideBuffer.str(), productName.str() ); + stl::wstring wideBuffer3 = TheGameText->fetch("Autorun:CantFind"); WideCharToMultiByte( CodePage, 0, wideBuffer3.str(), wideBuffer3.getLength()+1, szBuffer3, _MAX_PATH, nullptr, nullptr ); WideCharToMultiByte( CodePage, 0, wideBuffer2.str(), wideBuffer2.getLength()+1, szBuffer2, _MAX_PATH, nullptr, nullptr ); diff --git a/Core/Tools/Autorun/locale.cpp b/Core/Tools/Autorun/locale.cpp index c60eed0e359..9407a207f4f 100644 --- a/Core/Tools/Autorun/locale.cpp +++ b/Core/Tools/Autorun/locale.cpp @@ -19,7 +19,6 @@ /* Copyright (C) Electronic Arts Canada Inc. 1998-1999. All rights reserved. */ #include -#include "Lib/WideChar.h" #include #include "gimex.h" /* for file and memory IO only */ #include "locale.h" diff --git a/Core/Tools/Babylon/transcs.cpp b/Core/Tools/Babylon/transcs.cpp index 875e0e262ee..764b35aede5 100644 --- a/Core/Tools/Babylon/transcs.cpp +++ b/Core/Tools/Babylon/transcs.cpp @@ -21,7 +21,6 @@ // #include "StdAfx.h" -#include "Lib/WideChar.h" #include #include #include diff --git a/Core/Tools/Launcher/Toolkit/Support/UTypes.h b/Core/Tools/Launcher/Toolkit/Support/UTypes.h index 1af9b036ffc..b15f41ad502 100644 --- a/Core/Tools/Launcher/Toolkit/Support/UTypes.h +++ b/Core/Tools/Launcher/Toolkit/Support/UTypes.h @@ -36,8 +36,6 @@ #pragma once -#include "Lib/WideChar.h" - //! Signed integer value typedef int Int; diff --git a/Dependencies/Utility/CMakeLists.txt b/Dependencies/Utility/CMakeLists.txt index 32bd79cf728..1706e79fda7 100644 --- a/Dependencies/Utility/CMakeLists.txt +++ b/Dependencies/Utility/CMakeLists.txt @@ -17,6 +17,7 @@ set(UTILITY_SRC Utility/sstream_adapter.h Utility/stdio_adapter.h Utility/STLUtils.h + Utility/string_adapter.h Utility/string_compat.h Utility/stringex.h Utility/tchar_compat.h @@ -36,3 +37,12 @@ target_sources(core_utility PRIVATE ${UTILITY_SRC}) target_link_libraries(core_utility INTERFACE core_precompiled # Gives force included headers. Link early. ) + +# Make the character type available throughout the project, including builds without PCH. +if(MSVC) + target_compile_options(core_utility INTERFACE + "$<$:/FIUtility/WideChar.h>") +else() + target_compile_options(core_utility INTERFACE + "$<$:SHELL:-include Utility/WideChar.h>") +endif() diff --git a/Dependencies/Utility/Utility/WideChar.h b/Dependencies/Utility/Utility/WideChar.h index 8c1474b2fa2..3c061e2a169 100644 --- a/Dependencies/Utility/Utility/WideChar.h +++ b/Dependencies/Utility/Utility/WideChar.h @@ -17,6 +17,7 @@ #pragma once +#include "Precompiled/CppTypes.h" #include // Shared project wide-character type, currently using the native representation. diff --git a/Core/Libraries/Include/Lib/WideChar.h b/Dependencies/Utility/Utility/string_adapter.h similarity index 85% rename from Core/Libraries/Include/Lib/WideChar.h rename to Dependencies/Utility/Utility/string_adapter.h index ce980cdf6ce..2fa7930c631 100644 --- a/Core/Libraries/Include/Lib/WideChar.h +++ b/Dependencies/Utility/Utility/string_adapter.h @@ -18,3 +18,10 @@ #pragma once #include +#include + +namespace stl +{ +typedef std::basic_string string; +typedef std::basic_string wstring; +} diff --git a/Generals/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp b/Generals/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp index 326033d3ca2..e2f1d696707 100644 --- a/Generals/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp +++ b/Generals/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp @@ -29,7 +29,6 @@ // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "PreRTS.h" -#include "Lib/WideChar.h" #include "Common/file.h" #include "Common/FileSystem.h" #include "Common/GameEngine.h" diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupReplay.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupReplay.cpp index 95a305c5128..c58f682eef4 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupReplay.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupReplay.cpp @@ -46,7 +46,6 @@ // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine -#include "Lib/WideChar.h" #include "Common/LocalFileSystem.h" #include "Common/MessageStream.h" diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp index 9f3baae5d23..bf9e862a70a 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp @@ -29,7 +29,6 @@ // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine -#include "Lib/WideChar.h" #include "Common/FileSystem.h" diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp index e32c12fbd66..735b1762c27 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp @@ -29,7 +29,6 @@ // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "PreRTS.h" -#include "Lib/WideChar.h" #include "Common/file.h" #include "Common/FileSystem.h" #include "Common/GameEngine.h" diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupReplay.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupReplay.cpp index 8c288dc012a..775ebfe0924 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupReplay.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupReplay.cpp @@ -46,7 +46,6 @@ // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine -#include "Lib/WideChar.h" #include "Common/LocalFileSystem.h" #include "Common/MessageStream.h" diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp index 34f316d97dd..f7b0e6ad6f8 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp @@ -29,7 +29,6 @@ // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine -#include "Lib/WideChar.h" #include "Common/FileSystem.h" diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/playerlistdlg.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/playerlistdlg.cpp index 7b50cc46548..9c3c1a34bfe 100644 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/playerlistdlg.cpp +++ b/GeneralsMD/Code/Tools/WorldBuilder/src/playerlistdlg.cpp @@ -20,7 +20,6 @@ // #include "StdAfx.h" -#include "Lib/WideChar.h" #include "WorldBuilder.h" #include "playerlistdlg.h" #include "mapobjectprops.h" From 48c999220a4de1bf14ec656074ec68c98ec8f4ca Mon Sep 17 00:00:00 2001 From: Jacob Ledbetter Date: Fri, 2 Oct 2026 21:20:14 -0600 Subject: [PATCH 3/6] refactor: separate game WideChar from shared unichar --- .../Include/GameNetwork/GameSpy/PeerThread.h | 2 - .../Include/GameNetwork/GameSpy/ThreadUtils.h | 2 - .../GameSpy/Thread/BuddyThread.cpp | 1 - .../GameNetwork/GameSpy/Thread/PeerThread.cpp | 1 - .../GameSpy/Thread/ThreadUtils.cpp | 1 - .../Precompiled/Precompiled/BaseTypes.h | 3 +- .../Libraries/Source/WWVegas/WWLib/WWCommon.h | 3 +- Dependencies/Precompiled/CMakeLists.txt | 1 + .../Precompiled/Precompiled/precompiled.h | 1 + .../Precompiled/unichar.h} | 5 +-- Dependencies/Utility/CMakeLists.txt | 10 ----- Dependencies/Utility/Utility/string_adapter.h | 3 +- Dependencies/Utility/Utility/stringex.h | 45 ++++++------------- 13 files changed, 20 insertions(+), 58 deletions(-) rename Dependencies/{Utility/Utility/WideChar.h => Precompiled/Precompiled/unichar.h} (91%) diff --git a/Core/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h b/Core/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h index 3977cb96ab2..fee7b6b1459 100644 --- a/Core/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h @@ -28,8 +28,6 @@ #pragma once -#include - #include "gamespy/peer/peer.h" #include "GameNetwork/NetworkDefs.h" diff --git a/Core/GameEngine/Include/GameNetwork/GameSpy/ThreadUtils.h b/Core/GameEngine/Include/GameNetwork/GameSpy/ThreadUtils.h index 49c0691b6ee..861531451fc 100644 --- a/Core/GameEngine/Include/GameNetwork/GameSpy/ThreadUtils.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpy/ThreadUtils.h @@ -28,7 +28,5 @@ #pragma once -#include - stl::wstring MultiByteToWideCharSingleLine( const char* orig ); std::string WideCharStringToMultiByte( const WideChar *orig ); diff --git a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp index b16633e810c..0cdaf508714 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp @@ -30,7 +30,6 @@ // Author: Matthew D. Campbell, June 2002 #include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine -#include #include "GameNetwork/GameSpy/BuddyThread.h" #include "GameNetwork/GameSpy/PeerThread.h" diff --git a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PeerThread.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PeerThread.cpp index 48c5b443848..dadf09e4c27 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PeerThread.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PeerThread.cpp @@ -30,7 +30,6 @@ // Author: Matthew D. Campbell, June 2002 #include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine -#include #include "Common/Registry.h" #include "Common/OptionPreferences.h" diff --git a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp index 05d32c5b8aa..ed142c42a2b 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp @@ -27,7 +27,6 @@ // Author: Matthew D. Campbell, July 2002 #include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine -#include #include "WWLib/utf8.h" diff --git a/Core/Libraries/Include/Precompiled/Precompiled/BaseTypes.h b/Core/Libraries/Include/Precompiled/Precompiled/BaseTypes.h index 5927cedf6f7..3458876d80b 100644 --- a/Core/Libraries/Include/Precompiled/Precompiled/BaseTypes.h +++ b/Core/Libraries/Include/Precompiled/Precompiled/BaseTypes.h @@ -17,8 +17,6 @@ #pragma once -#include - // Fundamental type definitions typedef float Real; @@ -36,5 +34,6 @@ typedef char Byte; typedef unsigned char UnsignedByte; typedef char Char; +typedef unichar WideChar; typedef bool Bool; diff --git a/Core/Libraries/Source/WWVegas/WWLib/WWCommon.h b/Core/Libraries/Source/WWVegas/WWLib/WWCommon.h index 9825dcd0053..a4b805097de 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/WWCommon.h +++ b/Core/Libraries/Source/WWVegas/WWLib/WWCommon.h @@ -18,12 +18,11 @@ #pragma once -#include - #include "ref_ptr.h" #include "refcount.h" #include "Utility/STLUtils.h" #include "Utility/stringex.h" +#include #include #include #include diff --git a/Dependencies/Precompiled/CMakeLists.txt b/Dependencies/Precompiled/CMakeLists.txt index beffc0f5985..444506dcd3f 100644 --- a/Dependencies/Precompiled/CMakeLists.txt +++ b/Dependencies/Precompiled/CMakeLists.txt @@ -4,6 +4,7 @@ set(PRECOMPILED_SRC Precompiled/precompiled.h Precompiled/stdint_adapter.h Precompiled/stdint_subset.h + Precompiled/unichar.h ) ## core_precompiled diff --git a/Dependencies/Precompiled/Precompiled/precompiled.h b/Dependencies/Precompiled/Precompiled/precompiled.h index ace8dbc25f9..cf6baa8f47f 100644 --- a/Dependencies/Precompiled/Precompiled/precompiled.h +++ b/Dependencies/Precompiled/Precompiled/precompiled.h @@ -22,6 +22,7 @@ #include "CppMacros.h" #include "CppTypes.h" + #include "unichar.h" #else diff --git a/Dependencies/Utility/Utility/WideChar.h b/Dependencies/Precompiled/Precompiled/unichar.h similarity index 91% rename from Dependencies/Utility/Utility/WideChar.h rename to Dependencies/Precompiled/Precompiled/unichar.h index 3c061e2a169..888efc5464a 100644 --- a/Dependencies/Utility/Utility/WideChar.h +++ b/Dependencies/Precompiled/Precompiled/unichar.h @@ -17,9 +17,6 @@ #pragma once -#include "Precompiled/CppTypes.h" -#include - // Shared project wide-character type, currently using the native representation. // Changing it also requires adapting wide literals, character traits, and CRT/platform APIs. -typedef wchar_t WideChar; +typedef wchar_t unichar; diff --git a/Dependencies/Utility/CMakeLists.txt b/Dependencies/Utility/CMakeLists.txt index 1706e79fda7..8c6b8f82967 100644 --- a/Dependencies/Utility/CMakeLists.txt +++ b/Dependencies/Utility/CMakeLists.txt @@ -25,7 +25,6 @@ set(UTILITY_SRC Utility/time_compat.h Utility/utility_adapter.h Utility/wchar_compat.h - Utility/WideChar.h ) ## core_utility @@ -37,12 +36,3 @@ target_sources(core_utility PRIVATE ${UTILITY_SRC}) target_link_libraries(core_utility INTERFACE core_precompiled # Gives force included headers. Link early. ) - -# Make the character type available throughout the project, including builds without PCH. -if(MSVC) - target_compile_options(core_utility INTERFACE - "$<$:/FIUtility/WideChar.h>") -else() - target_compile_options(core_utility INTERFACE - "$<$:SHELL:-include Utility/WideChar.h>") -endif() diff --git a/Dependencies/Utility/Utility/string_adapter.h b/Dependencies/Utility/Utility/string_adapter.h index 2fa7930c631..99c4423f7b3 100644 --- a/Dependencies/Utility/Utility/string_adapter.h +++ b/Dependencies/Utility/Utility/string_adapter.h @@ -17,11 +17,10 @@ #pragma once -#include #include namespace stl { typedef std::basic_string string; -typedef std::basic_string wstring; +typedef std::basic_string wstring; } diff --git a/Dependencies/Utility/Utility/stringex.h b/Dependencies/Utility/Utility/stringex.h index 30ca4c26146..66472a49e8a 100644 --- a/Dependencies/Utility/Utility/stringex.h +++ b/Dependencies/Utility/Utility/stringex.h @@ -18,10 +18,10 @@ #pragma once -#include "Utility/WideChar.h" #include #include + // Declaration template size_t strlen_t(const T *str); @@ -29,7 +29,7 @@ template size_t strnlen_t(const T *str, size_t maxlen); #if defined(_MSC_VER) && _MSC_VER < 1300 size_t strnlen(const char *str, size_t maxlen); -size_t wcsnlen(const WideChar* str, size_t maxlen); +size_t wcsnlen(const unichar *str, size_t maxlen); #endif template size_t strlcpy_t(T *dst, const T *src, size_t dstsize); @@ -37,16 +37,16 @@ template size_t strlcat_t(T *dst, const T *src, size_t dstsize); size_t strlcpy(char *dst, const char *src, size_t dstsize); size_t strlcat(char *dst, const char *src, size_t dstsize); -size_t wcslcpy(WideChar* dst, const WideChar* src, size_t dstsize); -size_t wcslcat(WideChar* dst, const WideChar* src, size_t dstsize); +size_t wcslcpy(unichar *dst, const unichar *src, size_t dstsize); +size_t wcslcat(unichar *dst, const unichar *src, size_t dstsize); template size_t strlmove_t(T *dst, const T *src, size_t dstsize); template size_t strlmcat_t(T *dst, const T *src, size_t dstsize); size_t strlmove(char *dst, const char *src, size_t dstsize); size_t strlmcat(char *dst, const char *src, size_t dstsize); -size_t wcslmove(WideChar* dst, const WideChar* src, size_t dstsize); -size_t wcslmcat(WideChar* dst, const WideChar* src, size_t dstsize); +size_t wcslmove(unichar *dst, const unichar *src, size_t dstsize); +size_t wcslmcat(unichar *dst, const unichar *src, size_t dstsize); #if !(defined(_MSC_VER) && _MSC_VER < 1300) template size_t strlcpy_t(char (&dst)[Size], const char *src); @@ -63,6 +63,7 @@ template bool startsWithNoCase(const T *str, const T *prefix); template bool endsWithNoCase(const T *str, const T *suffix); template bool endsWithNoCase(const T *str, const T *suffix); + // Implementation // Templated strlen. @@ -88,11 +89,7 @@ template size_t strnlen_t(const T *str, size_t maxlen) #if defined(_MSC_VER) && _MSC_VER < 1300 inline size_t strnlen(const char *str, size_t maxlen) { return strnlen_t(str, maxlen); } -inline size_t wcsnlen(const WideChar* str, size_t maxlen) -{ - return strnlen_t(str, maxlen); -} - +inline size_t wcsnlen(const unichar *str, size_t maxlen) { return strnlen_t(str, maxlen); } #endif // Templated strlcpy. Prefer using this over strncpy. @@ -140,15 +137,8 @@ inline size_t strlcpy(char *dst, const char *src, size_t dstsize) { return strlc #ifndef HAVE_STRLCAT inline size_t strlcat(char *dst, const char *src, size_t dstsize) { return strlcat_t(dst, src, dstsize); } #endif -inline size_t wcslcpy(WideChar* dst, const WideChar* src, size_t dstsize) -{ - return strlcpy_t(dst, src, dstsize); -} - -inline size_t wcslcat(WideChar* dst, const WideChar* src, size_t dstsize) -{ - return strlcat_t(dst, src, dstsize); -} +inline size_t wcslcpy(unichar *dst, const unichar *src, size_t dstsize) { return strlcpy_t(dst, src, dstsize); } +inline size_t wcslcat(unichar *dst, const unichar *src, size_t dstsize) { return strlcat_t(dst, src, dstsize); } // Templated strlmove. Prefer using this over strlcpy if dst and src overlap. // Moves src into dst until dstsize minus one. Always null terminates. @@ -191,15 +181,8 @@ template size_t strlmcat_t(T *dst, const T *src, size_t dstsize) inline size_t strlmove(char *dst, const char *src, size_t dstsize) { return strlmove_t(dst, src, dstsize); } inline size_t strlmcat(char *dst, const char *src, size_t dstsize) { return strlmcat_t(dst, src, dstsize); } -inline size_t wcslmove(WideChar* dst, const WideChar* src, size_t dstsize) -{ - return strlmove_t(dst, src, dstsize); -} - -inline size_t wcslmcat(WideChar* dst, const WideChar* src, size_t dstsize) -{ - return strlmcat_t(dst, src, dstsize); -} +inline size_t wcslmove(unichar *dst, const unichar *src, size_t dstsize) { return strlmove_t(dst, src, dstsize); } +inline size_t wcslmcat(unichar *dst, const unichar *src, size_t dstsize) { return strlmcat_t(dst, src, dstsize); } #if !(defined(_MSC_VER) && _MSC_VER < 1300) template size_t strlcpy_t(char (&dst)[Size], const char *src) { return strlcpy_t(dst, src, Size); } @@ -237,9 +220,9 @@ inline char tolower_t(char c) return (char)tolower((unsigned char)c); } -inline WideChar tolower_t(WideChar c) +inline unichar tolower_t(unichar c) { - return (WideChar)towlower(c); + return (unichar)towlower(c); } // Templated strnicmp. From 844fa69e45e843e4a64a1e83003a3ac1c80f6a45 Mon Sep 17 00:00:00 2001 From: Jacob Ledbetter Date: Sat, 3 Oct 2026 08:35:54 -0600 Subject: [PATCH 4/6] refactor: use unichar in WWLib and support C headers --- Core/GameEngine/Include/Common/STLTypedefs.h | 2 +- .../GameSpy/Thread/ThreadUtils.cpp | 5 +--- Core/Libraries/Source/WWVegas/WWLib/INI.h | 4 ++-- .../Libraries/Source/WWVegas/WWLib/WWCommon.h | 1 - Core/Libraries/Source/WWVegas/WWLib/ini.cpp | 6 ++--- .../Source/WWVegas/WWLib/readline.cpp | 4 ++-- .../Libraries/Source/WWVegas/WWLib/readline.h | 2 +- Core/Libraries/Source/WWVegas/WWLib/trim.cpp | 6 ++--- Core/Libraries/Source/WWVegas/WWLib/trim.h | 2 +- Core/Libraries/Source/WWVegas/WWLib/utf8.cpp | 24 +++++++++---------- Core/Libraries/Source/WWVegas/WWLib/utf8.h | 10 ++++---- .../Precompiled/Precompiled/precompiled.h | 2 +- .../Precompiled/Precompiled/unichar.h | 2 ++ 13 files changed, 34 insertions(+), 36 deletions(-) diff --git a/Core/GameEngine/Include/Common/STLTypedefs.h b/Core/GameEngine/Include/Common/STLTypedefs.h index 7276a459c3f..5c81fbb0062 100644 --- a/Core/GameEngine/Include/Common/STLTypedefs.h +++ b/Core/GameEngine/Include/Common/STLTypedefs.h @@ -75,7 +75,7 @@ enum ParticleSystemID CPP_11(: Int); #include #include #include -#include +#include #include // List of AsciiStrings to allow list of ThingTemplate names from INI and such diff --git a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp index ed142c42a2b..8f5b6a76a49 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp @@ -33,15 +33,12 @@ //------------------------------------------------------------------------- // TheSuperHackers @refactor bobtista 02/04/2026 Use WWLib UTF-8 functions instead of raw Win32 API calls -stl::wstring MultiByteToWideCharSingleLine( const char* orig ) +stl::wstring MultiByteToWideCharSingleLine( const char *orig ) { const size_t srcLen = strlen(orig); const size_t dstLen = Utf8_To_Wide_Len(orig, srcLen); if (dstLen == 0) - { return stl::wstring(); - } - stl::wstring ret; if (dstLen == UTF8_INVALID) { diff --git a/Core/Libraries/Source/WWVegas/WWLib/INI.h b/Core/Libraries/Source/WWVegas/WWLib/INI.h index e06e045a363..12128733b56 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/INI.h +++ b/Core/Libraries/Source/WWVegas/WWLib/INI.h @@ -138,7 +138,7 @@ class INIClass { int Get_Int(char const * section, char const * entry, int defvalue=0) const; int Get_String(char const * section, char const * entry, char const * defvalue, char * buffer, int size) const; const StringClass& Get_String(StringClass& new_string, char const * section, char const * entry, char const * defvalue="") const; - const WideStringClass& Get_Wide_String(WideStringClass& new_string, const char* section, const char* entry, const WideChar* defvalue=L"") const; + const WideStringClass& Get_Wide_String(WideStringClass& new_string, char const * section, char const * entry, unichar const * defvalue=L"") const; int Get_List_Index(char const * section, char const * entry, int const defvalue, char *list[]); int * Get_Alloc_Int_Array(char const * section, char const * entry, int listend); int Get_Int_Bitfield(char const * section, char const * entry, int defvalue, char *list[]); @@ -170,7 +170,7 @@ class INIClass { bool Put_Point(char const * section, char const * entry, TPoint3D const & value); bool Put_Point(char const * section, char const * entry, TPoint3D const & value); bool Put_Point(char const * section, char const * entry, TPoint2D const & value); - bool Put_Wide_String(const char* section, const char* entry, const WideChar* string); + bool Put_Wide_String(char const * section, char const * entry, unichar const * string); // protected: diff --git a/Core/Libraries/Source/WWVegas/WWLib/WWCommon.h b/Core/Libraries/Source/WWVegas/WWLib/WWCommon.h index a4b805097de..e505e9b6bb1 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/WWCommon.h +++ b/Core/Libraries/Source/WWVegas/WWLib/WWCommon.h @@ -22,7 +22,6 @@ #include "refcount.h" #include "Utility/STLUtils.h" #include "Utility/stringex.h" -#include #include #include #include diff --git a/Core/Libraries/Source/WWVegas/WWLib/ini.cpp b/Core/Libraries/Source/WWVegas/WWLib/ini.cpp index e59fdf3342d..2e9871dbf28 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/ini.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/ini.cpp @@ -988,9 +988,9 @@ int INIClass::Get_UUBlock(char const * section, void * block, int len) const * HISTORY: * * 11/6/2001 4:27PM ST : Created * *=============================================================================================*/ -const WideStringClass& INIClass::Get_Wide_String(WideStringClass& new_string, const char* section, const char* entry, const WideChar* defvalue) const +const WideStringClass& INIClass::Get_Wide_String(WideStringClass& new_string, char const * section, char const * entry, unichar const * defvalue) const { - WideChar out[1024]; + unichar out[1024]; char buffer[1024]; Base64Pipe b64pipe(Base64Pipe::DECODE); @@ -1027,7 +1027,7 @@ const WideStringClass& INIClass::Get_Wide_String(WideStringClass& new_string, co * HISTORY: * * 11/6/2001 4:29PM ST : Created * *=============================================================================================*/ -bool INIClass::Put_Wide_String(const char* section, const char* entry, const WideChar* string) +bool INIClass::Put_Wide_String(char const * section, char const * entry, unichar const * string) { if (section == nullptr || entry == nullptr || string == nullptr) { return(false); diff --git a/Core/Libraries/Source/WWVegas/WWLib/readline.cpp b/Core/Libraries/Source/WWVegas/WWLib/readline.cpp index 943882d4e87..c306f37719b 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/readline.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/readline.cpp @@ -117,13 +117,13 @@ int Read_Line(Straw & file, char * buffer, int len, bool & eof) return(strlen(buffer)); } -int Read_Line(Straw & file, WideChar* buffer, int len, bool & eof) +int Read_Line(Straw & file, unichar * buffer, int len, bool & eof) { if (len == 0 || buffer == nullptr) return(0); int count = 0; for (;;) { - WideChar c; + unichar c; if (file.Get(&c, sizeof(c)) != sizeof(c)) { eof = true; buffer[count] = L'\0'; diff --git a/Core/Libraries/Source/WWVegas/WWLib/readline.h b/Core/Libraries/Source/WWVegas/WWLib/readline.h index b48a4fe667a..5e1ce4a4155 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/readline.h +++ b/Core/Libraries/Source/WWVegas/WWLib/readline.h @@ -42,4 +42,4 @@ int Read_Line(FileClass & file, char * buffer, int len, bool & eof); int Read_Line(Straw & file, char * buffer, int len, bool & eof); -int Read_Line(Straw & file, WideChar* buffer, int len, bool & eof); +int Read_Line(Straw & file, unichar * buffer, int len, bool & eof); diff --git a/Core/Libraries/Source/WWVegas/WWLib/trim.cpp b/Core/Libraries/Source/WWVegas/WWLib/trim.cpp index 3a99d366616..90fe1285e08 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/trim.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/trim.cpp @@ -85,11 +85,11 @@ char* strtrim(char* buffer) } -WideChar* wcstrim(WideChar* buffer) +unichar* wcstrim(unichar* buffer) { if (buffer) { /* Strip leading white space from the string. */ - WideChar* source = buffer; + unichar* source = buffer; while ((*source != 0) && ((unsigned int)*source <= 32)) { ++source; @@ -97,7 +97,7 @@ WideChar* wcstrim(WideChar* buffer) if (source != buffer) { // TheSuperHackers @fix Mauller 04/04/2025 Replace wcscpy with safer memmove as memory regions can overlap when part of string is copied to itself - memmove(buffer, source, (wcslen(source) + 1) * sizeof(WideChar)); + memmove(buffer, source, (wcslen(source) + 1) * sizeof(unichar)); } /* Clip trailing white space from the string. */ diff --git a/Core/Libraries/Source/WWVegas/WWLib/trim.h b/Core/Libraries/Source/WWVegas/WWLib/trim.h index ddd5ff49dc5..fe022f5a16c 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/trim.h +++ b/Core/Libraries/Source/WWVegas/WWLib/trim.h @@ -39,4 +39,4 @@ #include char * strtrim(char * buffer); -WideChar* wcstrim(WideChar* buffer); +unichar * wcstrim(unichar * buffer); diff --git a/Core/Libraries/Source/WWVegas/WWLib/utf8.cpp b/Core/Libraries/Source/WWVegas/WWLib/utf8.cpp index 4b81342d2d4..d8c4e97cd84 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/utf8.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/utf8.cpp @@ -19,9 +19,9 @@ #include "always.h" #include "utf8.h" -// WideChar is a 16-bit UTF-16 code unit on Windows and a 32-bit UTF-32 codepoint on most other +// unichar is a 16-bit UTF-16 code unit on Windows and a 32-bit UTF-32 codepoint on most other // platforms. WCHAR_MAX lets us distinguish the two at compile time so the surrogate-pair paths -// are excluded entirely (not just constant-folded) where WideChar is wide enough to hold a codepoint. +// are excluded entirely (not just constant-folded) where unichar is wide enough to hold a codepoint. #if defined(WCHAR_MAX) && (WCHAR_MAX <= 0xFFFF) #define UTF8_WCHAR_IS_UTF16 1 #else @@ -138,11 +138,11 @@ static size_t Utf8_Decode(const char* src, size_t srcLen, unsigned int& cp) } // Read one codepoint at src, with srcLen wide characters remaining. Returns the number of wide -// characters consumed (1-2) and sets cp. Combines UTF-16 surrogate pairs where WideChar is 16-bit; -// treats each element as a whole codepoint where WideChar is 32-bit. Wide data that has no UTF-8 +// characters consumed (1-2) and sets cp. Combines UTF-16 surrogate pairs where unichar is 16-bit; +// treats each element as a whole codepoint where unichar is 32-bit. Wide data that has no UTF-8 // representation is reported as U+FFFD, so the encoder never emits a sequence that the decoder // would reject. -static size_t Wide_Read(const WideChar* src, size_t srcLen, unsigned int& cp) +static size_t Wide_Read(const unichar* src, size_t srcLen, unsigned int& cp) { size_t consumed = 1; #if UTF8_WCHAR_IS_UTF16 @@ -179,22 +179,22 @@ static size_t Wide_Encoded_Length(unsigned int cp) } // Write one codepoint to a wide buffer, which is assumed to have room. Returns wide characters written. -static size_t Wide_Write(WideChar* dest, unsigned int cp) +static size_t Wide_Write(unichar* dest, unsigned int cp) { #if UTF8_WCHAR_IS_UTF16 if (cp >= 0x10000) { cp -= 0x10000; - dest[0] = (WideChar)(0xD800 + (cp >> 10)); - dest[1] = (WideChar)(0xDC00 + (cp & 0x3FF)); + dest[0] = (unichar)(0xD800 + (cp >> 10)); + dest[1] = (unichar)(0xDC00 + (cp & 0x3FF)); return 2; } #endif - dest[0] = (WideChar)cp; + dest[0] = (unichar)cp; return 1; } -size_t Wide_To_Utf8_Len(const WideChar* src, size_t srcLen) +size_t Wide_To_Utf8_Len(const unichar* src, size_t srcLen) { size_t needed = 0; size_t i = 0; @@ -225,7 +225,7 @@ size_t Utf8_To_Wide_Len(const char* src, size_t srcLen) return needed; } -size_t Wide_To_Utf8(char* dest, size_t destLen, const WideChar* src, size_t srcLen) +size_t Wide_To_Utf8(char* dest, size_t destLen, const unichar* src, size_t srcLen) { size_t needed = 0; size_t out = 0; @@ -249,7 +249,7 @@ size_t Wide_To_Utf8(char* dest, size_t destLen, const WideChar* src, size_t srcL return needed; } -size_t Utf8_To_Wide(WideChar* dest, size_t destLen, const char* src, size_t srcLen) +size_t Utf8_To_Wide(unichar* dest, size_t destLen, const char* src, size_t srcLen) { size_t needed = 0; size_t out = 0; diff --git a/Core/Libraries/Source/WWVegas/WWLib/utf8.h b/Core/Libraries/Source/WWVegas/WWLib/utf8.h index b4de2054768..fd509c13038 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/utf8.h +++ b/Core/Libraries/Source/WWVegas/WWLib/utf8.h @@ -22,9 +22,9 @@ #include // UTF-8 <-> wide-character transcoding, hand-rolled per RFC 3629, using no platform text APIs. -// The wide side is WideChar, whose width is platform-dependent: on Windows it is a 16-bit UTF-16 +// The wide side is unichar, whose width is platform-dependent: on Windows it is a 16-bit UTF-16 // code unit (astral codepoints use surrogate pairs); on most other platforms it is a 32-bit -// UTF-32 codepoint. Both are handled transparently based on the width of WideChar. +// UTF-32 codepoint. Both are handled transparently based on the width of unichar. // Returned by the decoding functions when the source is not well-formed UTF-8. A return of 0 means // an empty result, which is a success and must not be confused with a decoding failure. @@ -33,7 +33,7 @@ const size_t UTF8_INVALID = (size_t)-1; // Returns the number of UTF-8 bytes needed for the UTF-8 representation of srcLen wide characters // from src, not counting a null terminator. Returns 0 if srcLen is 0. Wide values that have no // UTF-8 representation are counted as U+FFFD. -size_t Wide_To_Utf8_Len(const WideChar* src, size_t srcLen); +size_t Wide_To_Utf8_Len(const unichar* src, size_t srcLen); // Returns the number of wide characters needed for the wide representation of srcLen bytes from the // UTF-8 string src, not counting a null terminator. Returns 0 if srcLen is 0, or UTF8_INVALID if @@ -46,7 +46,7 @@ size_t Utf8_To_Wide_Len(const char* src, size_t srcLen); // Returns the number of bytes the whole conversion needs, not counting a null terminator. A return // greater than destLen means the output was truncated on a codepoint boundary; retry with that many // bytes plus one for the terminator. Pass destLen 0 to measure without writing. -size_t Wide_To_Utf8(char* dest, size_t destLen, const WideChar* src, size_t srcLen); +size_t Wide_To_Utf8(char* dest, size_t destLen, const unichar* src, size_t srcLen); // Converts srcLen bytes from the UTF-8 string src to wide characters. destLen is the destination // buffer capacity in wide characters. Writes a null terminator if room remains, otherwise not. @@ -54,7 +54,7 @@ size_t Wide_To_Utf8(char* dest, size_t destLen, const WideChar* src, size_t srcL // A return greater than destLen means the output was truncated on a codepoint boundary; retry with // that many wide characters plus one for the terminator. Pass destLen 0 to measure without writing. // Returns UTF8_INVALID if src is not well-formed UTF-8, setting dest[0] to L'\0' if destLen > 0. -size_t Utf8_To_Wide(WideChar* dest, size_t destLen, const char* src, size_t srcLen); +size_t Utf8_To_Wide(unichar* dest, size_t destLen, const char* src, size_t srcLen); // Returns the largest length not greater than maxLen at which the srcLen bytes of the UTF-8 string // src can be cut without splitting a multibyte sequence, by backing off the continuation bytes at diff --git a/Dependencies/Precompiled/Precompiled/precompiled.h b/Dependencies/Precompiled/Precompiled/precompiled.h index cf6baa8f47f..920b0da4a5c 100644 --- a/Dependencies/Precompiled/Precompiled/precompiled.h +++ b/Dependencies/Precompiled/Precompiled/precompiled.h @@ -22,7 +22,6 @@ #include "CppMacros.h" #include "CppTypes.h" - #include "unichar.h" #else @@ -32,4 +31,5 @@ #endif // __cplusplus +#include "unichar.h" #include "stdint_adapter.h" diff --git a/Dependencies/Precompiled/Precompiled/unichar.h b/Dependencies/Precompiled/Precompiled/unichar.h index 888efc5464a..80b2ad3fee6 100644 --- a/Dependencies/Precompiled/Precompiled/unichar.h +++ b/Dependencies/Precompiled/Precompiled/unichar.h @@ -17,6 +17,8 @@ #pragma once +#include + // Shared project wide-character type, currently using the native representation. // Changing it also requires adapting wide literals, character traits, and CRT/platform APIs. typedef wchar_t unichar; From a3f1e2cb25ab877977984bda097b51630c8a196f Mon Sep 17 00:00:00 2001 From: Jacob Ledbetter Date: Sat, 3 Oct 2026 15:14:40 -0600 Subject: [PATCH 5/6] style: preserve original formatting in wide-character migration --- .../Include/GameNetwork/GameSpy/ThreadUtils.h | 2 +- .../Source/GameClient/LanguageFilter.cpp | 2 +- .../GameNetwork/GameSpy/Thread/PeerThread.cpp | 6 +---- Core/Tools/Autorun/DrawButton.cpp | 2 +- Core/Tools/Autorun/DrawButton.h | 8 ++----- Core/Tools/Autorun/GameText.cpp | 4 ++-- Core/Tools/Autorun/GameText.h | 2 +- Core/Tools/Autorun/Locale_API.cpp | 24 +++++++++---------- Core/Tools/Autorun/Locale_API.h | 4 ++-- Core/Tools/Autorun/TTFont.cpp | 4 ++-- Core/Tools/Autorun/TTFont.h | 2 +- Core/Tools/Autorun/Utils.cpp | 18 +++++++------- Core/Tools/Autorun/Utils.h | 10 ++++---- Core/Tools/Autorun/Wnd_File.h | 2 +- Core/Tools/Autorun/Wnd_file.cpp | 6 ++--- Core/Tools/Autorun/autorun.cpp | 2 +- Core/Tools/Autorun/locale.cpp | 2 +- .../Tools/WorldBuilder/src/playerlistdlg.cpp | 2 +- 18 files changed, 47 insertions(+), 55 deletions(-) diff --git a/Core/GameEngine/Include/GameNetwork/GameSpy/ThreadUtils.h b/Core/GameEngine/Include/GameNetwork/GameSpy/ThreadUtils.h index 861531451fc..b9d771a507f 100644 --- a/Core/GameEngine/Include/GameNetwork/GameSpy/ThreadUtils.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpy/ThreadUtils.h @@ -28,5 +28,5 @@ #pragma once -stl::wstring MultiByteToWideCharSingleLine( const char* orig ); +stl::wstring MultiByteToWideCharSingleLine( const char *orig ); std::string WideCharStringToMultiByte( const WideChar *orig ); diff --git a/Core/GameEngine/Source/GameClient/LanguageFilter.cpp b/Core/GameEngine/Source/GameClient/LanguageFilter.cpp index fc1d11a5cb7..409d3500427 100644 --- a/Core/GameEngine/Source/GameClient/LanguageFilter.cpp +++ b/Core/GameEngine/Source/GameClient/LanguageFilter.cpp @@ -87,7 +87,7 @@ void LanguageFilter::filterLine(UnicodeString &line) UnicodeString token; while (newLine.nextToken(&token, L" ;,.!?:=\\/><`~()&^%#\n\t")) { - WideChar* pos = wcsstr(buf, token.str()); + WideChar *pos = wcsstr(buf, token.str()); if (pos == nullptr) { DEBUG_CRASH(("Couldn't find the token in its own string.")); continue; diff --git a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PeerThread.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PeerThread.cpp index dadf09e4c27..6e89d5f9315 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PeerThread.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PeerThread.cpp @@ -232,11 +232,7 @@ class PeerThreadClass : public ThreadClass UnsignedInt exeCRC() { return m_exeCRC; } UnsignedInt iniCRC() { return m_iniCRC; } UnsignedInt gameVersion() { return m_gameVersion; } - stl::wstring getLocalStagingServerName() - { - return m_localStagingServerName; - } - + stl::wstring getLocalStagingServerName() { return m_localStagingServerName; } Int getLocalRoomID() { return m_localRoomID; } std::string ladderIP() { return m_ladderIP; } UnsignedShort ladderPort() { return m_ladderPort; } diff --git a/Core/Tools/Autorun/DrawButton.cpp b/Core/Tools/Autorun/DrawButton.cpp index 6de56fc6642..548a27844b7 100644 --- a/Core/Tools/Autorun/DrawButton.cpp +++ b/Core/Tools/Autorun/DrawButton.cpp @@ -153,7 +153,7 @@ DrawButton::DrawButton ( int id, RECT button_rect, const char *normal, const cha Msg( __LINE__, TEXT(__FILE__), TEXT(" MyRect = [%d,%d,%d,%d]"), MyRect.X, MyRect.Y, MyRect.Width, MyRect.Height ); } -DrawButton::DrawButton ( int id, RECT button_rect, const char* normal, const char* focus, const char* pressed, const WideChar* string, TTFontClass* fontptr ) +DrawButton::DrawButton ( int id, RECT button_rect, const char *normal, const char *focus, const char *pressed, const WideChar *string, TTFontClass *fontptr ) { Id = id; diff --git a/Core/Tools/Autorun/DrawButton.h b/Core/Tools/Autorun/DrawButton.h index 6682e31ce24..c8bbe1b8877 100644 --- a/Core/Tools/Autorun/DrawButton.h +++ b/Core/Tools/Autorun/DrawButton.h @@ -52,7 +52,7 @@ class DrawButton }; DrawButton ( int id, RECT button_rect, const char *normal, const char *focus, const char *pressed, const char *string, TTFontClass *fontptr ); - DrawButton ( int id, RECT button_rect, const char* normal, const char* focus, const char* pressed, const WideChar* string, TTFontClass* fontptr ); + DrawButton ( int id, RECT button_rect, const char *normal, const char *focus, const char *pressed, const WideChar *string, TTFontClass *fontptr ); char *Return_Normal_Bitmap () { return NormalBitmap; }; char *Return_Pressed_Bitmap () { return PressedBitmap; }; @@ -76,11 +76,7 @@ class DrawButton void Return_Area ( Rect *area ); void Return_Text_Area ( Rect *area ); TTFontClass *Return_Font_Ptr () { return( MyFontPtr ); }; - WideChar* Return_Text() - { - return( String ); - }; - + WideChar *Return_Text () { return( String ); }; void Set_State ( BUTTON_STATE state ) { ButtonState = state; }; int Set_Stretched_Width ( int ); int Set_Stretched_Height ( int ); diff --git a/Core/Tools/Autorun/GameText.cpp b/Core/Tools/Autorun/GameText.cpp index 0902ea13f82..12831cbdbba 100644 --- a/Core/Tools/Autorun/GameText.cpp +++ b/Core/Tools/Autorun/GameText.cpp @@ -142,7 +142,7 @@ class GameTextManager : public GameTextInterface virtual void update() {}; ///< update text manager virtual void reset(); ///< Resets the text system - virtual const WideChar* fetch( const Char* label ); ///< Returns the associated labeled unicode text + virtual const WideChar * fetch( const Char *label ); ///< Returns the associated labeled unicode text protected: Int m_textCount; @@ -1045,7 +1045,7 @@ Bool GameTextManager::parseStringFile( char *filename ) // *GameTextManager::fetch //============================================================================ -const WideChar* GameTextManager::fetch( const Char* label ) +const WideChar * GameTextManager::fetch( const Char *label ) { DEBUG_ASSERTCRASH ( m_initialized, ("String Manager has not been m_initialized") ); diff --git a/Core/Tools/Autorun/GameText.h b/Core/Tools/Autorun/GameText.h index 4c589268b4f..f9b58e8b9e0 100644 --- a/Core/Tools/Autorun/GameText.h +++ b/Core/Tools/Autorun/GameText.h @@ -62,7 +62,7 @@ class GameTextInterface virtual ~GameTextInterface() {}; virtual void init() = 0; ///< Initlaizes the text system - virtual const WideChar* fetch( const char* label ) = 0; ///< Returns the associated labeled unicode text + virtual const WideChar * fetch( const char *label ) = 0; ///< Returns the associated labeled unicode text }; diff --git a/Core/Tools/Autorun/Locale_API.cpp b/Core/Tools/Autorun/Locale_API.cpp index 3b07a1aec93..f6b7ae83cbf 100644 --- a/Core/Tools/Autorun/Locale_API.cpp +++ b/Core/Tools/Autorun/Locale_API.cpp @@ -44,7 +44,7 @@ #define MISSING_STRING_HINTS_MAX (20) -const WideChar* localeStringsMissing[ MISSING_STRING_HINTS_MAX ] = +const WideChar *localeStringsMissing[ MISSING_STRING_HINTS_MAX ] = { { L"0 MissingInstall" }, { L"1 MissingExplore" }, @@ -104,7 +104,7 @@ int SubLanguage = SUBLANG_DEFAULT; /****************************************************************************/ /* LOCALE API */ /****************************************************************************/ -WideChar* Remove_Quotes_Around_String ( WideChar* old_string ); +WideChar * Remove_Quotes_Around_String ( WideChar *old_string ); //============================================================================= @@ -315,9 +315,9 @@ const char* Locale_GetString( int StringID, char *String ) memset( wide_buffer, '\0', _MAX_PATH ); #if( USE_MULTI_FILE_FORMAT ) - wcscpy( wide_buffer, (WideChar*)LOCALE_getstring( StringID )); + wcscpy( wide_buffer, (WideChar *)LOCALE_getstring( StringID )); #else - wcscpy( wide_buffer, (WideChar*)LOCALE_getstr( LocaleFile, StringID )); + wcscpy( wide_buffer, (WideChar *)LOCALE_getstr( LocaleFile, StringID )); #endif Remove_Quotes_Around_String( wide_buffer ); @@ -330,11 +330,11 @@ const char* Locale_GetString( int StringID, char *String ) return buffer; } -const WideChar* Locale_GetString( const char* id, WideChar* buffer, int size ) +const WideChar* Locale_GetString( const char *id, WideChar *buffer, int size ) { if (TheGameText) { - const WideChar* fetched = TheGameText->fetch(id); + const WideChar *fetched = TheGameText->fetch(id); if (buffer) { wcsncpy(buffer, fetched, size); @@ -346,20 +346,20 @@ const WideChar* Locale_GetString( const char* id, WideChar* buffer, int size ) } /* -const WideChar* Locale_GetString( int StringID, WideChar* String ) +const WideChar* Locale_GetString( int StringID, WideChar *String ) { static WideChar wide_buffer[ _MAX_PATH ]; memset( wide_buffer, '\0', _MAX_PATH ); #if( USE_MULTI_FILE_FORMAT ) - wcscpy( wide_buffer, (WideChar*)LOCALE_getstring( StringID )); + wcscpy( wide_buffer, (WideChar *)LOCALE_getstring( StringID )); #else - WideChar* localeStr = nullptr; + WideChar *localeStr = nullptr; if (TheGameText != nullptr) - localeStr = (WideChar*)TheGameText->fetch( s_stringLabels[StringID] ); + localeStr = (WideChar *)TheGameText->fetch( s_stringLabels[StringID] ); if (localeStr == nullptr) { @@ -385,10 +385,10 @@ const WideChar* Locale_GetString( int StringID, WideChar* String ) /* formating strings */ /****************************************************************************/ -WideChar* Remove_Quotes_Around_String ( WideChar* old_string ) +WideChar *Remove_Quotes_Around_String ( WideChar *old_string ) { WideChar wide_buffer[ _MAX_PATH ]; - WideChar* letter = old_string; + WideChar *letter = old_string; int length; //---------------------------------------------------------------------- diff --git a/Core/Tools/Autorun/Locale_API.h b/Core/Tools/Autorun/Locale_API.h index fd038bdbe0a..754d903c6da 100644 --- a/Core/Tools/Autorun/Locale_API.h +++ b/Core/Tools/Autorun/Locale_API.h @@ -53,10 +53,10 @@ extern int SubLanguage; /****************************************************************************/ int Locale_Init ( int language, char *file ); void Locale_Restore (); -const WideChar* Locale_GetString( const char* id, WideChar* buffer = nullptr, int size = _MAX_PATH ); +const WideChar* Locale_GetString( const char *id, WideChar *buffer = nullptr, int size = _MAX_PATH ); /* const char* Locale_GetString ( int StringID, char *String ); -const WideChar* Locale_GetString ( int StringID, WideChar* String=nullptr ); +const WideChar* Locale_GetString ( int StringID, WideChar *String=nullptr ); */ bool Locale_Use_Multi_Language_Files (); //int Locale_Get_Language_ID () { return LanguageID; }; diff --git a/Core/Tools/Autorun/TTFont.cpp b/Core/Tools/Autorun/TTFont.cpp index 68e1cfe3a5c..b1cb79da2ce 100644 --- a/Core/Tools/Autorun/TTFont.cpp +++ b/Core/Tools/Autorun/TTFont.cpp @@ -663,7 +663,7 @@ int TTFontClass::Set_YSpacing( int y ) Point2D TTFontClass::Print( HDC hdc, - const WideChar* string, + WideChar const * string, Rect const & cliprect, COLORREF forecolor, /* = TEXT_COLOR, */ COLORREF backcolor, /* = TEXT_SHADOW_COLOR, */ @@ -683,7 +683,7 @@ Point2D TTFontClass::Print( Point2D TTFontClass::Print( HDC hdc, - const WideChar* string, + WideChar const * string, Rect const & cliprect, COLORREF forecolor, /* = TEXT_COLOR, */ COLORREF backcolor, /* = TEXT_SHADOW_COLOR, */ diff --git a/Core/Tools/Autorun/TTFont.h b/Core/Tools/Autorun/TTFont.h index 8db2a9d2f7f..f98fcd7af5b 100644 --- a/Core/Tools/Autorun/TTFont.h +++ b/Core/Tools/Autorun/TTFont.h @@ -235,7 +235,7 @@ class TTFontClass virtual Point2D Print( HDC hdc, - const WideChar* string, + WideChar const * string, Rect const & cliprect, COLORREF forecolor = TEXT_COLOR, COLORREF backcolor = TEXT_NORMAL_SHADOW_COLOR, diff --git a/Core/Tools/Autorun/Utils.cpp b/Core/Tools/Autorun/Utils.cpp index 282e5a86871..cb15e02f6d4 100644 --- a/Core/Tools/Autorun/Utils.cpp +++ b/Core/Tools/Autorun/Utils.cpp @@ -131,11 +131,11 @@ void Fix_Single_Ampersands ( LPSTR pszString, bool upper_case ) strcpy((LPSTR)pszString, (LPSTR)pszTemp ); } -void Fix_Single_Ampersands ( WideChar* pszString, bool upper_case ) +void Fix_Single_Ampersands ( WideChar *pszString, bool upper_case ) { WideChar pszTemp[ MAX_PATH ]; // variable to hold the string passed WideChar pszOld[ MAX_PATH ]; // variable to hold the string passed - WideChar* letter; + WideChar *letter; int i = 0; wcscpy( pszOld, pszString ); @@ -358,13 +358,13 @@ char *Make_Current_Path_To ( const char *filename, char *path ) return( path ); } -WideChar* Make_Current_Path_To ( const WideChar* filename, WideChar* path ) +WideChar *Make_Current_Path_To ( const WideChar *filename, WideChar *path ) { WideChar szPath [ _MAX_PATH ]; WideChar drive [ _MAX_DRIVE]; WideChar dir [ _MAX_DIR ]; - wcscpy( szPath, (WideChar*)Args->Get_argv(0)); + wcscpy( szPath, (WideChar *)Args->Get_argv(0)); _wsplitpath( szPath, drive, dir, nullptr, nullptr ); _wmakepath( szPath, drive, dir, nullptr, nullptr ); Path_Add_Back_Slash( szPath ); @@ -400,7 +400,7 @@ char *Path_Add_Back_Slash ( char *path ) return( path ); } -WideChar* Path_Add_Back_Slash ( WideChar* path ) +WideChar *Path_Add_Back_Slash ( WideChar *path ) { if ( path != nullptr && *path != '\0' ) { if ( path[ wcslen( path )-1 ] != '\\' ) { @@ -434,7 +434,7 @@ char *Path_Remove_Back_Slash ( char *path ) return( path ); } -WideChar* Path_Remove_Back_Slash ( WideChar* path ) +WideChar *Path_Remove_Back_Slash ( WideChar *path ) { if ( path != nullptr && *path != '\0' ) { if ( path[ wcslen( path )-1 ] == L'\\' ) { @@ -602,14 +602,14 @@ void PlugInProductName( char *szString, int nName ) /* */ /*--------------------------------------------------------------------------*/ -void PlugInProductName ( WideChar* szString, const WideChar* szName ) +void PlugInProductName ( WideChar *szString, const WideChar *szName ) { int nCount, nMsgLength; WideChar szTextBuf[ MAX_PATH ]; WideChar szOut[ MAX_PATH ]; WideChar szProduct[ MAX_PATH ]; - WideChar* temp = nullptr; - WideChar* next = nullptr; + WideChar *temp = nullptr; + WideChar *next = nullptr; if ( szName == nullptr || szName[0] == '\0' ) { return; diff --git a/Core/Tools/Autorun/Utils.h b/Core/Tools/Autorun/Utils.h index 0d5e4ed8625..df311876918 100644 --- a/Core/Tools/Autorun/Utils.h +++ b/Core/Tools/Autorun/Utils.h @@ -54,17 +54,17 @@ void swap( T & left, T & right ) void Fix_Single_Ampersands ( LPSTR pszString, bool upper_case ); -void Fix_Single_Ampersands ( WideChar* pszString, bool upper_case ); +void Fix_Single_Ampersands ( WideChar *pszString, bool upper_case ); //UnicodeString Fix_Single_Ampersands ( UnicodeString string, bool upper_case); void Fix_Double_Ampersands ( LPSTR string, bool upper_case ); void * Load_Alloc_Data ( char *filename, long *filesize=0 ); void * Load_File ( char *filename, long *filesize=0 ); char * Make_Current_Path_To ( const char *filename, char *path ); -WideChar* Make_Current_Path_To ( const WideChar* filename, WideChar* path ); +WideChar * Make_Current_Path_To ( const WideChar *filename, WideChar *path ); char * Path_Add_Back_Slash ( char *path ); char * Path_Remove_Back_Slash ( char *path ); -WideChar* Path_Add_Back_Slash ( WideChar* path ); -WideChar* Path_Remove_Back_Slash ( WideChar* path ); +WideChar * Path_Add_Back_Slash ( WideChar *path ); +WideChar * Path_Remove_Back_Slash ( WideChar *path ); void PlugInProductName ( char *szString, int nName ); void PlugInProductName ( char *szString, char *szName ); -void PlugInProductName ( WideChar* szString, const WideChar* szName ); +void PlugInProductName ( WideChar *szString, const WideChar *szName ); diff --git a/Core/Tools/Autorun/Wnd_File.h b/Core/Tools/Autorun/Wnd_File.h index 35453063c66..7293e5181be 100644 --- a/Core/Tools/Autorun/Wnd_File.h +++ b/Core/Tools/Autorun/Wnd_File.h @@ -94,7 +94,7 @@ #ifdef RTS_DEBUG void __cdecl Msg( int line, const char *file, const char *fmt, ... ); -void __cdecl Msg( int line, const char* filename, const WideChar* fmt, unsigned int codepage=1252, ... ); +void __cdecl Msg( int line, const char *filename, const WideChar *fmt, unsigned int codepage=1252, ... ); void Delete_Msg_File(); #else #define Msg diff --git a/Core/Tools/Autorun/Wnd_file.cpp b/Core/Tools/Autorun/Wnd_file.cpp index 63ef65583da..48557b76583 100644 --- a/Core/Tools/Autorun/Wnd_file.cpp +++ b/Core/Tools/Autorun/Wnd_file.cpp @@ -170,8 +170,8 @@ void __cdecl Msg( int line, const char *filename, const char *fmt, ... ) * MSG -- Write Message to Debug file with line and filename. * * * * INPUT: int line -- line where message originated. * - * WideChar* filename -- file where message originated. * - * WideChar* fmt -- variable argument list. * + * WideChar *filename -- file where message originated. * + * WideChar *fmt -- variable argument list. * * * * OUTPUT: none. * * * @@ -181,7 +181,7 @@ void __cdecl Msg( int line, const char *filename, const char *fmt, ... ) * 08/19/1998 MML : Created. * *==========================================================================*/ -void __cdecl Msg( int line, const char* filename, const WideChar* fmt, UINT codepage, ... ) +void __cdecl Msg( int line, const char *filename, const WideChar *fmt, UINT codepage, ... ) { WideChar szBuffer1[ MAX_PATH * 3 ]; WideChar szBuffer2[ MAX_PATH * 3 ]; diff --git a/Core/Tools/Autorun/autorun.cpp b/Core/Tools/Autorun/autorun.cpp index caeed6da54a..8e24301b376 100644 --- a/Core/Tools/Autorun/autorun.cpp +++ b/Core/Tools/Autorun/autorun.cpp @@ -3751,7 +3751,7 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param wFileName = Locale_GetString(HELP_FILENAME); std::string fname; - const WideChar* tmp = wFileName.c_str(); + const WideChar *tmp = wFileName.c_str(); char hack[2] = "a"; while (*tmp) { diff --git a/Core/Tools/Autorun/locale.cpp b/Core/Tools/Autorun/locale.cpp index 9407a207f4f..5bc088aaba1 100644 --- a/Core/Tools/Autorun/locale.cpp +++ b/Core/Tools/Autorun/locale.cpp @@ -769,7 +769,7 @@ const char* LOCALE_getstring( int StringID ) p = nullptr; } - Msg( __LINE__, __FILE__, L"%s", 1252, (WideChar*)p ); + Msg( __LINE__, __FILE__, L"%s", 1252, (WideChar *)p ); return p; } diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/playerlistdlg.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/playerlistdlg.cpp index 9c3c1a34bfe..645eb03e12f 100644 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/playerlistdlg.cpp +++ b/GeneralsMD/Code/Tools/WorldBuilder/src/playerlistdlg.cpp @@ -845,7 +845,7 @@ void PlayerListDlg::OnChangePlayerdisplayname() } static void addSide(SidesList *sides, AsciiString faction, - AsciiString playerName, const WideChar* playerUName) + AsciiString playerName, const WideChar *playerUName) { if (!sides->findSideInfo(playerName)) { From 69cf17e980522b9b82a2508dd660111fca4b1f1f Mon Sep 17 00:00:00 2001 From: Jacob Ledbetter Date: Sun, 4 Oct 2026 08:47:26 -0600 Subject: [PATCH 6/6] refactor: use shared unichar in Autorun and Babylon --- Core/Tools/Autorun/DrawButton.cpp | 2 +- Core/Tools/Autorun/DrawButton.h | 6 +++--- Core/Tools/Autorun/GameText.cpp | 24 +++++++++++----------- Core/Tools/Autorun/GameText.h | 2 +- Core/Tools/Autorun/Locale_API.cpp | 30 +++++++++++++-------------- Core/Tools/Autorun/Locale_API.h | 4 ++-- Core/Tools/Autorun/TTFont.cpp | 4 ++-- Core/Tools/Autorun/TTFont.h | 2 +- Core/Tools/Autorun/Utils.cpp | 34 +++++++++++++++---------------- Core/Tools/Autorun/Utils.h | 10 ++++----- Core/Tools/Autorun/Wnd_File.h | 2 +- Core/Tools/Autorun/Wnd_file.cpp | 14 ++++++------- Core/Tools/Autorun/autorun.cpp | 26 +++++++++++------------ Core/Tools/Autorun/locale.cpp | 2 +- Core/Tools/Babylon/transcs.cpp | 4 ++-- 15 files changed, 83 insertions(+), 83 deletions(-) diff --git a/Core/Tools/Autorun/DrawButton.cpp b/Core/Tools/Autorun/DrawButton.cpp index 548a27844b7..f5486acb0fa 100644 --- a/Core/Tools/Autorun/DrawButton.cpp +++ b/Core/Tools/Autorun/DrawButton.cpp @@ -153,7 +153,7 @@ DrawButton::DrawButton ( int id, RECT button_rect, const char *normal, const cha Msg( __LINE__, TEXT(__FILE__), TEXT(" MyRect = [%d,%d,%d,%d]"), MyRect.X, MyRect.Y, MyRect.Width, MyRect.Height ); } -DrawButton::DrawButton ( int id, RECT button_rect, const char *normal, const char *focus, const char *pressed, const WideChar *string, TTFontClass *fontptr ) +DrawButton::DrawButton ( int id, RECT button_rect, const char *normal, const char *focus, const char *pressed, const unichar *string, TTFontClass *fontptr ) { Id = id; diff --git a/Core/Tools/Autorun/DrawButton.h b/Core/Tools/Autorun/DrawButton.h index c8bbe1b8877..b3e66d9c63c 100644 --- a/Core/Tools/Autorun/DrawButton.h +++ b/Core/Tools/Autorun/DrawButton.h @@ -52,7 +52,7 @@ class DrawButton }; DrawButton ( int id, RECT button_rect, const char *normal, const char *focus, const char *pressed, const char *string, TTFontClass *fontptr ); - DrawButton ( int id, RECT button_rect, const char *normal, const char *focus, const char *pressed, const WideChar *string, TTFontClass *fontptr ); + DrawButton ( int id, RECT button_rect, const char *normal, const char *focus, const char *pressed, const unichar *string, TTFontClass *fontptr ); char *Return_Normal_Bitmap () { return NormalBitmap; }; char *Return_Pressed_Bitmap () { return PressedBitmap; }; @@ -76,7 +76,7 @@ class DrawButton void Return_Area ( Rect *area ); void Return_Text_Area ( Rect *area ); TTFontClass *Return_Font_Ptr () { return( MyFontPtr ); }; - WideChar *Return_Text () { return( String ); }; + unichar *Return_Text () { return( String ); }; void Set_State ( BUTTON_STATE state ) { ButtonState = state; }; int Set_Stretched_Width ( int ); int Set_Stretched_Height ( int ); @@ -93,7 +93,7 @@ class DrawButton bool UseBitmaps; TTFontClass *MyFontPtr; - WideChar String[ MAX_PATH ]; + unichar String[ MAX_PATH ]; char NormalBitmap [ _MAX_FNAME ]; char PressedBitmap[ _MAX_FNAME ]; char FocusBitmap [ _MAX_FNAME ]; diff --git a/Core/Tools/Autorun/GameText.cpp b/Core/Tools/Autorun/GameText.cpp index 12831cbdbba..05b4d0473f4 100644 --- a/Core/Tools/Autorun/GameText.cpp +++ b/Core/Tools/Autorun/GameText.cpp @@ -142,7 +142,7 @@ class GameTextManager : public GameTextInterface virtual void update() {}; ///< update text manager virtual void reset(); ///< Resets the text system - virtual const WideChar * fetch( const Char *label ); ///< Returns the associated labeled unicode text + virtual const unichar * fetch( const Char *label ); ///< Returns the associated labeled unicode text protected: Int m_textCount; @@ -150,7 +150,7 @@ class GameTextManager : public GameTextInterface Char m_buffer[MAX_UITEXT_LENGTH]; Char m_buffer2[MAX_UITEXT_LENGTH]; Char m_buffer3[MAX_UITEXT_LENGTH]; - WideChar m_tbuffer[MAX_UITEXT_LENGTH*2]; + unichar m_tbuffer[MAX_UITEXT_LENGTH*2]; StringInfo *m_stringInfo; StringLookUp *m_stringLUT; @@ -161,11 +161,11 @@ class GameTextManager : public GameTextInterface Int m_useStringFile; stl::wstring m_failed; - void stripSpaces ( WideChar *string ); + void stripSpaces ( unichar *string ); void removeLeadingAndTrailing ( Char *m_buffer ); void readToEndOfQuote( File *file, Char *in, Char *out, Char *wavefile, Int maxBufLen ); void reverseWord ( Char *file, Char *lp ); - void translateCopy( WideChar *outbuf, Char *inbuf ); + void translateCopy( unichar *outbuf, Char *inbuf ); Bool getStringCount( Char *filename); Bool getCSFInfo ( Char *filename ); Bool parseCSF( Char *filename ); @@ -380,10 +380,10 @@ void GameTextManager::reset() // GameTextManager::stripSpaces //============================================================================ -void GameTextManager::stripSpaces ( WideChar *string ) +void GameTextManager::stripSpaces ( unichar *string ) { - WideChar *str, *ptr; - WideChar ch, last = 0; + unichar *str, *ptr; + unichar ch, last = 0; Int skipall = TRUE; str = ptr = string; @@ -627,7 +627,7 @@ void GameTextManager::reverseWord ( Char *file, Char *lp ) // GameTextManager::translateCopy //============================================================================ -void GameTextManager::translateCopy( WideChar *outbuf, Char *inbuf ) +void GameTextManager::translateCopy( unichar *outbuf, Char *inbuf ) { Bool slash = FALSE; @@ -884,7 +884,7 @@ Bool GameTextManager::parseCSF( Char *filename ) if ( len ) { - file.read ( m_tbuffer, len*sizeof(WideChar) ); + file.read ( m_tbuffer, len*sizeof(unichar) ); } if ( num == 0 ) @@ -893,7 +893,7 @@ Bool GameTextManager::parseCSF( Char *filename ) m_tbuffer[len] = 0; { - WideChar *ptr; + unichar *ptr; ptr = m_tbuffer; @@ -1045,7 +1045,7 @@ Bool GameTextManager::parseStringFile( char *filename ) // *GameTextManager::fetch //============================================================================ -const WideChar * GameTextManager::fetch( const Char *label ) +const unichar * GameTextManager::fetch( const Char *label ) { DEBUG_ASSERTCRASH ( m_initialized, ("String Manager has not been m_initialized") ); @@ -1066,7 +1066,7 @@ const WideChar * GameTextManager::fetch( const Char *label ) if( lookUp == nullptr ) { // See if we already have the missing string - WideChar tmp[256]; + unichar tmp[256]; swprintf(tmp, 256, L"MISSING: '%hs'", label); stl::wstring missingString = tmp; diff --git a/Core/Tools/Autorun/GameText.h b/Core/Tools/Autorun/GameText.h index f9b58e8b9e0..c52fdda3538 100644 --- a/Core/Tools/Autorun/GameText.h +++ b/Core/Tools/Autorun/GameText.h @@ -62,7 +62,7 @@ class GameTextInterface virtual ~GameTextInterface() {}; virtual void init() = 0; ///< Initlaizes the text system - virtual const WideChar * fetch( const char *label ) = 0; ///< Returns the associated labeled unicode text + virtual const unichar * fetch( const char *label ) = 0; ///< Returns the associated labeled unicode text }; diff --git a/Core/Tools/Autorun/Locale_API.cpp b/Core/Tools/Autorun/Locale_API.cpp index f6b7ae83cbf..edf2499ce5e 100644 --- a/Core/Tools/Autorun/Locale_API.cpp +++ b/Core/Tools/Autorun/Locale_API.cpp @@ -44,7 +44,7 @@ #define MISSING_STRING_HINTS_MAX (20) -const WideChar *localeStringsMissing[ MISSING_STRING_HINTS_MAX ] = +const unichar *localeStringsMissing[ MISSING_STRING_HINTS_MAX ] = { { L"0 MissingInstall" }, { L"1 MissingExplore" }, @@ -104,7 +104,7 @@ int SubLanguage = SUBLANG_DEFAULT; /****************************************************************************/ /* LOCALE API */ /****************************************************************************/ -WideChar * Remove_Quotes_Around_String ( WideChar *old_string ); +unichar * Remove_Quotes_Around_String ( unichar *old_string ); //============================================================================= @@ -309,15 +309,15 @@ void Locale_Restore () const char* Locale_GetString( int StringID, char *String ) { static char buffer[ _MAX_PATH ]; - static WideChar wide_buffer[ _MAX_PATH ]; + static unichar wide_buffer[ _MAX_PATH ]; memset( buffer, '\0', _MAX_PATH ); memset( wide_buffer, '\0', _MAX_PATH ); #if( USE_MULTI_FILE_FORMAT ) - wcscpy( wide_buffer, (WideChar *)LOCALE_getstring( StringID )); + wcscpy( wide_buffer, (unichar *)LOCALE_getstring( StringID )); #else - wcscpy( wide_buffer, (WideChar *)LOCALE_getstr( LocaleFile, StringID )); + wcscpy( wide_buffer, (unichar *)LOCALE_getstr( LocaleFile, StringID )); #endif Remove_Quotes_Around_String( wide_buffer ); @@ -330,11 +330,11 @@ const char* Locale_GetString( int StringID, char *String ) return buffer; } -const WideChar* Locale_GetString( const char *id, WideChar *buffer, int size ) +const unichar* Locale_GetString( const char *id, unichar *buffer, int size ) { if (TheGameText) { - const WideChar *fetched = TheGameText->fetch(id); + const unichar *fetched = TheGameText->fetch(id); if (buffer) { wcsncpy(buffer, fetched, size); @@ -346,20 +346,20 @@ const WideChar* Locale_GetString( const char *id, WideChar *buffer, int size ) } /* -const WideChar* Locale_GetString( int StringID, WideChar *String ) +const unichar* Locale_GetString( int StringID, unichar *String ) { - static WideChar wide_buffer[ _MAX_PATH ]; + static unichar wide_buffer[ _MAX_PATH ]; memset( wide_buffer, '\0', _MAX_PATH ); #if( USE_MULTI_FILE_FORMAT ) - wcscpy( wide_buffer, (WideChar *)LOCALE_getstring( StringID )); + wcscpy( wide_buffer, (unichar *)LOCALE_getstring( StringID )); #else - WideChar *localeStr = nullptr; + unichar *localeStr = nullptr; if (TheGameText != nullptr) - localeStr = (WideChar *)TheGameText->fetch( s_stringLabels[StringID] ); + localeStr = (unichar *)TheGameText->fetch( s_stringLabels[StringID] ); if (localeStr == nullptr) { @@ -385,10 +385,10 @@ const WideChar* Locale_GetString( int StringID, WideChar *String ) /* formating strings */ /****************************************************************************/ -WideChar *Remove_Quotes_Around_String ( WideChar *old_string ) +unichar *Remove_Quotes_Around_String ( unichar *old_string ) { - WideChar wide_buffer[ _MAX_PATH ]; - WideChar *letter = old_string; + unichar wide_buffer[ _MAX_PATH ]; + unichar *letter = old_string; int length; //---------------------------------------------------------------------- diff --git a/Core/Tools/Autorun/Locale_API.h b/Core/Tools/Autorun/Locale_API.h index 754d903c6da..7db3dc63797 100644 --- a/Core/Tools/Autorun/Locale_API.h +++ b/Core/Tools/Autorun/Locale_API.h @@ -53,10 +53,10 @@ extern int SubLanguage; /****************************************************************************/ int Locale_Init ( int language, char *file ); void Locale_Restore (); -const WideChar* Locale_GetString( const char *id, WideChar *buffer = nullptr, int size = _MAX_PATH ); +const unichar* Locale_GetString( const char *id, unichar *buffer = nullptr, int size = _MAX_PATH ); /* const char* Locale_GetString ( int StringID, char *String ); -const WideChar* Locale_GetString ( int StringID, WideChar *String=nullptr ); +const unichar* Locale_GetString ( int StringID, unichar *String=nullptr ); */ bool Locale_Use_Multi_Language_Files (); //int Locale_Get_Language_ID () { return LanguageID; }; diff --git a/Core/Tools/Autorun/TTFont.cpp b/Core/Tools/Autorun/TTFont.cpp index b1cb79da2ce..21d5e8e8af9 100644 --- a/Core/Tools/Autorun/TTFont.cpp +++ b/Core/Tools/Autorun/TTFont.cpp @@ -663,7 +663,7 @@ int TTFontClass::Set_YSpacing( int y ) Point2D TTFontClass::Print( HDC hdc, - WideChar const * string, + unichar const * string, Rect const & cliprect, COLORREF forecolor, /* = TEXT_COLOR, */ COLORREF backcolor, /* = TEXT_SHADOW_COLOR, */ @@ -683,7 +683,7 @@ Point2D TTFontClass::Print( Point2D TTFontClass::Print( HDC hdc, - WideChar const * string, + unichar const * string, Rect const & cliprect, COLORREF forecolor, /* = TEXT_COLOR, */ COLORREF backcolor, /* = TEXT_SHADOW_COLOR, */ diff --git a/Core/Tools/Autorun/TTFont.h b/Core/Tools/Autorun/TTFont.h index f98fcd7af5b..a50aa107d69 100644 --- a/Core/Tools/Autorun/TTFont.h +++ b/Core/Tools/Autorun/TTFont.h @@ -235,7 +235,7 @@ class TTFontClass virtual Point2D Print( HDC hdc, - WideChar const * string, + unichar const * string, Rect const & cliprect, COLORREF forecolor = TEXT_COLOR, COLORREF backcolor = TEXT_NORMAL_SHADOW_COLOR, diff --git a/Core/Tools/Autorun/Utils.cpp b/Core/Tools/Autorun/Utils.cpp index cb15e02f6d4..afcfb93b514 100644 --- a/Core/Tools/Autorun/Utils.cpp +++ b/Core/Tools/Autorun/Utils.cpp @@ -131,11 +131,11 @@ void Fix_Single_Ampersands ( LPSTR pszString, bool upper_case ) strcpy((LPSTR)pszString, (LPSTR)pszTemp ); } -void Fix_Single_Ampersands ( WideChar *pszString, bool upper_case ) +void Fix_Single_Ampersands ( unichar *pszString, bool upper_case ) { - WideChar pszTemp[ MAX_PATH ]; // variable to hold the string passed - WideChar pszOld[ MAX_PATH ]; // variable to hold the string passed - WideChar *letter; + unichar pszTemp[ MAX_PATH ]; // variable to hold the string passed + unichar pszOld[ MAX_PATH ]; // variable to hold the string passed + unichar *letter; int i = 0; wcscpy( pszOld, pszString ); @@ -358,13 +358,13 @@ char *Make_Current_Path_To ( const char *filename, char *path ) return( path ); } -WideChar *Make_Current_Path_To ( const WideChar *filename, WideChar *path ) +unichar *Make_Current_Path_To ( const unichar *filename, unichar *path ) { - WideChar szPath [ _MAX_PATH ]; - WideChar drive [ _MAX_DRIVE]; - WideChar dir [ _MAX_DIR ]; + unichar szPath [ _MAX_PATH ]; + unichar drive [ _MAX_DRIVE]; + unichar dir [ _MAX_DIR ]; - wcscpy( szPath, (WideChar *)Args->Get_argv(0)); + wcscpy( szPath, (unichar *)Args->Get_argv(0)); _wsplitpath( szPath, drive, dir, nullptr, nullptr ); _wmakepath( szPath, drive, dir, nullptr, nullptr ); Path_Add_Back_Slash( szPath ); @@ -400,7 +400,7 @@ char *Path_Add_Back_Slash ( char *path ) return( path ); } -WideChar *Path_Add_Back_Slash ( WideChar *path ) +unichar *Path_Add_Back_Slash ( unichar *path ) { if ( path != nullptr && *path != '\0' ) { if ( path[ wcslen( path )-1 ] != '\\' ) { @@ -434,7 +434,7 @@ char *Path_Remove_Back_Slash ( char *path ) return( path ); } -WideChar *Path_Remove_Back_Slash ( WideChar *path ) +unichar *Path_Remove_Back_Slash ( unichar *path ) { if ( path != nullptr && *path != '\0' ) { if ( path[ wcslen( path )-1 ] == L'\\' ) { @@ -602,14 +602,14 @@ void PlugInProductName( char *szString, int nName ) /* */ /*--------------------------------------------------------------------------*/ -void PlugInProductName ( WideChar *szString, const WideChar *szName ) +void PlugInProductName ( unichar *szString, const unichar *szName ) { int nCount, nMsgLength; - WideChar szTextBuf[ MAX_PATH ]; - WideChar szOut[ MAX_PATH ]; - WideChar szProduct[ MAX_PATH ]; - WideChar *temp = nullptr; - WideChar *next = nullptr; + unichar szTextBuf[ MAX_PATH ]; + unichar szOut[ MAX_PATH ]; + unichar szProduct[ MAX_PATH ]; + unichar *temp = nullptr; + unichar *next = nullptr; if ( szName == nullptr || szName[0] == '\0' ) { return; diff --git a/Core/Tools/Autorun/Utils.h b/Core/Tools/Autorun/Utils.h index df311876918..157b493c7c0 100644 --- a/Core/Tools/Autorun/Utils.h +++ b/Core/Tools/Autorun/Utils.h @@ -54,17 +54,17 @@ void swap( T & left, T & right ) void Fix_Single_Ampersands ( LPSTR pszString, bool upper_case ); -void Fix_Single_Ampersands ( WideChar *pszString, bool upper_case ); +void Fix_Single_Ampersands ( unichar *pszString, bool upper_case ); //UnicodeString Fix_Single_Ampersands ( UnicodeString string, bool upper_case); void Fix_Double_Ampersands ( LPSTR string, bool upper_case ); void * Load_Alloc_Data ( char *filename, long *filesize=0 ); void * Load_File ( char *filename, long *filesize=0 ); char * Make_Current_Path_To ( const char *filename, char *path ); -WideChar * Make_Current_Path_To ( const WideChar *filename, WideChar *path ); +unichar * Make_Current_Path_To ( const unichar *filename, unichar *path ); char * Path_Add_Back_Slash ( char *path ); char * Path_Remove_Back_Slash ( char *path ); -WideChar * Path_Add_Back_Slash ( WideChar *path ); -WideChar * Path_Remove_Back_Slash ( WideChar *path ); +unichar * Path_Add_Back_Slash ( unichar *path ); +unichar * Path_Remove_Back_Slash ( unichar *path ); void PlugInProductName ( char *szString, int nName ); void PlugInProductName ( char *szString, char *szName ); -void PlugInProductName ( WideChar *szString, const WideChar *szName ); +void PlugInProductName ( unichar *szString, const unichar *szName ); diff --git a/Core/Tools/Autorun/Wnd_File.h b/Core/Tools/Autorun/Wnd_File.h index 7293e5181be..c92c083638c 100644 --- a/Core/Tools/Autorun/Wnd_File.h +++ b/Core/Tools/Autorun/Wnd_File.h @@ -94,7 +94,7 @@ #ifdef RTS_DEBUG void __cdecl Msg( int line, const char *file, const char *fmt, ... ); -void __cdecl Msg( int line, const char *filename, const WideChar *fmt, unsigned int codepage=1252, ... ); +void __cdecl Msg( int line, const char *filename, const unichar *fmt, unsigned int codepage=1252, ... ); void Delete_Msg_File(); #else #define Msg diff --git a/Core/Tools/Autorun/Wnd_file.cpp b/Core/Tools/Autorun/Wnd_file.cpp index 48557b76583..9b636dab1c9 100644 --- a/Core/Tools/Autorun/Wnd_file.cpp +++ b/Core/Tools/Autorun/Wnd_file.cpp @@ -170,8 +170,8 @@ void __cdecl Msg( int line, const char *filename, const char *fmt, ... ) * MSG -- Write Message to Debug file with line and filename. * * * * INPUT: int line -- line where message originated. * - * WideChar *filename -- file where message originated. * - * WideChar *fmt -- variable argument list. * + * unichar *filename -- file where message originated. * + * unichar *fmt -- variable argument list. * * * * OUTPUT: none. * * * @@ -181,13 +181,13 @@ void __cdecl Msg( int line, const char *filename, const char *fmt, ... ) * 08/19/1998 MML : Created. * *==========================================================================*/ -void __cdecl Msg( int line, const char *filename, const WideChar *fmt, UINT codepage, ... ) +void __cdecl Msg( int line, const char *filename, const unichar *fmt, UINT codepage, ... ) { - WideChar szBuffer1[ MAX_PATH * 3 ]; - WideChar szBuffer2[ MAX_PATH * 3 ]; + unichar szBuffer1[ MAX_PATH * 3 ]; + unichar szBuffer2[ MAX_PATH * 3 ]; char szBuffer3[ MAX_PATH * 3 ]; - WideChar szFile[ MAX_PATH ]; - WideChar szArgs[ MAX_PATH ]; + unichar szFile[ MAX_PATH ]; + unichar szArgs[ MAX_PATH ]; va_list va; int length; DWORD nBytes; diff --git a/Core/Tools/Autorun/autorun.cpp b/Core/Tools/Autorun/autorun.cpp index 8e24301b376..2a7c440a708 100644 --- a/Core/Tools/Autorun/autorun.cpp +++ b/Core/Tools/Autorun/autorun.cpp @@ -221,12 +221,12 @@ char szProduct_Name [ _MAX_PATH ]; #ifdef LEAN_AND_MEAN -WideChar szWideBuffer [ _MAX_PATH ]; -WideChar szWideBuffer0 [ _MAX_PATH ]; -WideChar szWideBuffer2 [ _MAX_PATH ]; -WideChar szWideBuffer3 [ _MAX_PATH ]; -WideChar szProductName [ _MAX_PATH ]; -WideChar szFullProductName [ _MAX_PATH ]; +unichar szWideBuffer [ _MAX_PATH ]; +unichar szWideBuffer0 [ _MAX_PATH ]; +unichar szWideBuffer2 [ _MAX_PATH ]; +unichar szWideBuffer3 [ _MAX_PATH ]; +unichar szProductName [ _MAX_PATH ]; +unichar szFullProductName [ _MAX_PATH ]; /* enum @@ -1231,7 +1231,7 @@ BOOL MainWindow::Is_Product_Registered() BOOL result = FALSE; char key [_MAX_PATH]; - WideChar szPath [_MAX_PATH]; + unichar szPath [_MAX_PATH]; char aName [_MAX_PATH]; //jfs unsigned long Type; @@ -2566,9 +2566,9 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param static char szLicense[ _MAX_PATH ]; static char szButtonBitmap[_MAX_PATH]; - static WideChar szString1[ 500 ]; - static WideChar szString2[ 500 ]; - static WideChar szWholeString[ 1000 ]; + static unichar szString1[ 500 ]; + static unichar szString2[ 500 ]; + static unichar szWholeString[ 1000 ]; // static wchar_t szWSMsg1[ _MAX_PATH ]; #ifdef LEAN_AND_MEAN @@ -2577,8 +2577,8 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param static UnicodeString wsMsg1; #endif - static WideChar szWSMsg2[ _MAX_PATH ]; - static WideChar szWholeWSMsg[ 1000 ]; + static unichar szWSMsg2[ _MAX_PATH ]; + static unichar szWholeWSMsg[ 1000 ]; // static wchar_t szInstallWarningMsg[ _MAX_PATH ]; static HBITMAP hBitmap = 0; @@ -3751,7 +3751,7 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param wFileName = Locale_GetString(HELP_FILENAME); std::string fname; - const WideChar *tmp = wFileName.c_str(); + const unichar *tmp = wFileName.c_str(); char hack[2] = "a"; while (*tmp) { diff --git a/Core/Tools/Autorun/locale.cpp b/Core/Tools/Autorun/locale.cpp index 5bc088aaba1..a8ac5ae3d15 100644 --- a/Core/Tools/Autorun/locale.cpp +++ b/Core/Tools/Autorun/locale.cpp @@ -769,7 +769,7 @@ const char* LOCALE_getstring( int StringID ) p = nullptr; } - Msg( __LINE__, __FILE__, L"%s", 1252, (WideChar *)p ); + Msg( __LINE__, __FILE__, L"%s", 1252, (unichar *)p ); return p; } diff --git a/Core/Tools/Babylon/transcs.cpp b/Core/Tools/Babylon/transcs.cpp index 764b35aede5..660a6b4dac2 100644 --- a/Core/Tools/Babylon/transcs.cpp +++ b/Core/Tools/Babylon/transcs.cpp @@ -32,8 +32,8 @@ void CreateTranslationTable () { int i; FILE *out; - WideChar wc; - WideChar mb; + unichar wc; + unichar mb; DWORD last_error; if ( ( out = fopen ( "utable.c", "wt" )) == nullptr)