diff --git a/src/openrct2/paint/Supports.cpp b/src/openrct2/paint/Supports.cpp index 1da900e662..dda5aa9ea4 100644 --- a/src/openrct2/paint/Supports.cpp +++ b/src/openrct2/paint/Supports.cpp @@ -353,19 +353,19 @@ static constexpr UnkSupportsDescriptor Byte97B23C[] = { {{{0, 0, 0}, {1, 1, 8}}, 0, 1}, {{{0, 0, 0}, {1, 1, 8}}, 0, 1}, {{{0, 0, 0}, {1, 1, 8}}, 0, 1}, + {{{0, 0, 0}, {1, 1, 8}}, 0, 1}, // ? {{{0, 0, 0}, {1, 1, 8}}, 0, 1}, {{{0, 0, 0}, {1, 1, 8}}, 0, 1}, {{{0, 0, 0}, {1, 1, 8}}, 0, 1}, + {{{0, 0, 0}, {1, 1, 8}}, 0, 1}, // ? {{{0, 0, 0}, {1, 1, 8}}, 0, 1}, {{{0, 0, 0}, {1, 1, 8}}, 0, 1}, {{{0, 0, 0}, {1, 1, 8}}, 0, 1}, + {{{0, 0, 0}, {1, 1, 8}}, 0, 1}, // ? {{{0, 0, 0}, {1, 1, 8}}, 0, 1}, {{{0, 0, 0}, {1, 1, 8}}, 0, 1}, {{{0, 0, 0}, {1, 1, 8}}, 0, 1}, - {{{0, 0, 0}, {1, 1, 8}}, 0, 1}, - {{{0, 0, 0}, {1, 1, 8}}, 0, 1}, - {{{0, 0, 0}, {1, 1, 8}}, 0, 1}, - {{{2, 2, 1}, {28, 28, 2}}, 0, 1}, + {{{2, 2, 1}, {28, 28, 2}}, 0, 1}, // Large scenery (all directions) {{{0, 0, 0}, {1, 1, 8}}, 0, 1}, // Flat to steep large 1 {{{0, 0, 0}, {1, 1, 8}}, 0, 1}, {{{0, 0, 0}, {1, 1, 8}}, 0, 1}, @@ -680,16 +680,32 @@ bool WoodenASupportsPaintSetup( return hasSupports; } +static int32_t GetSpecialOffsetForTransitionType(WoodenSupportTransitionType transitionType, Direction direction) +{ + if (transitionType == WoodenSupportTransitionType::None) + return 0; + + // "Special" values are an offset into tables like Byte97B23C, plus 1. + // Save for WoodenSupportTransitionType::LargeScenery, there are four entries (one per direction) for every + // transition type. While these tables will have to be refactored in due course, we can only do so once all + // drawing functions use WoodenSupportTransitionType instead of passing the "special" value directly. + int32_t specialOffset = 0; + if (transitionType < WoodenSupportTransitionType::Scenery) + specialOffset = (EnumValue(transitionType) * NumOrthogonalDirections) + direction; + else if (transitionType == WoodenSupportTransitionType::Scenery) + specialOffset = (EnumValue(transitionType) * NumOrthogonalDirections); + else + specialOffset = (EnumValue(transitionType) * NumOrthogonalDirections) + direction - 3; + + return specialOffset + 1; +} + bool WoodenASupportsPaintSetup( PaintSession& session, WoodenSupportType supportType, WoodenSupportSubType subType, int32_t height, ImageId imageTemplate, WoodenSupportTransitionType transitionType, Direction direction) { int32_t oldSupportType = (EnumValue(supportType) * 6) + EnumValue(subType); - int32_t special = 0; - if (transitionType != WoodenSupportTransitionType::None) - { - special = (EnumValue(transitionType) * NumOrthogonalDirections) + direction + 1; - } + int32_t special = GetSpecialOffsetForTransitionType(transitionType, direction); return WoodenASupportsPaintSetup(session, oldSupportType, special, height, imageTemplate); } @@ -829,11 +845,7 @@ bool WoodenBSupportsPaintSetup( WoodenSupportTransitionType transitionType, Direction direction) { int32_t oldSupportType = (EnumValue(supportType) * 6) + EnumValue(subType); - int32_t special = 0; - if (transitionType != WoodenSupportTransitionType::None) - { - special = (EnumValue(transitionType) * NumOrthogonalDirections) + direction + 1; - } + int32_t special = GetSpecialOffsetForTransitionType(transitionType, direction); return WoodenBSupportsPaintSetup(session, oldSupportType, special, height, imageTemplate); } diff --git a/src/openrct2/paint/Supports.h b/src/openrct2/paint/Supports.h index 54ee612f1c..f5e78570e1 100644 --- a/src/openrct2/paint/Supports.h +++ b/src/openrct2/paint/Supports.h @@ -42,6 +42,7 @@ enum class WoodenSupportTransitionType : uint8_t Up25DegToUp60Deg = 3, Up60DegToUp25Deg = 4, Up60Deg = 5, + Scenery = 12, }; // There are 13 types of metal supports. A graphic showing all of them is available here: diff --git a/src/openrct2/paint/tile_element/Paint.LargeScenery.cpp b/src/openrct2/paint/tile_element/Paint.LargeScenery.cpp index 2f50f0cc51..3c661d216f 100644 --- a/src/openrct2/paint/tile_element/Paint.LargeScenery.cpp +++ b/src/openrct2/paint/tile_element/Paint.LargeScenery.cpp @@ -61,15 +61,16 @@ static void PaintLargeScenerySupports( if (tile.flags & LARGE_SCENERY_TILE_FLAG_NO_SUPPORTS) return; - auto special = 0; + auto transitionType = WoodenSupportTransitionType::None; auto supportHeight = height; if (supportHeight & 0xF) { supportHeight &= ~0xF; - special = 49; + transitionType = WoodenSupportTransitionType::Scenery; } - WoodenBSupportsPaintSetup(session, (direction & 1), special, supportHeight, imageTemplate); + WoodenBSupportsPaintSetupRotated( + session, WoodenSupportType::Truss, WoodenSupportSubType::NeSw, direction, supportHeight, imageTemplate, transitionType); 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 5654eb2679..6d22f0a07b 100644 --- a/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp +++ b/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp @@ -42,12 +42,12 @@ static void PaintSmallScenerySupports( if (sceneryEntry.HasFlag(SMALL_SCENERY_FLAG_NO_SUPPORTS)) return; - auto special = 0; + auto transitionType = WoodenSupportTransitionType::None; auto supportHeight = height; if (supportHeight & 0xF) { supportHeight &= ~0xF; - special = 49; + transitionType = WoodenSupportTransitionType::Scenery; } auto supportImageTemplate = ImageId().WithRemap(0); @@ -60,8 +60,9 @@ static void PaintSmallScenerySupports( supportImageTemplate = imageTemplate; } - auto supportType = (direction & 1) ? 1 : 0; - WoodenBSupportsPaintSetup(session, supportType, special, supportHeight, supportImageTemplate); + WoodenBSupportsPaintSetupRotated( + session, WoodenSupportType::Truss, WoodenSupportSubType::NeSw, direction, supportHeight, supportImageTemplate, + transitionType); } static void SetSupportHeights(