From 2656f3acc2cd74617acdb90f41f75a55d7b3f26d Mon Sep 17 00:00:00 2001 From: Michael Steenbeek <1478678+Gymnasiast@users.noreply.github.com> Date: Sat, 24 May 2025 14:52:54 +0200 Subject: [PATCH] Eliminate direct ride type check --- src/openrct2-ui/windows/Ride.cpp | 4 +++- src/openrct2/object/MusicObject.cpp | 6 +++--- src/openrct2/object/MusicObject.h | 9 ++++++++- src/openrct2/ride/RideData.h | 2 ++ src/openrct2/ride/rtd/gentle/MerryGoRound.h | 3 ++- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 5e69cfb707..41b46bfb29 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -5048,6 +5048,7 @@ namespace OpenRCT2::Ui::Windows if (ride == nullptr) return; + const auto& rtd = ride->getRideTypeDescriptor(); // Construct list of available music auto& musicOrder = window_ride_current_music_style_order; musicOrder.clear(); @@ -5077,7 +5078,8 @@ namespace OpenRCT2::Ui::Windows } } - if (getGameState().cheats.unlockOperatingLimits || musicObj->SupportsRideType(ride->type)) + if (getGameState().cheats.unlockOperatingLimits + || musicObj->SupportsRideType(ride->type, rtd.HasFlag(RtdFlag::requireExplicitListingInMusicObjects))) { musicOrder.push_back(i); } diff --git a/src/openrct2/object/MusicObject.cpp b/src/openrct2/object/MusicObject.cpp index 3a23520dd6..e54e1c8a6b 100644 --- a/src/openrct2/object/MusicObject.cpp +++ b/src/openrct2/object/MusicObject.cpp @@ -191,12 +191,12 @@ std::optional MusicObject::GetOriginalStyleId() const return _originalStyleId; } -bool MusicObject::SupportsRideType(ride_type_t rideType) +bool MusicObject::SupportsRideType(ride_type_t rideType, bool onlyAllowIfExplicitlyListed) { if (_rideTypes.size() == 0) { - // Default behaviour for music is to only exclude from merry-go-round - return rideType != RIDE_TYPE_MERRY_GO_ROUND; + // Some rides, like the merry-go-round, need music objects to explicitly list them. + return !onlyAllowIfExplicitlyListed; } auto it = std::find(_rideTypes.begin(), _rideTypes.end(), rideType); diff --git a/src/openrct2/object/MusicObject.h b/src/openrct2/object/MusicObject.h index 085dbde851..faea0116bc 100644 --- a/src/openrct2/object/MusicObject.h +++ b/src/openrct2/object/MusicObject.h @@ -65,7 +65,14 @@ public: bool HasPreview() const; std::optional GetOriginalStyleId() const; - bool SupportsRideType(ride_type_t rideType); + /** + * + * @param rideType + * @param onlyAllowIfExplicitlyListed If a music object does not provide a list of ride types, + * it will be enabled for all ride types, unless this parameter is set to true. + * @return + */ + bool SupportsRideType(ride_type_t rideType, bool onlyAllowIfExplicitlyListed); size_t GetTrackCount() const; const MusicObjectTrack* GetTrack(size_t trackIndex) const; OpenRCT2::Audio::IAudioSource* GetTrackSample(size_t trackIndex) const; diff --git a/src/openrct2/ride/RideData.h b/src/openrct2/ride/RideData.h index ef310540f4..48a8fd29be 100644 --- a/src/openrct2/ride/RideData.h +++ b/src/openrct2/ride/RideData.h @@ -431,6 +431,8 @@ enum class RtdFlag : uint8_t hasOneStation, hasSeatRotation, allowReversedTrains, + + requireExplicitListingInMusicObjects, }; /** diff --git a/src/openrct2/ride/rtd/gentle/MerryGoRound.h b/src/openrct2/ride/rtd/gentle/MerryGoRound.h index 523a1beb07..59e4fd3590 100644 --- a/src/openrct2/ride/rtd/gentle/MerryGoRound.h +++ b/src/openrct2/ride/rtd/gentle/MerryGoRound.h @@ -29,7 +29,8 @@ constexpr RideTypeDescriptor MerryGoRoundRTD = RtdFlag::hasLoadOptions, RtdFlag::vehicleIsIntegral, RtdFlag::noWallsAroundTrack, RtdFlag::isFlatRide, RtdFlag::hasVehicleColours, RtdFlag::hasMusicByDefault, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, RtdFlag::singleSession, - RtdFlag::interestingToLookAt, RtdFlag::listVehiclesSeparately), + RtdFlag::interestingToLookAt, RtdFlag::listVehiclesSeparately, + RtdFlag::requireExplicitListingInMusicObjects), .RideModes = EnumsToFlags(RideMode::rotation), .DefaultMode = RideMode::rotation, .OperatingSettings = { 4, 25 },