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/Include/GameNetwork/GameSpy/PeerThread.h b/Core/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h index b958d15c0b7..fee7b6b1459 100644 --- a/Core/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h @@ -69,7 +69,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 + stl::wstring text; // can't be in a union std::string password; std::string email; std::string id; @@ -248,13 +248,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 + 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::wstring 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 0db2a8df67e..b9d771a507f 100644 --- a/Core/GameEngine/Include/GameNetwork/GameSpy/ThreadUtils.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpy/ThreadUtils.h @@ -28,5 +28,5 @@ #pragma once -std::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 93c2513baae..409d3500427 100644 --- a/Core/GameEngine/Source/GameClient/LanguageFilter.cpp +++ b/Core/GameEngine/Source/GameClient/LanguageFilter.cpp @@ -50,7 +50,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 +76,7 @@ void LanguageFilter::reset() { void LanguageFilter::update() { } -wchar_t ignoredChars[] = L"-_*'\""; +WideChar ignoredChars[] = L"-_*'\""; void LanguageFilter::filterLine(UnicodeString &line) { @@ -87,7 +87,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 +114,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..0cdaf508714 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp @@ -517,7 +517,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 ); + 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())); @@ -636,7 +636,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 ); + 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 178a1b1ad3c..6e89d5f9315 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PeerThread.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PeerThread.cpp @@ -232,7 +232,7 @@ 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; } + stl::wstring getLocalStagingServerName() { return m_localStagingServerName; } Int getLocalRoomID() { return m_localRoomID; } std::string ladderIP() { return m_ladderIP; } UnsignedShort ladderPort() { return m_ladderPort; } @@ -314,7 +314,7 @@ class PeerThreadClass : public ThreadClass Int m_nextStagingServer; std::map m_stagingServers; - std::wstring 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 84ce0c9b19a..8f5b6a76a49 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp @@ -33,13 +33,13 @@ //------------------------------------------------------------------------- // TheSuperHackers @refactor bobtista 02/04/2026 Use WWLib UTF-8 functions instead of raw Win32 API calls -std::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 std::wstring(); - std::wstring ret; + return stl::wstring(); + 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/Lib/PathUtil.h b/Core/Libraries/Include/Lib/PathUtil.h index 6fcdc91fadf..b114ef87c3e 100644 --- a/Core/Libraries/Include/Lib/PathUtil.h +++ b/Core/Libraries/Include/Lib/PathUtil.h @@ -76,7 +76,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 +108,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/Precompiled/Precompiled/BaseTypes.h b/Core/Libraries/Include/Precompiled/Precompiled/BaseTypes.h index 468bd761e53..3458876d80b 100644 --- a/Core/Libraries/Include/Precompiled/Precompiled/BaseTypes.h +++ b/Core/Libraries/Include/Precompiled/Precompiled/BaseTypes.h @@ -34,6 +34,6 @@ typedef char Byte; typedef unsigned char UnsignedByte; typedef char Char; -typedef wchar_t WideChar; +typedef unichar WideChar; typedef bool Bool; diff --git a/Core/Libraries/Source/WWVegas/WWLib/INI.h b/Core/Libraries/Source/WWVegas/WWLib/INI.h index a1dc6fbbe4a..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, char const * section, char const * entry, wchar_t const * 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(char const * section, char const * entry, wchar_t const * string); + bool Put_Wide_String(char const * section, char const * entry, unichar const * string); // protected: diff --git a/Core/Libraries/Source/WWVegas/WWLib/ini.cpp b/Core/Libraries/Source/WWVegas/WWLib/ini.cpp index 0b32b043afc..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, char const * section, char const * entry, wchar_t const * defvalue) const +const WideStringClass& INIClass::Get_Wide_String(WideStringClass& new_string, char const * section, char const * entry, unichar const * defvalue) const { - wchar_t 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, 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(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 a63730e8198..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, wchar_t * 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 (;;) { - wchar_t 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 1a9f019cc56..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, wchar_t * 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 ccc97c2ff88..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) } -wchar_t* wcstrim(wchar_t* buffer) +unichar* wcstrim(unichar* buffer) { if (buffer) { /* Strip leading white space from the string. */ - wchar_t* source = buffer; + unichar* source = buffer; while ((*source != 0) && ((unsigned int)*source <= 32)) { ++source; @@ -97,7 +97,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(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 cdb550eaa9a..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); -wchar_t * wcstrim(wchar_t * buffer); +unichar * wcstrim(unichar * buffer); diff --git a/Core/Libraries/Source/WWVegas/WWLib/utf8.cpp b/Core/Libraries/Source/WWVegas/WWLib/utf8.cpp index 578299fbe3d..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" -// wchar_t 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 wchar_t 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 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 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 wchar_t* 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(wchar_t* 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] = (wchar_t)(0xD800 + (cp >> 10)); - dest[1] = (wchar_t)(0xDC00 + (cp & 0x3FF)); + dest[0] = (unichar)(0xD800 + (cp >> 10)); + dest[1] = (unichar)(0xDC00 + (cp & 0x3FF)); return 2; } #endif - dest[0] = (wchar_t)cp; + dest[0] = (unichar)cp; return 1; } -size_t Wide_To_Utf8_Len(const wchar_t* 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 wchar_t* 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 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(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 0a4f92f95ee..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 wchar_t, 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 wchar_t. +// 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 wchar_t* 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 wchar_t* 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 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(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/Core/Tools/Autorun/DrawButton.cpp b/Core/Tools/Autorun/DrawButton.cpp index 54ac3193ade..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 wchar_t *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 faf44d347fb..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 wchar_t *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 ); }; - wchar_t *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; - wchar_t 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 695bb18fa3a..05b4d0473f4 100644 --- a/Core/Tools/Autorun/GameText.cpp +++ b/Core/Tools/Autorun/GameText.cpp @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include "GameText.h" @@ -90,7 +90,7 @@ struct StringInfo { std::string label; - std::wstring text; + stl::wstring text; std::string speech; }; @@ -122,7 +122,7 @@ struct CSFHeader struct NoString { struct NoString *next; - std::wstring text; + stl::wstring text; }; @@ -142,7 +142,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 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; @@ -159,13 +159,13 @@ class GameTextManager : public GameTextInterface Bool m_munkee; NoString *m_noStringList; Int m_useStringFile; - std::wstring m_failed; + 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 wchar_t * GameTextManager::fetch( const Char *label ) +const unichar * GameTextManager::fetch( const Char *label ) { DEBUG_ASSERTCRASH ( m_initialized, ("String Manager has not been m_initialized") ); @@ -1066,9 +1066,9 @@ const wchar_t * GameTextManager::fetch( const Char *label ) if( lookUp == nullptr ) { // See if we already have the missing string - wchar_t tmp[256]; + unichar tmp[256]; swprintf(tmp, 256, L"MISSING: '%hs'", label); - std::wstring 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 1f23232a51e..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 wchar_t * 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 8312b6b43b1..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 wchar_t *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 */ /****************************************************************************/ -wchar_t * Remove_Quotes_Around_String ( wchar_t *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 wchar_t 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, (wchar_t *)LOCALE_getstring( StringID )); + wcscpy( wide_buffer, (unichar *)LOCALE_getstring( StringID )); #else - wcscpy( wide_buffer, (wchar_t *)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 wchar_t* Locale_GetString( const char *id, wchar_t *buffer, int size ) +const unichar* Locale_GetString( const char *id, unichar *buffer, int size ) { if (TheGameText) { - const wchar_t *fetched = TheGameText->fetch(id); + const unichar *fetched = TheGameText->fetch(id); if (buffer) { wcsncpy(buffer, fetched, size); @@ -346,20 +346,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 unichar* Locale_GetString( int StringID, unichar *String ) { - static wchar_t wide_buffer[ _MAX_PATH ]; + static unichar 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, (unichar *)LOCALE_getstring( StringID )); #else - wchar_t *localeStr = nullptr; + unichar *localeStr = nullptr; if (TheGameText != nullptr) - localeStr = (wchar_t *)TheGameText->fetch( s_stringLabels[StringID] ); + localeStr = (unichar *)TheGameText->fetch( s_stringLabels[StringID] ); if (localeStr == nullptr) { @@ -385,10 +385,10 @@ const wchar_t* Locale_GetString( int StringID, wchar_t *String ) /* formating strings */ /****************************************************************************/ -wchar_t *Remove_Quotes_Around_String ( wchar_t *old_string ) +unichar *Remove_Quotes_Around_String ( unichar *old_string ) { - wchar_t wide_buffer[ _MAX_PATH ]; - wchar_t *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 e5670c1f2bb..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 wchar_t* Locale_GetString( const char *id, wchar_t *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 wchar_t* Locale_GetString ( int StringID, wchar_t *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 b1976282685..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, - wchar_t 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, - wchar_t 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 43823a27c5c..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, - wchar_t 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 565449b0f96..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 ( wchar_t *pszString, bool upper_case ) +void Fix_Single_Ampersands ( unichar *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; + 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 ); } -wchar_t *Make_Current_Path_To ( const wchar_t *filename, wchar_t *path ) +unichar *Make_Current_Path_To ( const unichar *filename, unichar *path ) { - wchar_t szPath [ _MAX_PATH ]; - wchar_t drive [ _MAX_DRIVE]; - wchar_t dir [ _MAX_DIR ]; + unichar szPath [ _MAX_PATH ]; + unichar drive [ _MAX_DRIVE]; + unichar dir [ _MAX_DIR ]; - wcscpy( szPath, (wchar_t *)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 ); } -wchar_t *Path_Add_Back_Slash ( wchar_t *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 ); } -wchar_t *Path_Remove_Back_Slash ( wchar_t *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 ( wchar_t *szString, const wchar_t *szName ) +void PlugInProductName ( unichar *szString, const unichar *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; + 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 894a7e43606..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 ( wchar_t *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 ); -wchar_t * Make_Current_Path_To ( const wchar_t *filename, wchar_t *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 ); -wchar_t * Path_Add_Back_Slash ( wchar_t *path ); -wchar_t * Path_Remove_Back_Slash ( wchar_t *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 ( wchar_t *szString, const wchar_t *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 5e4ece6d874..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 wchar_t *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 fac5af17ef6..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. * - * wchar_t *filename -- file where message originated. * - * wchar_t *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 wchar_t *fmt, UINT codepage, ... ) +void __cdecl Msg( int line, const char *filename, const unichar *fmt, UINT codepage, ... ) { - wchar_t szBuffer1[ MAX_PATH * 3 ]; - wchar_t szBuffer2[ MAX_PATH * 3 ]; + unichar szBuffer1[ MAX_PATH * 3 ]; + unichar szBuffer2[ MAX_PATH * 3 ]; char szBuffer3[ MAX_PATH * 3 ]; - wchar_t szFile[ MAX_PATH ]; - wchar_t 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 5b66de18d54..2a7c440a708 100644 --- a/Core/Tools/Autorun/autorun.cpp +++ b/Core/Tools/Autorun/autorun.cpp @@ -109,7 +109,7 @@ #include "WSYS_FileSystem.h" #include "WSYS_StdFileSystem.h" -#include +#include #include "GameText.h" #include "leanAndMeanAutorun.h" @@ -221,12 +221,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 ]; +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]; - wchar_t 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 wchar_t szString1[ 500 ]; - static wchar_t szString2[ 500 ]; - static wchar_t 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 wchar_t szWSMsg2[ _MAX_PATH ]; - static wchar_t szWholeWSMsg[ 1000 ]; + static unichar szWSMsg2[ _MAX_PATH ]; + static unichar szWholeWSMsg[ 1000 ]; // static wchar_t szInstallWarningMsg[ _MAX_PATH ]; static HBITMAP hBitmap = 0; @@ -3733,8 +3733,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"); + 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(); @@ -3747,11 +3747,11 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param case IDD_HELP: { - std::wstring wFileName; + stl::wstring wFileName; wFileName = Locale_GetString(HELP_FILENAME); std::string fname; - const wchar_t *tmp = wFileName.c_str(); + const unichar *tmp = wFileName.c_str(); char hack[2] = "a"; while (*tmp) { @@ -3778,8 +3778,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"); + 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(); @@ -4804,8 +4804,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"); + 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(); @@ -5068,9 +5068,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"); + 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 e7665813563..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, (wchar_t *)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 67d9f164d2e..660a6b4dac2 100644 --- a/Core/Tools/Babylon/transcs.cpp +++ b/Core/Tools/Babylon/transcs.cpp @@ -32,8 +32,8 @@ void CreateTranslationTable () { int i; FILE *out; - wchar_t wc; - wchar_t mb; + unichar wc; + unichar 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..b15f41ad502 100644 --- a/Core/Tools/Launcher/Toolkit/Support/UTypes.h +++ b/Core/Tools/Launcher/Toolkit/Support/UTypes.h @@ -67,11 +67,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/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..920b0da4a5c 100644 --- a/Dependencies/Precompiled/Precompiled/precompiled.h +++ b/Dependencies/Precompiled/Precompiled/precompiled.h @@ -31,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 new file mode 100644 index 00000000000..80b2ad3fee6 --- /dev/null +++ b/Dependencies/Precompiled/Precompiled/unichar.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 unichar; diff --git a/Dependencies/Utility/CMakeLists.txt b/Dependencies/Utility/CMakeLists.txt index 8f77d663e47..8c6b8f82967 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 diff --git a/Dependencies/Utility/Utility/string_adapter.h b/Dependencies/Utility/Utility/string_adapter.h new file mode 100644 index 00000000000..99c4423f7b3 --- /dev/null +++ b/Dependencies/Utility/Utility/string_adapter.h @@ -0,0 +1,26 @@ +/* +** 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 + +namespace stl +{ +typedef std::basic_string string; +typedef std::basic_string wstring; +} diff --git a/Dependencies/Utility/Utility/stringex.h b/Dependencies/Utility/Utility/stringex.h index c54de55fc57..66472a49e8a 100644 --- a/Dependencies/Utility/Utility/stringex.h +++ b/Dependencies/Utility/Utility/stringex.h @@ -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 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(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(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(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(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); @@ -89,7 +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 wchar_t *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. @@ -137,8 +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(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(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. @@ -181,8 +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(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(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); } @@ -220,9 +220,9 @@ inline char tolower_t(char c) return (char)tolower((unsigned char)c); } -inline wchar_t tolower_t(wchar_t c) +inline unichar tolower_t(unichar c) { - return (wchar_t)towlower(c); + return (unichar)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..e2f1d696707 100644 --- a/Generals/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp +++ b/Generals/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp @@ -226,7 +226,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 +259,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..c58f682eef4 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupReplay.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupReplay.cpp @@ -282,7 +282,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 +307,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..bf9e862a70a 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp @@ -859,7 +859,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..735b1762c27 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp @@ -226,7 +226,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 +259,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..775ebfe0924 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupReplay.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupReplay.cpp @@ -282,7 +282,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 +307,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..f7b0e6ad6f8 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp @@ -859,7 +859,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..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 wchar_t *playerUName) + AsciiString playerName, const WideChar *playerUName) { if (!sides->findSideInfo(playerName)) {