From cd63cd34d1810f84fe6bee8441fe22af47aa1be9 Mon Sep 17 00:00:00 2001 From: Harry Hopkinson <63599884+Harry-Hopkinson@users.noreply.github.com> Date: Fri, 23 May 2025 13:48:06 +0100 Subject: [PATCH] Close #24400: Sort rides with preservation order alphabetically --- distribution/changelog.txt | 1 + src/openrct2-ui/windows/EditorScenarioOptions.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index ef326daed9..8880623194 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -4,6 +4,7 @@ - Feature: [#24313] [Plugin] Add API for setting a ride vehicle’s sprite to a smoke plume. - Improved: [#24364] Improve the fallback vehicle sprites for Zero G Rolls, and allow small ones to be built without cheats if the fallbacks are available. - Improved: [#24368] Clicking the in-game update notication now leads to a more user-friendly download page. +- Improved: [#24400] Ride list in preservation window is now sorted alphabetically. - Improved: [#24409] Steam installs of RCT Classic are now detected automatically. - Improved: [#24413] Better performance when moving the viewport on Windows and Linux platforms. - Improved: [#24417] Improve the fallback vehicle sprites for Dive Loops. diff --git a/src/openrct2-ui/windows/EditorScenarioOptions.cpp b/src/openrct2-ui/windows/EditorScenarioOptions.cpp index 08f5d8b3c7..afa3c49aae 100644 --- a/src/openrct2-ui/windows/EditorScenarioOptions.cpp +++ b/src/openrct2-ui/windows/EditorScenarioOptions.cpp @@ -2185,6 +2185,14 @@ namespace OpenRCT2::Ui::Windows WindowSetResize(*this, kSizeRides, kSizeRides); } + static std::string GetRideString(RideId rideId) + { + const auto* ride = GetRide(rideId); + if (ride == nullptr) + return ""; + return ride->getName(); + } + /** * * rct2: 0x00672544 @@ -2206,6 +2214,11 @@ namespace OpenRCT2::Ui::Windows } } + // Sort the rides alphabetically + std::stable_sort(_rideableRides.begin(), _rideableRides.end(), [](const RideId& a, const RideId& b) { + return String::compare(GetRideString(a), GetRideString(b), false) < 0; + }); + if (oldSize != _rideableRides.size()) { Invalidate();