Skip to content

Commit

Permalink
Fix corrupted schinese map txt.
Browse files Browse the repository at this point in the history
  • Loading branch information
hzqst committed Feb 14, 2024
1 parent fa81a2c commit 654f3c0
Showing 1 changed file with 52 additions and 47 deletions.
99 changes: 52 additions & 47 deletions Plugins/VGUI2Extension/ClientVGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,63 +63,68 @@ vgui::BuildGroup_Legacy *GetLegacyBuildGroup(vgui::Panel* pWindow)
return pfnGetBuildGroup(pWindow, 0);
}

#if 0//Fuck Valve
//Fuck Valve
#if 1
void __fastcall ClientVGUI_RichText_SetTextW_Proxy(void* pthis, int dummy, const wchar_t* text)
{
std::wstringstream wss;

auto ch = text;
const char * pbase = (const char*)text;

while (1)
if (!strcmp(GetCurrentGameLanguage(), "schinese"))
{
auto pch = (const char*)ch;
int offset = (pch - pbase);
std::wstringstream wss;

if ((BYTE)pch[0] == (BYTE)0xFF && (BYTE)pch[1] == (BYTE)0x50 && (BYTE)pch[2] == (BYTE)0x60)
{
wss << L"£º¿Ö";
pch += 3;
ch = (const wchar_t*)pch;
continue;
}
auto ch = text;
const char* pbase = (const char*)text;
auto totalLen = wcslen(text);

if ((BYTE)pch[0] == (BYTE)0xFF && (BYTE)pch[1] == (BYTE)0x26 && (BYTE)pch[2] == (BYTE)0x5E)
while (1)
{
wss << L"£º´ø";
pch += 3;
ch = (const wchar_t*)pch;
continue;
}
auto pch = (const char*)ch;
int offset = (pch - pbase);

if ((BYTE)pch[0] == (BYTE)0xFF && (BYTE)pch[1] == (BYTE)0x28 && (BYTE)pch[2] == (BYTE)0x57)
{
wss << L"£ºÔÚ";
pch += 3;
ch = (const wchar_t*)pch;
continue;
}
if (offset >= totalLen * 2)
break;

if ((BYTE)pch[0] == (BYTE)0x4F && (offset % 2) == 1)
{
pch += 1;
ch = (const wchar_t*)pch;
continue;
}
if ((*ch) == L'\0')
break;

if ((*ch) == L'\0')
break;
if ((BYTE)pch[0] == (BYTE)0xFF)
{
wss << L"£º";
pch += 1;
ch = (const wchar_t*)pch;
continue;
}

wss << (*ch);
ch++;
if ((WORD)(*ch) > (WORD)0x00FF)
{
if ((WORD)(*ch) >= (WORD)0x2000 && (WORD)(*ch) <= (WORD)0x26FF)
{
//symbols
}
else if ((WORD)(*ch) >= (WORD)0x4E00 && (WORD)(*ch) <= (WORD)0x9FA5)
{
//schinese
}
else
{
pch += 1;
ch = (const wchar_t*)pch;
continue;
}
}

if ((*ch) == L'\0')
break;
}
if ((*ch) == L'\0')
break;

auto ws = wss.str();
wss << (*ch);
ch++;
}

auto ws = wss.str();

return gPrivateFuncs.ClientVGUI_RichText_SetTextW(pthis, dummy, ws.c_str());
}

gPrivateFuncs.ClientVGUI_RichText_SetTextW(pthis, dummy, ws.c_str());
gPrivateFuncs.ClientVGUI_RichText_SetTextW(pthis, dummy, text);
}
#endif

Expand Down Expand Up @@ -1082,9 +1087,9 @@ void NativeClientUI_RichText_Search(PVOID Candidate, bool bIsUnicode)
{
gPrivateFuncs.ClientVGUI_RichText_SetTextW = (decltype(gPrivateFuncs.ClientVGUI_RichText_SetTextW))GetCallAddress(address);

//auto addr = (PUCHAR)address;
//int rva = (PUCHAR)ClientVGUI_RichText_SetTextW_Proxy - (addr + 5);
//g_pMetaHookAPI->WriteMemory(addr + 1, &rva, 4);
auto addr = (PUCHAR)address;
int rva = (PUCHAR)ClientVGUI_RichText_SetTextW_Proxy - (addr + 5);
g_pMetaHookAPI->WriteMemory(addr + 1, &rva, 4);
}
}
else
Expand Down

0 comments on commit 654f3c0

Please sign in to comment.