From 5cc776c62216a9f0b72c80bbffeb8d298572b278 Mon Sep 17 00:00:00 2001 From: Ted John Date: Tue, 14 Dec 2021 13:25:41 +0000 Subject: [PATCH] Fix #16206: Wooden supports for scenery are not drawn --- src/openrct2/paint/Supports.cpp | 93 ++++++++++--------- src/openrct2/paint/Supports.h | 4 + .../paint/tile_element/Paint.Entrance.cpp | 4 +- .../paint/tile_element/Paint.LargeScenery.cpp | 2 +- .../paint/tile_element/Paint.SmallScenery.cpp | 2 +- 5 files changed, 56 insertions(+), 49 deletions(-) diff --git a/src/openrct2/paint/Supports.cpp b/src/openrct2/paint/Supports.cpp index 3351358945..6665763f11 100644 --- a/src/openrct2/paint/Supports.cpp +++ b/src/openrct2/paint/Supports.cpp @@ -447,6 +447,18 @@ static constexpr const uint16_t word_97B3C4[] = { }; // clang-format on +bool wooden_a_supports_paint_setup( + paint_session* session, int32_t supportType, int32_t special, int32_t height, uint32_t imageColourFlags) +{ + return wooden_a_supports_paint_setup(session, supportType, special, height, ImageId::FromUInt32(imageColourFlags)); +} + +bool wooden_b_supports_paint_setup( + paint_session* session, int32_t supportType, int32_t special, int32_t height, uint32_t imageColourFlags) +{ + return wooden_a_supports_paint_setup(session, supportType, special, height, ImageId::FromUInt32(imageColourFlags)); +} + /** * Adds paint structs for wooden supports. * rct2: 0x006629BC @@ -458,7 +470,7 @@ static constexpr const uint16_t word_97B3C4[] = { * @returns (al) true if any supports have been drawn, otherwise false. */ bool wooden_a_supports_paint_setup( - paint_session* session, int32_t supportType, int32_t special, int32_t height, uint32_t imageColourFlags) + paint_session* session, int32_t supportType, int32_t special, int32_t height, ImageId imageTemplate) { if (session->ViewFlags & VIEWPORT_FLAG_INVISIBLE_SUPPORTS) { @@ -497,18 +509,16 @@ bool wooden_a_supports_paint_setup( return false; } - int32_t imageId = WoodenSupportImageIds[supportType].slope; - if (imageId == 0) + auto imageIndex = WoodenSupportImageIds[supportType].slope; + if (imageIndex == 0) { drawFlatPiece = true; } else { - imageId += word_97B3C4[slope & TILE_ELEMENT_SURFACE_SLOPE_MASK]; - imageId |= imageColourFlags; + auto imageId = imageTemplate.WithIndex(imageIndex + word_97B3C4[slope & TILE_ELEMENT_SURFACE_SLOPE_MASK]); PaintAddImageAsParent(session, imageId, { 0, 0, z }, { 32, 32, 11 }, { 0, 0, z + 2 }); - - PaintAddImageAsParent(session, imageId + 4, { 0, 0, z + 16 }, { 32, 32, 11 }, { 0, 0, z + 16 + 2 }); + PaintAddImageAsParent(session, imageId.WithIndexOffset(4), { 0, 0, z + 16 }, { 32, 32, 11 }, { 0, 0, z + 16 + 2 }); hasSupports = true; } @@ -523,16 +533,14 @@ bool wooden_a_supports_paint_setup( return false; } - int32_t imageId = WoodenSupportImageIds[supportType].slope; - if (imageId == 0) + int32_t imageIndex = WoodenSupportImageIds[supportType].slope; + if (imageIndex == 0) { drawFlatPiece = true; } else { - imageId += word_97B3C4[slope & TILE_ELEMENT_SURFACE_SLOPE_MASK]; - imageId |= imageColourFlags; - + auto imageId = imageTemplate.WithIndex(imageIndex + word_97B3C4[slope & TILE_ELEMENT_SURFACE_SLOPE_MASK]); PaintAddImageAsParent(session, imageId, { 0, 0, z }, { 32, 32, 11 }, { 0, 0, z + 2 }); hasSupports = true; } @@ -542,7 +550,7 @@ bool wooden_a_supports_paint_setup( // Draw flat base support if (drawFlatPiece) { - int32_t imageId = WoodenSupportImageIds[supportType].flat | imageColourFlags; + auto imageId = imageTemplate.WithIndex(WoodenSupportImageIds[supportType].flat); PaintAddImageAsParent(session, imageId, { 0, 0, z - 2 }, { 32, 32, 0 }); hasSupports = true; } @@ -553,7 +561,7 @@ bool wooden_a_supports_paint_setup( if ((z & 16) == 0 && height >= 2 && z + 16 != session->WaterHeight) { // Full support - int32_t imageId = WoodenSupportImageIds[supportType].full | imageColourFlags; + auto imageId = imageTemplate.WithIndex(WoodenSupportImageIds[supportType].full); uint8_t ah = height == 2 ? 23 : 28; PaintAddImageAsParent(session, imageId, { 0, 0, z }, { 32, 32, ah }); hasSupports = true; @@ -563,7 +571,7 @@ bool wooden_a_supports_paint_setup( else { // Half support - int32_t imageId = WoodenSupportImageIds[supportType].half | imageColourFlags; + auto imageId = imageTemplate.WithIndex(WoodenSupportImageIds[supportType].half); uint8_t ah = height == 1 ? 7 : 12; PaintAddImageAsParent(session, imageId, { 0, 0, z }, { 32, 32, ah }); hasSupports = true; @@ -580,8 +588,7 @@ bool wooden_a_supports_paint_setup( if (WoodenCurveSupportImageIds[supportType] != nullptr && WoodenCurveSupportImageIds[supportType][special] != 0 && byte_97B23C[special].var_7 != 0) { - uint32_t imageId = WoodenCurveSupportImageIds[supportType][special]; - imageId |= imageColourFlags; + auto imageId = imageTemplate.WithIndex(WoodenCurveSupportImageIds[supportType][special]); unk_supports_desc_bound_box bBox = byte_97B23C[special].bounding_box; @@ -594,9 +601,8 @@ bool wooden_a_supports_paint_setup( else { hasSupports = true; - paint_struct* ps = PaintAddImageAsOrphan( - session, ImageId::FromUInt32(imageId), { 0, 0, z }, bBox.length, - { bBox.offset.x, bBox.offset.y, bBox.offset.z + z }); + auto* ps = PaintAddImageAsOrphan( + session, imageId, { 0, 0, z }, bBox.length, { bBox.offset.x, bBox.offset.y, bBox.offset.z + z }); if (ps != nullptr) { session->WoodenSupportsPrependTo->children = ps; @@ -621,7 +627,7 @@ bool wooden_a_supports_paint_setup( * @return (al) whether supports have been drawn */ bool wooden_b_supports_paint_setup( - paint_session* session, int32_t supportType, int32_t special, int32_t height, uint32_t imageColourFlags) + paint_session* session, int32_t supportType, int32_t special, int32_t height, ImageId imageTemplate) { bool _9E32B1 = false; @@ -659,22 +665,22 @@ bool wooden_b_supports_paint_setup( return false; } - uint32_t imageId = WoodenSupportImageIds[supportType].slope; - if (imageId == 0) + uint32_t imageIndex = WoodenSupportImageIds[supportType].slope; + if (imageIndex == 0) { baseHeight += 32; goTo662E8B = true; } else { - imageId += word_97B3C4[session->Support.slope & TILE_ELEMENT_SURFACE_SLOPE_MASK]; + auto imageid = imageTemplate.WithIndex( + imageIndex + word_97B3C4[session->Support.slope & TILE_ELEMENT_SURFACE_SLOPE_MASK]); - PaintAddImageAsParent( - session, imageId | imageColourFlags, { 0, 0, baseHeight }, { 32, 32, 11 }, { 0, 0, baseHeight + 2 }); + PaintAddImageAsParent(session, imageid, { 0, 0, baseHeight }, { 32, 32, 11 }, { 0, 0, baseHeight + 2 }); baseHeight += 16; PaintAddImageAsParent( - session, (imageId + 4) | imageColourFlags, { 0, 0, baseHeight }, { 32, 32, 3 }, { 0, 0, baseHeight + 2 }); + session, imageid.WithIndexOffset(4), { 0, 0, baseHeight }, { 32, 32, 3 }, { 0, 0, baseHeight + 2 }); baseHeight += 16; _9E32B1 = true; @@ -688,18 +694,18 @@ bool wooden_b_supports_paint_setup( return false; } - uint32_t imageId = WoodenSupportImageIds[supportType].slope; - if (imageId == 0) + auto imageIndex = WoodenSupportImageIds[supportType].slope; + if (imageIndex == 0) { baseHeight += 16; goTo662E8B = true; } else { - imageId += word_97B3C4[session->Support.slope & TILE_ELEMENT_SURFACE_SLOPE_MASK]; + auto imageId = imageTemplate.WithIndex( + imageIndex + word_97B3C4[session->Support.slope & TILE_ELEMENT_SURFACE_SLOPE_MASK]); - PaintAddImageAsParent( - session, imageId | imageColourFlags, { 0, 0, baseHeight }, { 32, 32, 3 }, { 0, 0, baseHeight + 2 }); + PaintAddImageAsParent(session, imageId, { 0, 0, baseHeight }, { 32, 32, 3 }, { 0, 0, baseHeight + 2 }); baseHeight += 16; _9E32B1 = true; @@ -715,8 +721,8 @@ bool wooden_b_supports_paint_setup( } else { - PaintAddImageAsParent( - session, WoodenSupportImageIds[supportType].flat | imageColourFlags, { 0, 0, baseHeight - 2 }, { 32, 32, 0 }); + auto imageId = imageTemplate.WithIndex(WoodenSupportImageIds[supportType].flat); + PaintAddImageAsParent(session, imageId, { 0, 0, baseHeight - 2 }, { 32, 32, 0 }); _9E32B1 = true; } } @@ -727,18 +733,16 @@ bool wooden_b_supports_paint_setup( { if (baseHeight & 0x10 || heightSteps == 1 || baseHeight + 16 == session->WaterHeight) { - PaintAddImageAsParent( - session, WoodenSupportImageIds[supportType].half | imageColourFlags, { 0, 0, baseHeight }, - { 32, 32, ((heightSteps == 1) ? 7 : 12) }); + auto imageId = imageTemplate.WithIndex(WoodenSupportImageIds[supportType].half); + PaintAddImageAsParent(session, imageId, { 0, 0, baseHeight }, { 32, 32, ((heightSteps == 1) ? 7 : 12) }); heightSteps -= 1; baseHeight += 16; _9E32B1 = true; } else { - PaintAddImageAsParent( - session, WoodenSupportImageIds[supportType].full | imageColourFlags, { 0, 0, baseHeight }, - { 32, 32, ((heightSteps == 2) ? 23 : 28) }); + auto imageId = imageTemplate.WithIndex(WoodenSupportImageIds[supportType].full); + PaintAddImageAsParent(session, imageId, { 0, 0, baseHeight }, { 32, 32, ((heightSteps == 2) ? 23 : 28) }); heightSteps -= 2; baseHeight += 32; _9E32B1 = true; @@ -755,22 +759,21 @@ bool wooden_b_supports_paint_setup( if (WoodenCurveSupportImageIds[supportType] != nullptr && WoodenCurveSupportImageIds[supportType][specialIndex] != 0 && supportsDesc.var_7 != 0) { // byte_97B23C[special].var_7 is never 0 - uint32_t imageId = WoodenCurveSupportImageIds[supportType][specialIndex]; - imageId |= imageColourFlags; + auto imageId = imageTemplate.WithIndex(WoodenCurveSupportImageIds[supportType][specialIndex]); const unk_supports_desc_bound_box& boundBox = supportsDesc.bounding_box; if (supportsDesc.var_6 == 0 || session->WoodenSupportsPrependTo == nullptr) { PaintAddImageAsParent( - session, imageId | imageColourFlags, { 0, 0, baseHeight }, boundBox.length, + session, imageId, { 0, 0, baseHeight }, boundBox.length, { boundBox.offset.x, boundBox.offset.y, boundBox.offset.z + baseHeight }); _9E32B1 = true; } else { - paint_struct* paintStruct = PaintAddImageAsOrphan( - session, ImageId::FromUInt32(imageId | imageColourFlags), { 0, 0, baseHeight }, boundBox.length, + auto* paintStruct = PaintAddImageAsOrphan( + session, imageId, { 0, 0, baseHeight }, boundBox.length, { boundBox.offset.x, boundBox.offset.y, boundBox.offset.z + baseHeight }); _9E32B1 = true; if (paintStruct != nullptr) diff --git a/src/openrct2/paint/Supports.h b/src/openrct2/paint/Supports.h index c2bdd341e2..5c9752e869 100644 --- a/src/openrct2/paint/Supports.h +++ b/src/openrct2/paint/Supports.h @@ -17,6 +17,10 @@ struct FootpathPaintInfo; constexpr const uint8_t NumVanillaWoodenSupportTypes = 49; +bool wooden_a_supports_paint_setup( + paint_session* session, int32_t supportType, int32_t special, int32_t height, ImageId imageTemplate); +bool wooden_b_supports_paint_setup( + paint_session* session, int32_t supportType, int32_t special, int32_t height, ImageId imageTemplate); bool wooden_a_supports_paint_setup( paint_session* session, int32_t supportType, int32_t special, int32_t height, uint32_t imageColourFlags); bool wooden_b_supports_paint_setup( diff --git a/src/openrct2/paint/tile_element/Paint.Entrance.cpp b/src/openrct2/paint/tile_element/Paint.Entrance.cpp index 17bc837d65..649fc61238 100644 --- a/src/openrct2/paint/tile_element/Paint.Entrance.cpp +++ b/src/openrct2/paint/tile_element/Paint.Entrance.cpp @@ -192,7 +192,7 @@ static void PaintRideEntranceExit(paint_session* session, uint8_t direction, int { supportsImageTemplate = ImageId().WithPrimary(COLOUR_SATURATED_BROWN); } - wooden_a_supports_paint_setup(session, direction & 1, 0, height, supportsImageTemplate.ToUInt32()); + wooden_a_supports_paint_setup(session, direction & 1, 0, height, supportsImageTemplate); height += isExit ? 40 : 56; paint_util_set_segment_support_height(session, SEGMENTS_ALL, 0xFFFF, 0); @@ -316,7 +316,7 @@ static void PaintParkEntrance(paint_session* session, uint8_t direction, int32_t { supportsImageTemplate = ImageId().WithPrimary(COLOUR_SATURATED_BROWN); } - wooden_a_supports_paint_setup(session, direction & 1, 0, height, supportsImageTemplate.ToUInt32()); + wooden_a_supports_paint_setup(session, direction & 1, 0, height, supportsImageTemplate); paint_util_set_segment_support_height(session, SEGMENTS_ALL, 0xFFFF, 0); paint_util_set_general_support_height(session, height + 80, 0x20); diff --git a/src/openrct2/paint/tile_element/Paint.LargeScenery.cpp b/src/openrct2/paint/tile_element/Paint.LargeScenery.cpp index 33331b7bb0..e27938e935 100644 --- a/src/openrct2/paint/tile_element/Paint.LargeScenery.cpp +++ b/src/openrct2/paint/tile_element/Paint.LargeScenery.cpp @@ -70,7 +70,7 @@ static void PaintLargeScenerySupports( special = 49; } - wooden_b_supports_paint_setup(session, (direction & 1), special, supportHeight, imageTemplate.ToUInt32()); + wooden_b_supports_paint_setup(session, (direction & 1), special, supportHeight, imageTemplate); int32_t clearanceHeight = ceil2(tileElement.GetClearanceZ() + 15, 16); if (tile.flags & LARGE_SCENERY_TILE_FLAG_ALLOW_SUPPORTS_ABOVE) diff --git a/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp b/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp index 23503eb635..92e2da1e03 100644 --- a/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp +++ b/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp @@ -58,7 +58,7 @@ static void PaintSmallScenerySupports( } auto supportType = (direction & 1) ? 1 : 0; - wooden_b_supports_paint_setup(session, supportType, special, supportHeight, supportImageTemplate.ToUInt32()); + wooden_b_supports_paint_setup(session, supportType, special, supportHeight, supportImageTemplate); } static void SetSupportHeights(