1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 19:13:07 +01:00

Merge pull request #20023 from Broxzier/bugfix/20008-roto-drop-paint-crash

Fix #20008: Crash in PaintRotoDropTowerSection
This commit is contained in:
Matthias Moninger
2023-04-22 23:10:07 +03:00
committed by GitHub

View File

@@ -185,14 +185,16 @@ static void PaintRotoDropTowerSection(
auto imageId = session.TrackColours[SCHEME_TRACK].WithIndex(SPR_ROTO_DROP_TOWER_SEGMENT);
PaintAddImageAsParent(session, imageId, { 0, 0, height }, { { 8, 8, height }, { 2, 2, 30 } });
const TileElement* nextTileElement = reinterpret_cast<const TileElement*>(&trackElement) + 1;
while (nextTileElement->GetType() != TileElementType::Track && !nextTileElement->IsLastForTile())
// The top segment of the Roto drop is only drawn when there is no tile element right above it
bool paintTopSegment = true;
const auto* tileElement = trackElement.as<TileElement>();
while (paintTopSegment && !tileElement->IsLastForTile())
{
nextTileElement++;
tileElement++;
paintTopSegment = trackElement.GetClearanceZ() != tileElement->GetBaseZ();
}
if (trackElement.IsLastForTile() || trackElement.GetClearanceZ() != nextTileElement->GetBaseZ())
if (paintTopSegment)
{
imageId = session.TrackColours[SCHEME_TRACK].WithIndex(SPR_ROTO_DROP_TOWER_SEGMENT_TOP);
PaintAddImageAsChild(session, imageId, { 0, 0, height }, { { 8, 8, height }, { 2, 2, 30 } });