Change glyphOffset type to uint32_t (#16481)

This variable used to be uint32_t before a refactor, but was changed to
auto, which means it's uint8_t. The offset calculation in this function
can cause an overflow with uint8_t, which causes the wrong character to
be printed on the sign.
This commit is contained in:
GalBr 2022-01-22 18:36:28 +02:00 committed by GitHub
parent b3bae9429c
commit 85a1e96f94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -124,7 +124,8 @@ static void PaintLargeScenery3DTextLine(
for (auto codepoint : CodepointView(line))
{
auto glyph = text.GetGlyph(codepoint, ' ');
auto glyphOffset = glyph.image_offset;
// Upcasting from uint8_t to uint32_t to avoid an overflow.
uint32_t glyphOffset = glyph.image_offset;
auto glyphType = direction & 1;
if (text.flags & LARGE_SCENERY_TEXT_FLAG_VERTICAL)
{