From 8b43ba490ca5ca2e82b25f68fe331b35acb25eb4 Mon Sep 17 00:00:00 2001 From: Jan Date: Mon, 23 Aug 2021 00:03:00 +0200 Subject: [PATCH] Fix width calculation errors in R_TextWidth reimplementation --- src/Components/Modules/Materials.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Components/Modules/Materials.cpp b/src/Components/Modules/Materials.cpp index 98ba4062..330d0b39 100644 --- a/src/Components/Modules/Materials.cpp +++ b/src/Components/Modules/Materials.cpp @@ -303,7 +303,7 @@ namespace Components { if (*text >= '0' && *text <= Colors::LastColorIndex) { - text += 2; + text++; continue; } @@ -312,12 +312,12 @@ namespace Components const auto width = text[1]; const auto materialNameLength = text[3]; - auto v9 = font->pixelHeight * (text[1] - 16) + 16; - auto w = ((((v9 >> 24) & 0x1F) + (signed int)v9) >> 5); + auto v9 = font->pixelHeight * (width - 16) + 16; + auto w = ((((v9 >> 24) & 0x1F) + v9) >> 5); lineWidth += w; - text += 3; + text += 4; for (auto currentLength = 0; currentLength < materialNameLength && *text; currentLength++) text++; continue;