From 189ebbced7ab86b5ed8f1b21d7a980ffb2684d65 Mon Sep 17 00:00:00 2001 From: Rik Smeets <30838294+rik-smeets@users.noreply.github.com> Date: Fri, 23 Sep 2022 07:11:15 +0200 Subject: [PATCH 1/2] Reformat code on updating crossings --- src/openrct2/ride/Vehicle.cpp | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index df4ff3b883..36ebeb9d98 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -9250,29 +9250,25 @@ void Vehicle::UpdateCrossings() const xyElement = { backVehicle->TrackLocation, map_get_track_element_at_of_type_seq(backVehicle->TrackLocation, backVehicle->GetTrackType(), 0) }; - curZ = backVehicle->TrackLocation.z; - - if (xyElement.element != nullptr) + if (xyElement.element == nullptr) { - uint8_t freeCount = travellingForwards ? 3 : 1; + return; + } - while (freeCount-- > 0) + uint8_t freeCount = travellingForwards ? 3 : 1; + while (freeCount-- > 0) + { + if (travellingForwards && track_block_get_previous(xyElement, &output)) { - if (travellingForwards) - { - if (track_block_get_previous(xyElement, &output)) - { - xyElement.x = output.begin_x; - xyElement.y = output.begin_y; - xyElement.element = output.begin_element; - } - } + xyElement.x = output.begin_x; + xyElement.y = output.begin_y; + xyElement.element = output.begin_element; + } - auto* pathElement = map_get_path_element_at(TileCoordsXYZ(CoordsXYZ{ xyElement, xyElement.element->GetBaseZ() })); - if (pathElement != nullptr) - { - pathElement->SetIsBlockedByVehicle(false); - } + auto* pathElement = map_get_path_element_at(TileCoordsXYZ(CoordsXYZ{ xyElement, xyElement.element->GetBaseZ() })); + if (pathElement != nullptr) + { + pathElement->SetIsBlockedByVehicle(false); } } } From 9e68226df0b88aca99e7da7e901dfd9dbc4ad271 Mon Sep 17 00:00:00 2001 From: Rik Smeets <30838294+rik-smeets@users.noreply.github.com> Date: Fri, 23 Sep 2022 07:28:55 +0200 Subject: [PATCH 2/2] Fix #10535: Guests stuck at some level crossings The location of the back vehicle itself should be included in determining whether to clear the 'blocked by vehicle' flag on footpath. Otherwise, in specific cases, blocked footpath can be missed and therefore this flag wouldn't ever be cleared. --- distribution/changelog.txt | 1 + src/openrct2/ride/Vehicle.cpp | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 888574c13f..3efadbb4ea 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -29,6 +29,7 @@ - Change: [#17762] Use vertical tabs in the New Game dialog. - Fix: [#5141] Headless server is counted as a player. - Fix: [#7466] Coaster track not drawn at tunnel exit. +- Fix: [#10535] Guests getting stuck at specific level crossings. - Fix: [#14337] Guest blocking ride entrance after ride price changed to be unaffordable. - Fix: [#15328] Wooden Roller Coaster incorrectly draws a railing on the first station piece (original bug). - Fix: [#16392] Scenery on sloped surface is placed at wrong height. diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 36ebeb9d98..c1ccb78f1a 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -9258,18 +9258,18 @@ void Vehicle::UpdateCrossings() const uint8_t freeCount = travellingForwards ? 3 : 1; while (freeCount-- > 0) { - if (travellingForwards && track_block_get_previous(xyElement, &output)) - { - xyElement.x = output.begin_x; - xyElement.y = output.begin_y; - xyElement.element = output.begin_element; - } - auto* pathElement = map_get_path_element_at(TileCoordsXYZ(CoordsXYZ{ xyElement, xyElement.element->GetBaseZ() })); if (pathElement != nullptr) { pathElement->SetIsBlockedByVehicle(false); } + + if (travellingForwards && freeCount > 0 && track_block_get_previous(xyElement, &output)) + { + xyElement.x = output.begin_x; + xyElement.y = output.begin_y; + xyElement.element = output.begin_element; + } } }