From ca40a412bcefa3bdccd9fed79d40f8b0a9a2a0a7 Mon Sep 17 00:00:00 2001 From: Andrew <5436387+fidwell@users.noreply.github.com> Date: Mon, 3 Feb 2025 16:48:42 -0500 Subject: [PATCH] Make building new track inherit alternate colour scheme from previous piece --- distribution/changelog.txt | 1 + src/openrct2-ui/windows/RideConstruction.cpp | 6 +++- src/openrct2/ride/RideConstruction.cpp | 35 ++++++++++++++++++-- src/openrct2/ride/RideConstruction.h | 2 ++ 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 66e8aff540..7703202a20 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -1,5 +1,6 @@ 0.4.20 (in development) ------------------------------------------------------------------------ +- Improved: [#23677] Building new ride track now inherits the colour scheme from the previous piece. 0.4.19.1 (2025-02-03) ------------------------------------------------------------------------ diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index 1b8438ec80..752b8ba214 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -253,6 +253,7 @@ namespace OpenRCT2::Ui::Windows _currentTrackPrice = kMoney64Undefined; _currentBrakeSpeed = 8; + _currentColourScheme = RideColourScheme::main; _currentSeatRotationAngle = 4; _currentlySelectedTrack = currentRide->GetRideTypeDescriptor().StartTrackPiece; @@ -2690,7 +2691,7 @@ namespace OpenRCT2::Ui::Windows tempTrackTileElement.AsTrack()->SetRideType(currentRide->type); tempTrackTileElement.AsTrack()->SetHasCableLift(false); tempTrackTileElement.AsTrack()->SetInverted(liftHillAndInvertedState.has(LiftHillAndInverted::inverted)); - tempTrackTileElement.AsTrack()->SetColourScheme(RideColourScheme::main); + tempTrackTileElement.AsTrack()->SetColourScheme(_currentColourScheme); // Skipping seat rotation, should not be necessary for a temporary piece. tempTrackTileElement.AsTrack()->SetRideIndex(rideIndex); @@ -3108,6 +3109,7 @@ namespace OpenRCT2::Ui::Windows _selectedTrackType = tileElement->AsTrack()->GetTrackType(); if (TrackTypeHasSpeedSetting(tileElement->AsTrack()->GetTrackType())) _currentBrakeSpeed = tileElement->AsTrack()->GetBrakeBoosterSpeed(); + _currentColourScheme = static_cast(tileElement->AsTrack()->GetColourScheme()); _currentSeatRotationAngle = tileElement->AsTrack()->GetSeatRotation(); } } @@ -5046,6 +5048,8 @@ namespace OpenRCT2::Ui::Windows properties = _currentSeatRotationAngle << 12; } + properties |= static_cast(_currentColourScheme) << 8; + if (_trackType != nullptr) *_trackType = trackType; if (_trackDirection != nullptr) diff --git a/src/openrct2/ride/RideConstruction.cpp b/src/openrct2/ride/RideConstruction.cpp index 82a6c16518..b0a8ba2814 100644 --- a/src/openrct2/ride/RideConstruction.cpp +++ b/src/openrct2/ride/RideConstruction.cpp @@ -77,6 +77,7 @@ TrackPitch _previousTrackPitchEnd; CoordsXYZ _previousTrackPiece; uint8_t _currentBrakeSpeed; +RideColourScheme _currentColourScheme; uint8_t _currentSeatRotationAngle; CoordsXYZD _unkF440C5; @@ -441,7 +442,13 @@ std::optional GetTrackElementOriginAndApplyChanges( } if (flags & TRACK_ELEMENT_SET_COLOUR_SCHEME) { - trackElement->SetColourScheme(static_cast(extra_params & 0xFF)); + auto newScheme = static_cast(extra_params & 0xFF); + trackElement->SetColourScheme(newScheme); + + if (_previousTrackPiece == retCoordsXYZ) + { + _currentColourScheme = newScheme; + } } if (flags & TRACK_ELEMENT_SET_SEAT_ROTATION) { @@ -631,12 +638,23 @@ void RideConstructionSetDefaultNextPiece() _currentTrackRollEnd = bank; _previousTrackRollEnd = bank; + const auto& trackElement = tileElement->AsTrack(); + // Set track slope and lift hill _currentTrackPitchEnd = slope; _previousTrackPitchEnd = slope; - _currentTrackHasLiftHill = tileElement->AsTrack()->HasChain() + _currentTrackHasLiftHill = trackElement->HasChain() && ((slope != TrackPitch::Down25 && slope != TrackPitch::Down60) || GetGameState().Cheats.enableChainLiftOnAllTrack); + + if (TrackTypeHasSpeedSetting(trackElement->GetTrackType())) + _currentBrakeSpeed = trackElement->GetBrakeBoosterSpeed(); + _currentColourScheme = static_cast(trackElement->GetColourScheme()); + _currentSeatRotationAngle = trackElement->GetSeatRotation(); + + _previousTrackPiece.x = trackBeginEnd.begin_x; + _previousTrackPiece.y = trackBeginEnd.begin_y; + _previousTrackPiece.z = trackElement->GetBaseZ(); break; } case RideConstructionState::Back: @@ -679,13 +697,24 @@ void RideConstructionSetDefaultNextPiece() _currentTrackRollEnd = bank; _previousTrackRollEnd = bank; + const auto& trackElement = tileElement->AsTrack(); + // Set track slope and lift hill _currentTrackPitchEnd = slope; _previousTrackPitchEnd = slope; if (!GetGameState().Cheats.enableChainLiftOnAllTrack) { - _currentTrackHasLiftHill = tileElement->AsTrack()->HasChain(); + _currentTrackHasLiftHill = trackElement->HasChain(); } + + if (TrackTypeHasSpeedSetting(trackElement->GetTrackType())) + _currentBrakeSpeed = trackElement->GetBrakeBoosterSpeed(); + _currentColourScheme = static_cast(trackElement->GetColourScheme()); + _currentSeatRotationAngle = trackElement->GetSeatRotation(); + + _previousTrackPiece.x = xyElement.x; + _previousTrackPiece.y = xyElement.y; + _previousTrackPiece.z = trackElement->GetBaseZ(); break; } default: diff --git a/src/openrct2/ride/RideConstruction.h b/src/openrct2/ride/RideConstruction.h index ae20ab7666..41f15cbdea 100644 --- a/src/openrct2/ride/RideConstruction.h +++ b/src/openrct2/ride/RideConstruction.h @@ -13,6 +13,7 @@ #include "../core/FlagHolder.hpp" #include "../core/Money.hpp" #include "../world/Location.hpp" +#include "RideColour.h" #include "Station.h" #include "Track.h" @@ -79,6 +80,7 @@ extern TrackPitch _previousTrackPitchEnd; extern CoordsXYZ _previousTrackPiece; extern uint8_t _currentBrakeSpeed; +extern RideColourScheme _currentColourScheme; extern uint8_t _currentSeatRotationAngle; extern CoordsXYZD _unkF440C5;