ValveSoftware / halflife

Half-Life 1 engine based games
Other
3.71k stars 625 forks source link

Fix non-english symbols in the chat #1315

Open WPMGPRoSToTeMa opened 11 years ago

WPMGPRoSToTeMa commented 11 years ago

Please fix non-english symbols in the chat. If the "dropshadow" property of the chat font is enabled, all utf-8 characters have missed right vertical column of pixels.

1 2 4 3 And bug in the notify 5

WPMGPRoSToTeMa commented 11 years ago

Added screenshots

alfred-valve commented 11 years ago

This is on Windows right?

WPMGPRoSToTeMa commented 11 years ago

Yes, XP and 7. Linux version gives right result. If I remember correctly, the same problem was in old builds of source engine.

WPMGPRoSToTeMa commented 10 years ago

You will fix it ?

Mistrick commented 5 years ago

@mikela-valve can you look at this? Code by WPMGPRoSToTeMa which fixes bug.

#include <Windows.h>
#include <tchar.h>

BOOL WINAPI GetCharABCWidthsW_Hooked(void *pThis, HDC hdc, UINT wFirst, UINT wLast, LPABC lpABC)
{
    //MessageBox(NULL, _T("Hello!"), _T(""), MB_OK);

    BOOL bRet = GetCharABCWidthsW(hdc, wFirst, wLast, lpABC);

    lpABC->abcA = lpABC->abcA - *(int *)((byte *)pThis + 632);
    lpABC->abcB = lpABC->abcB + *(int *)((byte *)pThis + 48) + *(int *)((byte *)pThis + 632) * 2;
    lpABC->abcC = lpABC->abcC - *(int *)((byte *)pThis + 48) - *(int *)((byte *)pThis + 632);

    return bRet;
}

void __declspec(naked) GetCharABCWidthsW_Helper(HDC hdc, UINT wFirst, UINT wLast, LPABC lpABC)
{
    _asm
    {
        push[esp]
        mov[esp + 4], ebp;
        jmp GetCharABCWidthsW_Hooked;
    }
}

BOOL WINAPI DllMain(HMODULE hDllHandle, DWORD dwReason, LPVOID lpReserved)
{
    if (dwReason == DLL_PROCESS_ATTACH)
    {
        GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_PIN, (LPCTSTR)&DllMain, &hDllHandle);

        HMODULE hEngine = GetModuleHandle(_T("hw.dll"));
        byte *pCall = (byte *)hEngine + 0xCF410;
        DWORD dwOldProt;
        VirtualProtect(pCall, 6, PAGE_EXECUTE_READWRITE, &dwOldProt);
        *pCall = 0xE8;
        *(long *)(pCall + 1) = (long)&GetCharABCWidthsW_Helper - ((long)pCall + 5);
        *(pCall + 5) = 0x90;
        VirtualProtect(pCall, 6, dwOldProt, &dwOldProt);
    }

    return TRUE;
}
RauliTop commented 5 years ago

@kisak-valve fix proposal?