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) int Materials::R_TextWidth_Hk(const char* text, int maxChars, Game::Font_s* font)
{ {
auto lineWidth = 0; auto lineWidth = 0;
@ -296,7 +298,7 @@ namespace Components
return 0; return 0;
auto count = 0; auto count = 0;
while (*text && count < maxChars) while (text && *text && count < maxChars)
{ {
const auto letter = Game::SEH_ReadCharFromString(&text, nullptr); const auto letter = Game::SEH_ReadCharFromString(&text, nullptr);
if (letter == '\r' || letter == '\n') if (letter == '\r' || letter == '\n')
@ -329,18 +331,17 @@ namespace Components
continue; continue;
} }
} }
lineWidth += R_GetCharacterGlyph(font, letter)->dx; lineWidth += R_GetCharacterGlyph(font, letter)->dx;
if (lineWidth > maxWidth) if (lineWidth > maxWidth)
maxWidth = lineWidth; maxWidth = lineWidth;
count++; count++;
} }
} }
return maxWidth; return maxWidth;
} }
#endif
Materials::Materials() Materials::Materials()
{ {
Materials::ImageNameLength = 7; 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 __asm
{ {
mov edi, [esp + 8] push eax
push [esp+4] pushad
mov edi, [esp + 0x28 + 4]
push [esp + 0x24 + 4]
mov eax, 0x5055C0 mov eax, 0x5055C0
call eax call eax
add esp,0x4 add esp,0x4
mov [esp + 0x20],eax
popad
pop eax
retn retn
} }
} }