mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-04 06:00:15 +00:00
(svn r21515) -Codechange: Use cached_total_length where appropiate.
This commit is contained in:
parent
91df711d61
commit
96b98b392a
@ -49,13 +49,7 @@
|
|||||||
|
|
||||||
const Vehicle *v = ::Vehicle::Get(vehicle_id);
|
const Vehicle *v = ::Vehicle::Get(vehicle_id);
|
||||||
switch (v->type) {
|
switch (v->type) {
|
||||||
case VEH_ROAD: {
|
case VEH_ROAD: return ::RoadVehicle::From(v)->rcache.cached_total_length;
|
||||||
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_TRAIN: return ::Train::From(v)->tcache.cached_total_length;
|
case VEH_TRAIN: return ::Train::From(v)->tcache.cached_total_length;
|
||||||
default: return -1;
|
default: return -1;
|
||||||
}
|
}
|
||||||
|
@ -854,9 +854,7 @@ static int CDECL VehicleLengthSorter(const Vehicle * const *a, const Vehicle * c
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VEH_ROAD: {
|
case VEH_ROAD: {
|
||||||
const RoadVehicle *u;
|
r = RoadVehicle::From(*a)->rcache.cached_total_length - RoadVehicle::From(*b)->rcache.cached_total_length;
|
||||||
for (u = RoadVehicle::From(*a); u != NULL; u = u->Next()) r += u->rcache.cached_veh_length;
|
|
||||||
for (u = RoadVehicle::From(*b); u != NULL; u = u->Next()) r -= u->rcache.cached_veh_length;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user