From 6c011c2a2ae2e2a1fc087a22b8f0baf996d13587 Mon Sep 17 00:00:00 2001 From: mix Date: Sat, 14 Jun 2025 04:09:56 +0100 Subject: [PATCH] Only animate land edge doors if track is below surface height --- src/openrct2/ride/Vehicle.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index d19575ae08..883329451f 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -6371,6 +6371,17 @@ static void AnimateLandscapeDoor(const CoordsXYZ& doorLocation, TrackElement& tr } } +static const SurfaceElement* GetSurfaceElementAfterElement(const TileElement* tileElement) +{ + while (tileElement->GetType() != TileElementType::Surface) + { + if (tileElement->IsLastForTile()) + return nullptr; + tileElement++; + } + return tileElement->AsSurface(); +} + void Vehicle::UpdateLandscapeDoors(const int32_t previousTrackHeight) const { const auto* currentRide = GetRide(); @@ -6384,11 +6395,20 @@ void Vehicle::UpdateLandscapeDoors(const int32_t previousTrackHeight) const auto* const currentTrackElement = MapGetTrackElementAtBeforeSurfaceFromRide(TrackLocation, ride); if (previousTrackElement != nullptr && currentTrackElement == nullptr) { - AnimateLandscapeDoor(previousTrackLocation, *previousTrackElement->AsTrack(), next_vehicle_on_train.IsNull()); + const auto* const surfaceElement = GetSurfaceElementAfterElement(previousTrackElement); + if (surfaceElement != nullptr && surfaceElement->GetBaseZ() > previousTrackLocation.z) + { + AnimateLandscapeDoor( + previousTrackLocation, *previousTrackElement->AsTrack(), next_vehicle_on_train.IsNull()); + } } else if (previousTrackElement == nullptr && currentTrackElement != nullptr) { - AnimateLandscapeDoor(TrackLocation, *currentTrackElement->AsTrack(), next_vehicle_on_train.IsNull()); + const auto* const surfaceElement = GetSurfaceElementAfterElement(currentTrackElement); + if (surfaceElement != nullptr && surfaceElement->GetBaseZ() > TrackLocation.z) + { + AnimateLandscapeDoor(TrackLocation, *currentTrackElement->AsTrack(), next_vehicle_on_train.IsNull()); + } } }