From 96b98b392ad89e3d1718a7a46a3e41d4eeab61d3 Mon Sep 17 00:00:00 2001 From: terkhen Date: Tue, 14 Dec 2010 21:24:51 +0000 Subject: (svn r21515) -Codechange: Use cached_total_length where appropiate. --- src/ai/api/ai_vehicle.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src/ai') diff --git a/src/ai/api/ai_vehicle.cpp b/src/ai/api/ai_vehicle.cpp index d7d066c7b..2aad40f60 100644 --- a/src/ai/api/ai_vehicle.cpp +++ b/src/ai/api/ai_vehicle.cpp @@ -49,13 +49,7 @@ const Vehicle *v = ::Vehicle::Get(vehicle_id); switch (v->type) { - case VEH_ROAD: { - uint total_length = 0; - for (const Vehicle *u = v; u != NULL; u = u->Next()) { - total_length += ::RoadVehicle::From(u)->rcache.cached_veh_length; - } - return total_length; - } + case VEH_ROAD: return ::RoadVehicle::From(v)->rcache.cached_total_length; case VEH_TRAIN: return ::Train::From(v)->tcache.cached_total_length; default: return -1; } -- cgit v1.2.3-70-g09d2