diff options
author | peter1138 <peter1138@openttd.org> | 2008-07-20 21:21:51 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2008-07-20 21:21:51 +0000 |
commit | 47ba8389b50a54dec1c08e7af5ba08813857d759 (patch) | |
tree | 26dd5638af3ae49515c381ac099da9e76ce9d938 | |
parent | 8113efb0f2d3cd9af59e6a782e671fc1976e4ac3 (diff) | |
download | openttd-47ba8389b50a54dec1c08e7af5ba08813857d759.tar.xz |
(svn r13760) -Codechange: With multiple NewGRF engine sets, engine IDs may not be allocated in the order expected by GRF authors, so sort by 'list position' instead of engine ID for all vehicle types.
-rw-r--r-- | src/autoreplace_gui.cpp | 4 | ||||
-rw-r--r-- | src/build_vehicle_gui.cpp | 13 |
2 files changed, 4 insertions, 13 deletions
diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index c2c98ebd7..7dd69d3cc 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -59,7 +59,7 @@ enum ReplaceVehicleWindowWidgets { RVW_WIDGET_TRAIN_WAGONREMOVE_TOGGLE, }; -static int CDECL TrainEngineNumberSorter(const void *a, const void *b) +static int CDECL EngineNumberSorter(const void *a, const void *b) { const EngineID va = *(const EngineID*)a; const EngineID vb = *(const EngineID*)b; @@ -213,7 +213,7 @@ class ReplaceVehicleWindow : public Window { if (eid == this->sel_engine[i]) selected_engine = eid; // The selected engine is still in the list } this->sel_engine[i] = selected_engine; // update which engine we selected (the same or none, if it's not in the list anymore) - if (type == VEH_TRAIN) EngList_Sort(list, &TrainEngineNumberSorter); + EngList_Sort(list, &EngineNumberSorter); } /** Generate the lists */ diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index f84f7b2b7..cfc67df61 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -71,7 +71,7 @@ static int CDECL EngineNumberSorter(const void *a, const void *b) { const EngineID va = *(const EngineID*)a; const EngineID vb = *(const EngineID*)b; - int r = va - vb; + int r = ListPositionOfEngine(va) - ListPositionOfEngine(vb); return _internal_sort_order ? -r : r; } @@ -193,15 +193,6 @@ 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 TrainEngineCapacitySorter(const void *a, const void *b) { int va = RailVehInfo(*(const EngineID*)a)->capacity; @@ -381,7 +372,7 @@ static int CDECL AircraftEngineCargoSorter(const void *a, const void *b) static EngList_SortTypeFunction * const _sorter[][10] = {{ /* Trains */ - &TrainEngineNumberSorter, + &EngineNumberSorter, &TrainEngineCostSorter, &TrainEngineSpeedSorter, &TrainEnginePowerSorter, |