1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-23 15:52:55 +01:00

Fix #16206: Wooden supports for scenery are not drawn

This commit is contained in:
Ted John
2021-12-14 13:25:41 +00:00
committed by GitHub
parent 3572c3f466
commit 5cc776c622
5 changed files with 56 additions and 49 deletions

View File

@@ -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)

View File

@@ -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(

View File

@@ -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);

View File

@@ -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)

View File

@@ -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(