1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-10 09:32:29 +01:00

Fix #25201: Unstable sorting of the ride list

This commit is contained in:
ζeh Matt
2025-09-24 15:42:44 +03:00
parent 4bd911b472
commit 8a6d855edd

View File

@@ -983,6 +983,11 @@ namespace OpenRCT2::Ui::Windows
void SortList()
{
// Maintain stability by first sorting by ride id.
SortListByPredicate([](const Ride& thisRide, const Ride& otherRide) -> bool {
return thisRide.id.ToUnderlying() < otherRide.id.ToUnderlying();
});
switch (listInformationType)
{
case INFORMATION_TYPE_STATUS:
@@ -990,77 +995,77 @@ namespace OpenRCT2::Ui::Windows
break;
case INFORMATION_TYPE_POPULARITY:
SortListByPredicate([](const Ride& thisRide, const Ride& otherRide) -> bool {
return thisRide.popularity * 4 <= otherRide.popularity * 4;
return thisRide.popularity < otherRide.popularity;
});
break;
case INFORMATION_TYPE_SATISFACTION:
SortListByPredicate([](const Ride& thisRide, const Ride& otherRide) -> bool {
return thisRide.satisfaction * 5 <= otherRide.satisfaction * 5;
return thisRide.satisfaction < otherRide.satisfaction;
});
break;
case INFORMATION_TYPE_PROFIT:
SortListByPredicate([](const Ride& thisRide, const Ride& otherRide) -> bool {
return thisRide.profit <= otherRide.profit;
return thisRide.profit < otherRide.profit;
});
break;
case INFORMATION_TYPE_TOTAL_CUSTOMERS:
SortListByPredicate([](const Ride& thisRide, const Ride& otherRide) -> bool {
return thisRide.totalCustomers <= otherRide.totalCustomers;
return thisRide.totalCustomers < otherRide.totalCustomers;
});
break;
case INFORMATION_TYPE_TOTAL_PROFIT:
SortListByPredicate([](const Ride& thisRide, const Ride& otherRide) -> bool {
return thisRide.totalProfit <= otherRide.totalProfit;
return thisRide.totalProfit < otherRide.totalProfit;
});
break;
case INFORMATION_TYPE_CUSTOMERS:
SortListByPredicate([](const Ride& thisRide, const Ride& otherRide) -> bool {
return RideCustomersPerHour(thisRide) <= RideCustomersPerHour(otherRide);
return RideCustomersPerHour(thisRide) < RideCustomersPerHour(otherRide);
});
break;
case INFORMATION_TYPE_AGE:
SortListByPredicate([](const Ride& thisRide, const Ride& otherRide) -> bool {
return thisRide.buildDate <= otherRide.buildDate;
return thisRide.buildDate < otherRide.buildDate;
});
break;
case INFORMATION_TYPE_INCOME:
SortListByPredicate([](const Ride& thisRide, const Ride& otherRide) -> bool {
return thisRide.incomePerHour <= otherRide.incomePerHour;
return thisRide.incomePerHour < otherRide.incomePerHour;
});
break;
case INFORMATION_TYPE_RUNNING_COST:
SortListByPredicate([](const Ride& thisRide, const Ride& otherRide) -> bool {
return thisRide.upkeepCost <= otherRide.upkeepCost;
return thisRide.upkeepCost < otherRide.upkeepCost;
});
break;
case INFORMATION_TYPE_QUEUE_LENGTH:
SortListByPredicate([](const Ride& thisRide, const Ride& otherRide) -> bool {
return thisRide.getTotalQueueLength() <= otherRide.getTotalQueueLength();
return thisRide.getTotalQueueLength() < otherRide.getTotalQueueLength();
});
break;
case INFORMATION_TYPE_QUEUE_TIME:
SortListByPredicate([](const Ride& thisRide, const Ride& otherRide) -> bool {
return thisRide.getMaxQueueTime() <= otherRide.getMaxQueueTime();
return thisRide.getMaxQueueTime() < otherRide.getMaxQueueTime();
});
break;
case INFORMATION_TYPE_RELIABILITY:
SortListByPredicate([](const Ride& thisRide, const Ride& otherRide) -> bool {
return thisRide.reliabilityPercentage <= otherRide.reliabilityPercentage;
return thisRide.reliabilityPercentage < otherRide.reliabilityPercentage;
});
break;
case INFORMATION_TYPE_DOWN_TIME:
SortListByPredicate([](const Ride& thisRide, const Ride& otherRide) -> bool {
return thisRide.downtime <= otherRide.downtime;
return thisRide.downtime < otherRide.downtime;
});
break;
case INFORMATION_TYPE_LAST_INSPECTION:
SortListByPredicate([](const Ride& thisRide, const Ride& otherRide) -> bool {
return thisRide.lastInspection <= otherRide.lastInspection;
return thisRide.lastInspection < otherRide.lastInspection;
});
break;
case INFORMATION_TYPE_GUESTS_FAVOURITE:
SortListByPredicate([](const Ride& thisRide, const Ride& otherRide) -> bool {
return thisRide.guestsFavourite <= otherRide.guestsFavourite;
return thisRide.guestsFavourite < otherRide.guestsFavourite;
});
break;
case INFORMATION_TYPE_EXCITEMENT:
@@ -1068,7 +1073,7 @@ namespace OpenRCT2::Ui::Windows
const auto leftValue = thisRide.ratings.isNull() ? RideRating::kUndefined : thisRide.ratings.excitement;
const auto rightValue = otherRide.ratings.isNull() ? RideRating::kUndefined
: otherRide.ratings.excitement;
return leftValue <= rightValue;
return leftValue < rightValue;
});
break;
case INFORMATION_TYPE_INTENSITY:
@@ -1076,14 +1081,14 @@ namespace OpenRCT2::Ui::Windows
const auto leftValue = thisRide.ratings.isNull() ? RideRating::kUndefined : thisRide.ratings.intensity;
const auto rightValue = otherRide.ratings.isNull() ? RideRating::kUndefined
: otherRide.ratings.intensity;
return leftValue <= rightValue;
return leftValue < rightValue;
});
break;
case INFORMATION_TYPE_NAUSEA:
SortListByPredicate([](const Ride& thisRide, const Ride& otherRide) -> bool {
const auto leftValue = thisRide.ratings.isNull() ? RideRating::kUndefined : thisRide.ratings.nausea;
const auto rightValue = otherRide.ratings.isNull() ? RideRating::kUndefined : otherRide.ratings.nausea;
return leftValue <= rightValue;
return leftValue < rightValue;
});
break;
}