summaryrefslogtreecommitdiff
path: root/src/station_gui.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2013-06-15 15:26:24 +0000
committerrubidium <rubidium@openttd.org>2013-06-15 15:26:24 +0000
commit420f95a6e9ab5410e44c1b46d0d3ba2e0040b532 (patch)
tree59a9e04141969baafc76260aff3b41ac76cefa10 /src/station_gui.cpp
parent2ef4438882d658ed4d2c6ace462145ac77a4d6c4 (diff)
downloadopenttd-420f95a6e9ab5410e44c1b46d0d3ba2e0040b532.tar.xz
(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
Diffstat (limited to 'src/station_gui.cpp')
-rw-r--r--src/station_gui.cpp28
1 files changed, 21 insertions, 7 deletions
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