From d10be6d0e75fe63f5bd913d59b57417642fa2711 Mon Sep 17 00:00:00 2001 From: Rik Smeets <30838294+rik-smeets@users.noreply.github.com> Date: Thu, 20 Apr 2023 18:53:21 +0200 Subject: [PATCH] Fix #19911: Guests stuck at railway crossings (#19939) In continuous circuit operating mode, not only the train head should be used for (un)blocking path. Because of this change, a previous change regarding which trailing track blocks should be unblocked has been reverted, as to prevent path being unblocked too soon. --- distribution/changelog.txt | 1 + src/openrct2/ride/Vehicle.cpp | 41 +++++++++++++++++++++++------------ 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index b16037a5f8..1d01ea1eed 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -24,6 +24,7 @@ - Fix: [#19854] Looping Coaster trains clipping through steep quarter turns down. - Fix: [#19858] Issue drawing simulate flag icon on alternate colour palettes. - Fix: [#19901] Random shop colours never assigning last colour. +- Fix: [#19911] Guests stuck at certain railway crossings. - Fix: [#19924] Destructible cheat does not allow partial ride modification. - Fix: [#19950] Mine train block brake supports drawn incorrectly. - Fix: [#19987] [Plugin] ‘SetCheatAction’ has wrong ID in plugin API. diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index fde8843af3..bacfb883f9 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -9213,7 +9213,22 @@ void Vehicle::InvalidateWindow() void Vehicle::UpdateCrossings() const { - if (TrainHead() != this) + auto curRide = GetRide(); + if (curRide == nullptr) + { + return; + } + + // Parks may have rides hacked into the path. + // Limit path blocking to rides actually supporting level crossings to prevent peeps getting stuck everywhere. + if (!GetRideTypeDescriptor(curRide->type).HasFlag(RIDE_TYPE_FLAG_SUPPORTS_LEVEL_CROSSINGS)) + { + return; + } + + // In shuttle mode, only the train head is considered to be travelling backwards + // To prevent path getting blocked incorrectly, only update crossings when this is the train head + if (curRide->mode == RideMode::Shuttle && TrainHead() != this) { return; } @@ -9257,12 +9272,7 @@ void Vehicle::UpdateCrossings() const while (true) { auto* pathElement = MapGetPathElementAt(TileCoordsXYZ(CoordsXYZ{ xyElement, xyElement.element->GetBaseZ() })); - auto curRide = GetRide(); - - // Many New Element parks have invisible rides hacked into the path. - // Limit path blocking to rides actually supporting level crossings to prevent peeps getting stuck everywhere. - if (pathElement != nullptr && curRide != nullptr - && GetRideTypeDescriptor(curRide->type).HasFlag(RIDE_TYPE_FLAG_SUPPORTS_LEVEL_CROSSINGS)) + if (pathElement != nullptr) { if (!playedClaxon && !pathElement->IsBlockedByVehicle()) { @@ -9321,18 +9331,21 @@ void Vehicle::UpdateCrossings() const uint8_t freeCount = travellingForwards && status != Vehicle::Status::Departing ? 3 : 1; while (freeCount-- > 0) { + if (travellingForwards) + { + if (TrackBlockGetPrevious(xyElement, &output)) + { + xyElement.x = output.begin_x; + xyElement.y = output.begin_y; + xyElement.element = output.begin_element; + } + } + auto* pathElement = MapGetPathElementAt(TileCoordsXYZ(CoordsXYZ{ xyElement, xyElement.element->GetBaseZ() })); if (pathElement != nullptr) { pathElement->SetIsBlockedByVehicle(false); } - - if (travellingForwards && freeCount > 0 && TrackBlockGetPrevious(xyElement, &output)) - { - xyElement.x = output.begin_x; - xyElement.y = output.begin_y; - xyElement.element = output.begin_element; - } } }