From 2380e151ab6055e5002ccdc2f57c8529100184de Mon Sep 17 00:00:00 2001 From: mix Date: Wed, 9 Jul 2025 01:18:54 +0100 Subject: [PATCH] Unify metal support type a and b base to main segment drawing --- src/openrct2/paint/support/MetalSupports.cpp | 38 ++++++-------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/src/openrct2/paint/support/MetalSupports.cpp b/src/openrct2/paint/support/MetalSupports.cpp index efa02f00bb..380b3b9ce2 100644 --- a/src/openrct2/paint/support/MetalSupports.cpp +++ b/src/openrct2/paint/support/MetalSupports.cpp @@ -385,32 +385,19 @@ static bool MetalASupportsPaintSetup( currentHeight = supportSegments[segment].height + 6; } - // Work out if a small support segment required to bring support to normal - // size (aka floor2(x, 16)) - int16_t heightDiff = floor2(currentHeight + 16, 16); - if (heightDiff > crossbeamHeight) - { - heightDiff = crossbeamHeight; - } - - heightDiff -= currentHeight; + const auto supportBeamImageIndex = kSupportBasesAndBeams[supportType].beamUncapped; + // Draw an initial support segment to get the main segment height to a multiple of 16 + const int16_t heightDiff = std::min(floor2(currentHeight + 16, 16), crossbeamHeight) - currentHeight; if (heightDiff > 0) { - int8_t xOffset = kMetalSupportBoundBoxOffsets[segment].x; - int8_t yOffset = kMetalSupportBoundBoxOffsets[segment].y; - - uint32_t imageIndex = kSupportBasesAndBeams[supportType].beamUncapped; - imageIndex += heightDiff - 1; - auto image_id = imageTemplate.WithIndex(imageIndex); - - PaintAddImageAsParent(session, image_id, { xOffset, yOffset, currentHeight }, { 0, 0, heightDiff - 1 }); + PaintAddImageAsParent( + session, imageTemplate.WithIndex(supportBeamImageIndex + heightDiff - 1), + { kMetalSupportBoundBoxOffsets[segment], currentHeight }, { 0, 0, heightDiff - 1 }); } currentHeight += heightDiff; - const auto supportBeamImageIndex = kSupportBasesAndBeams[supportType].beamUncapped; - // Draw main support segments for (uint8_t count = 1;; count++) { @@ -570,24 +557,19 @@ static bool MetalBSupportsPaintSetup( currentHeight = supportSegments[segment].height + 6; } - int16_t heightDiff = floor2(currentHeight + 16, 16); - if (heightDiff > crossbeamHeight) - { - heightDiff = crossbeamHeight; - } + const auto supportBeamImageIndex = kSupportBasesAndBeams[supportType].beamUncapped; - heightDiff -= currentHeight; + // Draw an initial support segment to get the main segment height to a multiple of 16 + const int16_t heightDiff = std::min(floor2(currentHeight + 16, 16), crossbeamHeight) - currentHeight; if (heightDiff > 0) { PaintAddImageAsParent( - session, imageTemplate.WithIndex(kSupportBasesAndBeams[supportType].beamUncapped + (heightDiff - 1)), + session, imageTemplate.WithIndex(supportBeamImageIndex + heightDiff - 1), { kMetalSupportBoundBoxOffsets[segment], currentHeight }, { 0, 0, heightDiff - 1 }); } currentHeight += heightDiff; - const auto supportBeamImageIndex = kSupportBasesAndBeams[supportType].beamUncapped; - // Draw main support segments for (uint8_t count = 1;; count++) {