mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-17 21:25:40 +00:00
(svn r15255) -Fix (r15027): AIVehicle::GetLength() returned only the length of the first part of articulated road vehicles.
This commit is contained in:
parent
a92f472714
commit
47cdbe4a20
@ -47,7 +47,13 @@
|
|||||||
|
|
||||||
const Vehicle *v = ::GetVehicle(vehicle_id);
|
const Vehicle *v = ::GetVehicle(vehicle_id);
|
||||||
switch (v->type) {
|
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;
|
case VEH_TRAIN: return v->u.rail.cached_total_length;
|
||||||
default: return -1;
|
default: return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user