Fix release mode issues with R_TextWidth_Hk

This commit is contained in:
Jan 2021-08-23 22:44:57 +02:00
parent 6043dabc3c
commit ac1ade1976
2 changed files with 14 additions and 8 deletions

View File

@ -284,6 +284,8 @@ namespace Components
}
}
#endif
int Materials::R_TextWidth_Hk(const char* text, int maxChars, Game::Font_s* font)
{
auto lineWidth = 0;
@ -296,7 +298,7 @@ namespace Components
return 0;
auto count = 0;
while (*text && count < maxChars)
while (text && *text && count < maxChars)
{
const auto letter = Game::SEH_ReadCharFromString(&text, nullptr);
if (letter == '\r' || letter == '\n')
@ -329,18 +331,17 @@ namespace Components
continue;
}
}
lineWidth += R_GetCharacterGlyph(font, letter)->dx;
if (lineWidth > maxWidth)
maxWidth = lineWidth;
count++;
}
}
return maxWidth;
}
#endif
Materials::Materials()
{
Materials::ImageNameLength = 7;

View File

@ -1260,16 +1260,21 @@ namespace Game
}
}
__declspec(naked) Glyph* R_GetCharacterGlyph(Font_s* font, unsigned int letter)
__declspec(naked) Glyph* R_GetCharacterGlyph(Font_s* /*font */, unsigned int /*letter*/)
{
__asm
{
mov edi, [esp + 8]
push [esp+4]
push eax
pushad
mov edi, [esp + 0x28 + 4]
push [esp + 0x24 + 4]
mov eax, 0x5055C0
call eax
add esp,0x4
mov [esp + 0x20],eax
popad
pop eax
retn
}
}