summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lang/english.txt1
-rw-r--r--src/vehicle_gui.cpp10
2 files changed, 11 insertions, 0 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 9d3ddb5b3..2303a8e0d 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -259,6 +259,7 @@ STR_SORT_BY_MODEL :Model
STR_SORT_BY_VALUE :Value
STR_SORT_BY_LENGTH :Length
STR_SORT_BY_LIFE_TIME :Remaining life time
+STR_SORT_BY_TIMETABLE_DELAY :Timetable delay
STR_SORT_BY_FACILITY :Station type
STR_SORT_BY_WAITING :Waiting cargo value
STR_SORT_BY_RATING_MAX :Highest cargo rating
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 335094a43..226aa3265 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -51,6 +51,7 @@ static GUIVehicleList::SortFunction VehicleModelSorter;
static GUIVehicleList::SortFunction VehicleValueSorter;
static GUIVehicleList::SortFunction VehicleLengthSorter;
static GUIVehicleList::SortFunction VehicleTimeToLiveSorter;
+static GUIVehicleList::SortFunction VehicleTimetableDelaySorter;
GUIVehicleList::SortFunction * const BaseVehicleListWindow::vehicle_sorter_funcs[] = {
&VehicleNumberSorter,
@@ -65,6 +66,7 @@ GUIVehicleList::SortFunction * const BaseVehicleListWindow::vehicle_sorter_funcs
&VehicleValueSorter,
&VehicleLengthSorter,
&VehicleTimeToLiveSorter,
+ &VehicleTimetableDelaySorter,
};
const StringID BaseVehicleListWindow::vehicle_sorter_names[] = {
@@ -80,6 +82,7 @@ const StringID BaseVehicleListWindow::vehicle_sorter_names[] = {
STR_SORT_BY_VALUE,
STR_SORT_BY_LENGTH,
STR_SORT_BY_LIFE_TIME,
+ STR_SORT_BY_TIMETABLE_DELAY,
INVALID_STRING_ID
};
@@ -626,6 +629,13 @@ static int CDECL VehicleTimeToLiveSorter(const Vehicle * const *a, const Vehicle
return (r != 0) ? r : VehicleNumberSorter(a, b);
}
+/** Sort vehicles by the timetable delay */
+static int CDECL VehicleTimetableDelaySorter(const Vehicle * const *a, const Vehicle * const *b)
+{
+ int r = (*a)->lateness_counter - (*b)->lateness_counter;
+ return (r != 0) ? r : VehicleNumberSorter(a, b);
+}
+
void InitializeGUI()
{
MemSetT(&_sorting, 0);