summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2007-02-15 17:51:39 +0000
committerbjarni <bjarni@openttd.org>2007-02-15 17:51:39 +0000
commit8675b8ec7d36592777c23cfcfe273fa17c66afef (patch)
treef098b0ddacbd0782c2017ca299d12926bb7456f0 /src
parentc50396cb15a9de2bfa68e0be4d64b76a261e7e3b (diff)
downloadopenttd-8675b8ec7d36592777c23cfcfe273fa17c66afef.tar.xz
(svn r8746) -Regression r8331: build train window could sort incorrectly by EngineID with certain newGRF sets
Diffstat (limited to 'src')
-rw-r--r--src/build_vehicle_gui.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index e38c852bc..61f9f7a58 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -224,6 +224,15 @@ static int CDECL TrainEnginePowerVsRunningCostSorter(const void *a, const void *
return _internal_sort_order ? -r : r;
}
+static int CDECL TrainEngineNumberSorter(const void *a, const void *b)
+{
+ const EngineID va = *(const EngineID*)a;
+ const EngineID vb = *(const EngineID*)b;
+ int r = ListPositionOfEngine(va) - ListPositionOfEngine(vb);
+
+ return _internal_sort_order ? -r : r;
+}
+
static int CDECL TrainEnginesThenWagonsSorter(const void *a, const void *b)
{
EngineID va = *(const EngineID*)a;
@@ -290,7 +299,7 @@ static int CDECL AircraftEngineCargoSorter(const void *a, const void *b)
static EngList_SortTypeFunction * const _sorter[][9] = {{
/* Trains */
- &EngineNumberSorter,
+ &TrainEngineNumberSorter,
&TrainEngineCostSorter,
&TrainEngineSpeedSorter,
&TrainEnginePowerSorter,