From 23ea4613e6f0f195df462451e10b058532e53944 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Tue, 20 Aug 2024 22:09:53 +0200 Subject: [PATCH] Fix virtual floor no longer appearing during track construction (#22602) --- distribution/changelog.txt | 1 + src/openrct2/windows/_legacy.cpp | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 44e0c52c9f..8f8fdc84e5 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -19,6 +19,7 @@ - Fix: [#22316] Potential crash when switching the drawing engine while the game is running. - Fix: [#22395, #22396] Misaligned tick marks in financial and guest count graphs (original bug). - Fix: [#22457] Potential crash opening the scenario select window. +- Fix: [#22520] Virtual floor no longer appears when holding modifier keys during track construction. - Fix: [#22582] Lighting effects are not enabled/disabled correctly, making the game appear frozen. 0.4.13 (2024-08-04) diff --git a/src/openrct2/windows/_legacy.cpp b/src/openrct2/windows/_legacy.cpp index 1793d54a60..059390a4d4 100644 --- a/src/openrct2/windows/_legacy.cpp +++ b/src/openrct2/windows/_legacy.cpp @@ -18,6 +18,7 @@ #include "../entity/Staff.h" #include "../interface/Viewport.h" #include "../network/network.h" +#include "../paint/VirtualFloor.h" #include "../ride/RideConstruction.h" #include "../ride/RideData.h" #include "../ride/Track.h" @@ -78,12 +79,17 @@ money64 PlaceProvisionalTrackPiece( if (res.Error != GameActions::Status::Ok) return kMoney64Undefined; - int16_t zBegin{}; + int16_t zBegin{}, zEnd{}; const auto& ted = GetTrackElementDescriptor(trackType); const TrackCoordinates& coords = ted.coordinates; if (ride->GetRideTypeDescriptor().HasFlag(RtdFlag::hasTrack)) { zBegin = coords.zBegin; + zEnd = coords.zEnd; + } + else + { + zEnd = zBegin = coords.zBegin; } _unkF440C5 = { trackPos.x, trackPos.y, trackPos.z + zBegin, static_cast(trackDirection) }; @@ -96,6 +102,15 @@ money64 PlaceProvisionalTrackPiece( if (_currentTrackPitchEnd != TrackPitch::None) ViewportSetVisibility(ViewportVisibility::TrackHeights); + // Invalidate previous track piece (we may not be changing height!) + VirtualFloorInvalidate(); + + if (!isToolActive(WindowClass::Scenery)) + { + // Set height to where the next track piece would begin + VirtualFloorSetHeight(trackPos.z - zBegin + zEnd); + } + return res.Cost; }