changeset 20447:04a19e96e7fe draft

(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
author rubidium <rubidium@openttd.org>
date Sat, 15 Jun 2013 15:26:24 +0000
parents bb101b3fd00c
children ce1c99d711ea
files src/lang/english.txt src/station_gui.cpp
diffstat 2 files changed, 23 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -278,7 +278,8 @@
 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)
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -229,17 +229,29 @@
 	}
 
 	/** 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 @@
 GUIStationList::SortFunction * const CompanyStationsWindow::sorter_funcs[] = {
 	&StationNameSorter,
 	&StationTypeSorter,
-	&StationWaitingSorter,
+	&StationWaitingTotalSorter,
+	&StationWaitingAvailableSorter,
 	&StationRatingMaxSorter,
 	&StationRatingMinSorter
 };
@@ -653,7 +666,8 @@
 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