summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2008-01-01 17:01:06 +0000
committerpeter1138 <peter1138@openttd.org>2008-01-01 17:01:06 +0000
commit24784b7e0df21bba0d83ea9a1f5f95fd6116b625 (patch)
tree3c7bc9198f882ee5560bac89c2d9034d6fa82cc4 /src
parentf0e9c0cfc911ad1a2649f309ccb6191d98bc6be3 (diff)
downloadopenttd-24784b7e0df21bba0d83ea9a1f5f95fd6116b625.tar.xz
(svn r11737) -Fix: Reinstate NewGRF-specified engine list order in autoreplace window.
Diffstat (limited to 'src')
-rw-r--r--src/autoreplace_gui.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp
index 940b0d78b..fd9070f7c 100644
--- a/src/autoreplace_gui.cpp
+++ b/src/autoreplace_gui.cpp
@@ -31,6 +31,15 @@ static const StringID _rail_types_list[] = {
INVALID_STRING_ID
};
+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 r;
+}
+
/* General Vehicle GUI based procedures that are independent of vehicle types */
void InitializeVehiclesGuiList()
{
@@ -172,6 +181,7 @@ static void GenerateReplaceVehList(Window *w, bool draw_left)
if (e == WP(w, replaceveh_d).sel_engine[i]) selected_engine = e; // The selected engine is still in the list
}
WP(w, replaceveh_d).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);
}
/** Generate the lists