From 51b4bbbce52f8fbf57e81c6215b64a267e171b8b Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Wed, 17 Sep 2025 23:09:07 +0200 Subject: [PATCH] Allow shifting track designs underground Since about a year ago, OpenRCT2 has allowed players to shift ride/track designs using modifier keys (#22669). This was, however, limited to heights above-ground. This PR changes this by omitting the 'Z placement assist' when ctrl/shift modifiers are used. This means the helpful 'nudge' to overground is now omitted if (and only if) these modifier keys are involved. Below is an example of what placement now looks like (with clearance checks disabled for easier debugging): https://github.com/user-attachments/assets/3b23bc1d-ab7b-43a2-ad40-216ab83952d2 --- distribution/changelog.txt | 1 + src/openrct2-ui/windows/TrackDesignPlace.cpp | 22 ++++++++++++++++++++ src/openrct2/network/NetworkBase.cpp | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 2822f67350..357b64fc91 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -2,6 +2,7 @@ ------------------------------------------------------------------------ - Improved: [#2296, #2307] The land tool now takes sloped track and paths into account when modifying land. - Change: [#25161] Revert to the ‘fair ride price’ calculation of vanilla RCT2. +- Fix: [#24513] Ride/track designs can now be shifted underground as well. - Fix: [#25131] The Reverse Freefall Coaster On-ride photo section track has incorrectly coloured ties. - Fix: [#25132] Crash when trying to use simulate on incomplete ride. - Fix: [#25134] Vehicles visually glitch on diagonal steep slopes. diff --git a/src/openrct2-ui/windows/TrackDesignPlace.cpp b/src/openrct2-ui/windows/TrackDesignPlace.cpp index 7d1c076e2b..3389e93274 100644 --- a/src/openrct2-ui/windows/TrackDesignPlace.cpp +++ b/src/openrct2-ui/windows/TrackDesignPlace.cpp @@ -98,6 +98,7 @@ namespace OpenRCT2::Ui::Windows int32_t _trackPlaceShiftZ; int32_t _trackPlaceZ; + bool _triggeredUndergroundView = false; public: void onOpen() override @@ -538,6 +539,27 @@ namespace OpenRCT2::Ui::Windows if (mapCoords.x == kLocationNull) return std::nullopt; + // Trigger underground view? + auto* mainWnd = WindowGetMain(); + if (mainWnd != nullptr && mainWnd->viewport != nullptr) + { + if (_trackPlaceZ < surfaceElement->GetBaseZ() && !_triggeredUndergroundView) + { + mainWnd->viewport->flags |= VIEWPORT_FLAG_UNDERGROUND_INSIDE; + _triggeredUndergroundView = true; + } + else if (_trackPlaceZ >= surfaceElement->GetBaseZ() && _triggeredUndergroundView) + { + mainWnd->viewport->flags &= ~VIEWPORT_FLAG_UNDERGROUND_INSIDE; + _triggeredUndergroundView = false; + } + } + + // Force placement at the designated position if modifiers are used + if (_trackPlaceShiftState || _trackPlaceCtrlState) + return _trackPlaceZ; + + // Figure out a good position to place the design, taking other elements and surface height into account return _trackPlaceZ + TrackDesignGetZPlacement( *_trackDesign, RideGetTemporaryForPreview(), { mapCoords, _trackPlaceZ, _currentTrackPieceDirection }); diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index 94f8a8a146..634e9574fd 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -47,7 +47,7 @@ // It is used for making sure only compatible builds get connected, even within // single OpenRCT2 version. -constexpr uint8_t kStreamVersion = 4; +constexpr uint8_t kStreamVersion = 5; const std::string kStreamID = std::string(kOpenRCT2Version) + "-" + std::to_string(kStreamVersion);