diff options
author | frosch <frosch@openttd.org> | 2009-01-24 14:26:48 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2009-01-24 14:26:48 +0000 |
commit | 7120b2455ab044aca379b234b24b9bdcfd642ac2 (patch) | |
tree | 0890255fd73402ca21ee816e7c56b72568c00d2d /src/ai/api | |
parent | c40406a2371e40618209fd6914b27b86ec782f9e (diff) | |
download | openttd-7120b2455ab044aca379b234b24b9bdcfd642ac2.tar.xz |
(svn r15255) -Fix (r15027): AIVehicle::GetLength() returned only the length of the first part of articulated road vehicles.
Diffstat (limited to 'src/ai/api')
-rw-r--r-- | src/ai/api/ai_vehicle.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/ai/api/ai_vehicle.cpp b/src/ai/api/ai_vehicle.cpp index ec5d42f65..197b558b8 100644 --- a/src/ai/api/ai_vehicle.cpp +++ b/src/ai/api/ai_vehicle.cpp @@ -47,7 +47,13 @@ const Vehicle *v = ::GetVehicle(vehicle_id); switch (v->type) { - case VEH_ROAD: return v->u.road.cached_veh_length; + case VEH_ROAD: { + uint total_length = 0; + for (const Vehicle *u = v; u != NULL; u = u->Next()) { + total_length += u->u.road.cached_veh_length; + } + return total_length; + } case VEH_TRAIN: return v->u.rail.cached_total_length; default: return -1; } |