diff options
author | rubidium <rubidium@openttd.org> | 2009-04-12 19:15:53 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-04-12 19:15:53 +0000 |
commit | ae3ebe683446272b6d90346b8a0e6508896542b1 (patch) | |
tree | 736032a72b8a906d54314360cec53d2af3037dac /src/station_gui.cpp | |
parent | f46f8bd42780c31d3d4f9ba5c87790e151058258 (diff) | |
download | openttd-ae3ebe683446272b6d90346b8a0e6508896542b1.tar.xz |
(svn r16045) -Feature [FS#597]: allow sorting stations by the lowest cargo rating instead of only by the highest cargo rating (based on the idea of KeeperOfTheSoul)
Diffstat (limited to 'src/station_gui.cpp')
-rw-r--r-- | src/station_gui.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/station_gui.cpp b/src/station_gui.cpp index 185e8d382..a39b42388 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -219,6 +219,20 @@ protected: return maxr1 - maxr2; } + /** Sort stations by their rating */ + static int CDECL StationRatingMinSorter(const Station * const *a, const Station * const *b) + { + byte minr1 = 0; + byte minr2 = 0; + + for (CargoID j = 0; j < NUM_CARGO; j++) { + if (HasBit((*a)->goods[j].acceptance_pickup, GoodsEntry::PICKUP)) minr1 = min(minr1, (*a)->goods[j].rating); + if (HasBit((*b)->goods[j].acceptance_pickup, GoodsEntry::PICKUP)) minr2 = min(minr2, (*b)->goods[j].rating); + } + + return minr1 - minr2; + } + /** Sort the stations list */ void SortStationsList() { @@ -573,7 +587,8 @@ GUIStationList::SortFunction * const CompanyStationsWindow::sorter_funcs[] = { &StationNameSorter, &StationTypeSorter, &StationWaitingSorter, - &StationRatingMaxSorter + &StationRatingMaxSorter, + &StationRatingMinSorter }; /* Names of the sorting functions */ @@ -582,6 +597,7 @@ const StringID CompanyStationsWindow::sorter_names[] = { STR_SORT_BY_FACILITY, STR_SORT_BY_WAITING, STR_SORT_BY_RATING_MAX, + STR_SORT_BY_RATING_MIN, INVALID_STRING_ID }; |