From 8158956f18af5ab729ef804c5a8c44b60be8f99b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Tue, 2 Nov 2021 01:31:21 -0700 Subject: [PATCH] Fix #15819: Potential crash placing a maze design --- src/openrct2/ride/RideConstruction.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/openrct2/ride/RideConstruction.cpp b/src/openrct2/ride/RideConstruction.cpp index 86aee49fd3..54fa013b39 100644 --- a/src/openrct2/ride/RideConstruction.cpp +++ b/src/openrct2/ride/RideConstruction.cpp @@ -1525,21 +1525,23 @@ void Ride::ValidateStations() continue; auto trackType = trackElement->AsTrack()->GetTrackType(); - uint8_t trackSequence = trackElement->AsTrack()->GetSequenceIndex(); - // determine where the ride entrance is relative to the station track - Direction direction = (tileElement->GetDirection() - direction_reverse(trackElement->GetDirection())) & 3; - - // if the ride entrance is not on a valid side, remove it - ted = &GetTrackElementDescriptor(trackType); - if (!(ted->SequenceProperties[trackSequence] & (1 << direction))) - { - continue; - } // get the StationIndex for the station StationIndex stationId = 0; if (trackType != TrackElemType::Maze) { + uint8_t trackSequence = trackElement->AsTrack()->GetSequenceIndex(); + + // determine where the ride entrance is relative to the station track + Direction direction = (tileElement->GetDirection() - direction_reverse(trackElement->GetDirection())) & 3; + + // if the ride entrance is not on a valid side, remove it + ted = &GetTrackElementDescriptor(trackType); + if (!(ted->SequenceProperties[trackSequence] & (1 << direction))) + { + continue; + } + stationId = trackElement->AsTrack()->GetStationIndex(); } if (tileElement->AsEntrance()->GetEntranceType() == ENTRANCE_TYPE_RIDE_EXIT)