From 647ab23c3357e423435ee1441ecad40cf9999e8d Mon Sep 17 00:00:00 2001 From: mix <167040362+mixiate@users.noreply.github.com> Date: Mon, 17 Mar 2025 19:39:28 +0000 Subject: [PATCH] Fix #18309: Vehicles glitch going inverted to uninverted with uncap fps (#24011) --- distribution/changelog.txt | 1 + src/openrct2/ride/Vehicle.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index ed66ba630f..bf0bb67fb1 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -8,6 +8,7 @@ - Fix: [#5281] Missing supports on miniature railways built backwards. - Fix: [#10379] Banners outside the park can be renamed and modified (original bug). - Fix: [#10582] Low clearance tunnels below water are drawn incorrectly (original bug). +- Fix: [#18309] Flying and Multi Dimension trains glitch when changing between inverted and uninverted track when uncap fps is on. - Fix: [#23486] Object selection minimum requirements can be bypassed with close window hotkey. - Fix: [#23743] Parks with guest goals over 32767 do not appear in the scenario list. - Fix: [#23844] Sound effects keep playing when loading another save. diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 5b2120d6fe..4a05b51f36 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -26,6 +26,7 @@ #include "../core/Speed.hpp" #include "../entity/EntityList.h" #include "../entity/EntityRegistry.h" +#include "../entity/EntityTweener.h" #include "../entity/Particle.h" #include "../entity/Yaw.hpp" #include "../interface/Viewport.h" @@ -7004,6 +7005,7 @@ bool Vehicle::UpdateTrackMotionForwardsGetNewTrack( } // Update VehicleFlags::CarIsInverted flag + const auto previousCarIsInverted = HasFlag(VehicleFlags::CarIsInverted); ClearFlag(VehicleFlags::CarIsInverted); { auto rideType = ::GetRide(tileElement->AsTrack()->GetRideIndex())->type; @@ -7014,6 +7016,10 @@ bool Vehicle::UpdateTrackMotionForwardsGetNewTrack( SetFlag(VehicleFlags::CarIsInverted); } } + if (previousCarIsInverted != HasFlag(VehicleFlags::CarIsInverted)) + { + EntityTweener::Get().RemoveEntity(this); + } } } @@ -7393,6 +7399,7 @@ bool Vehicle::UpdateTrackMotionBackwardsGetNewTrack(TrackElemType trackType, con } // Update VehicleFlags::CarIsInverted + const auto previousCarIsInverted = HasFlag(VehicleFlags::CarIsInverted); ClearFlag(VehicleFlags::CarIsInverted); if (GetRideTypeDescriptor(curRide.type).HasFlag(RtdFlag::hasInvertedVariant)) { @@ -7400,6 +7407,10 @@ bool Vehicle::UpdateTrackMotionBackwardsGetNewTrack(TrackElemType trackType, con { SetFlag(VehicleFlags::CarIsInverted); } + if (previousCarIsInverted != HasFlag(VehicleFlags::CarIsInverted)) + { + EntityTweener::Get().RemoveEntity(this); + } } trackPos = { trackBeginEnd.begin_x, trackBeginEnd.begin_y, trackBeginEnd.begin_z };