From 420f95a6e9ab5410e44c1b46d0d3ba2e0040b532 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sat, 15 Jun 2013 15:26:24 +0000 Subject: (svn r25405) -Feature-ish: differentiate between total waiting cargo count and available (not reserved) cargo count in the station list -Change: sort based on the cargo count, not the cargo value --- src/lang/english.txt | 3 ++- src/station_gui.cpp | 28 +++++++++++++++++++++------- 2 files changed, 23 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/lang/english.txt b/src/lang/english.txt index 83f909351..424c728f0 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -278,7 +278,8 @@ STR_SORT_BY_LENGTH :Length STR_SORT_BY_LIFE_TIME :Remaining lifetime STR_SORT_BY_TIMETABLE_DELAY :Timetable delay STR_SORT_BY_FACILITY :Station type -STR_SORT_BY_WAITING :Waiting cargo value +STR_SORT_BY_WAITING_TOTAL :Total waiting cargo +STR_SORT_BY_WAITING_AVAILABLE :Available waiting cargo STR_SORT_BY_RATING_MAX :Highest cargo rating STR_SORT_BY_RATING_MIN :Lowest cargo rating STR_SORT_BY_ENGINE_ID :EngineID (classic sort) diff --git a/src/station_gui.cpp b/src/station_gui.cpp index b5e4962eb..9e85899d6 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -229,17 +229,29 @@ protected: } /** Sort stations by their waiting cargo */ - static int CDECL StationWaitingSorter(const Station * const *a, const Station * const *b) + static int CDECL StationWaitingTotalSorter(const Station * const *a, const Station * const *b) { - Money diff = 0; + int diff = 0; CargoID j; FOR_EACH_SET_CARGO_ID(j, cargo_filter) { - if ((*a)->goods[j].cargo.TotalCount() > 0) diff += GetTransportedGoodsIncome((*a)->goods[j].cargo.TotalCount(), 20, 50, j); - if ((*b)->goods[j].cargo.TotalCount() > 0) diff -= GetTransportedGoodsIncome((*b)->goods[j].cargo.TotalCount(), 20, 50, j); + diff += (*a)->goods[j].cargo.TotalCount() - (*b)->goods[j].cargo.TotalCount(); } - return ClampToI32(diff); + return diff; + } + + /** Sort stations by their available waiting cargo */ + static int CDECL StationWaitingAvailableSorter(const Station * const *a, const Station * const *b) + { + int diff = 0; + + CargoID j; + FOR_EACH_SET_CARGO_ID(j, cargo_filter) { + diff += (*a)->goods[j].cargo.AvailableCount() - (*b)->goods[j].cargo.AvailableCount(); + } + + return diff; } /** Sort stations by their rating */ @@ -644,7 +656,8 @@ const Station *CompanyStationsWindow::last_station = NULL; GUIStationList::SortFunction * const CompanyStationsWindow::sorter_funcs[] = { &StationNameSorter, &StationTypeSorter, - &StationWaitingSorter, + &StationWaitingTotalSorter, + &StationWaitingAvailableSorter, &StationRatingMaxSorter, &StationRatingMinSorter }; @@ -653,7 +666,8 @@ GUIStationList::SortFunction * const CompanyStationsWindow::sorter_funcs[] = { const StringID CompanyStationsWindow::sorter_names[] = { STR_SORT_BY_NAME, STR_SORT_BY_FACILITY, - STR_SORT_BY_WAITING, + STR_SORT_BY_WAITING_TOTAL, + STR_SORT_BY_WAITING_AVAILABLE, STR_SORT_BY_RATING_MAX, STR_SORT_BY_RATING_MIN, INVALID_STRING_ID -- cgit v1.2.3-70-g09d2