summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2008-02-13 18:11:19 +0000
committerpeter1138 <peter1138@openttd.org>2008-02-13 18:11:19 +0000
commitb7cd7919883ebec71a0e8ac88beb4bf72312e0d2 (patch)
treec2d214e80b03f3fd78f62b7dcc562a091265dd1a /src
parentfd51465c8bc1d86d67678adcef78aba5349dd492 (diff)
downloadopenttd-b7cd7919883ebec71a0e8ac88beb4bf72312e0d2.tar.xz
(svn r12133) -Fix: Vehicle sorting by max speed did not work properly for trains. Instead of trying to work it out again, just use the cached values...
Diffstat (limited to 'src')
-rw-r--r--src/vehicle_gui.cpp14
1 files changed, 1 insertions, 13 deletions
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index ca7672b6e..3a5d1f4ec 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -644,22 +644,10 @@ static int CDECL VehicleMaxSpeedSorter(const void *a, const void *b)
{
const Vehicle* va = *(const Vehicle**)a;
const Vehicle* vb = *(const Vehicle**)b;
- int max_speed_a = 0xFFFF, max_speed_b = 0xFFFF;
int r;
- const Vehicle *ua = va, *ub = vb;
if (va->type == VEH_TRAIN && vb->type == VEH_TRAIN) {
- do {
- if (RailVehInfo(ua->engine_type)->max_speed != 0)
- max_speed_a = min(max_speed_a, RailVehInfo(ua->engine_type)->max_speed);
- } while ((ua = ua->Next()) != NULL);
-
- do {
- if (RailVehInfo(ub->engine_type)->max_speed != 0)
- max_speed_b = min(max_speed_b, RailVehInfo(ub->engine_type)->max_speed);
- } while ((ub = ub->Next()) != NULL);
-
- r = max_speed_a - max_speed_b;
+ r = va->u.rail.cached_max_speed - vb->u.rail.cached_max_speed;
} else {
r = va->max_speed - vb->max_speed;
}