Fix width calculation errors in R_TextWidth reimplementation

This commit is contained in:
Jan 2021-08-23 00:03:00 +02:00
parent 885f5c4688
commit 8b43ba490c

View File

@ -303,7 +303,7 @@ namespace Components
{ {
if (*text >= '0' && *text <= Colors::LastColorIndex) if (*text >= '0' && *text <= Colors::LastColorIndex)
{ {
text += 2; text++;
continue; continue;
} }
@ -312,12 +312,12 @@ namespace Components
const auto width = text[1]; const auto width = text[1];
const auto materialNameLength = text[3]; const auto materialNameLength = text[3];
auto v9 = font->pixelHeight * (text[1] - 16) + 16; auto v9 = font->pixelHeight * (width - 16) + 16;
auto w = ((((v9 >> 24) & 0x1F) + (signed int)v9) >> 5); auto w = ((((v9 >> 24) & 0x1F) + v9) >> 5);
lineWidth += w; lineWidth += w;
text += 3; text += 4;
for (auto currentLength = 0; currentLength < materialNameLength && *text; currentLength++) for (auto currentLength = 0; currentLength < materialNameLength && *text; currentLength++)
text++; text++;
continue; continue;