From 47cdbe4a20ef0ab9f2d7108d51b501305ac4d401 Mon Sep 17 00:00:00 2001 From: frosch Date: Sat, 24 Jan 2009 14:26:48 +0000 Subject: (svn r15255) -Fix (r15027): AIVehicle::GetLength() returned only the length of the first part of articulated road vehicles. --- src/ai/api/ai_vehicle.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/ai/api/ai_vehicle.cpp') 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; } -- cgit v1.2.3-54-g00ecf