diff options
author | frosch <frosch@openttd.org> | 2012-11-12 18:11:46 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2012-11-12 18:11:46 +0000 |
commit | 9f43908d08d45b49f89cea8b9c6272efde1917ba (patch) | |
tree | 59ef0e4e8b1965e2111fa452fee5e8ebf6e6bf13 /src | |
parent | 0566b29ab7af463d815b67b05cff638423b68b98 (diff) | |
download | openttd-9f43908d08d45b49f89cea8b9c6272efde1917ba.tar.xz |
(svn r24709) -Codechange: Simplify some code.
Diffstat (limited to 'src')
-rw-r--r-- | src/vehicle.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 043d1d33f..e130a42dc 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1228,11 +1228,11 @@ void AgeVehicle(Vehicle *v) /** * Calculates how full a vehicle is. - * @param v The Vehicle to check. For trains, use the first engine. + * @param front The front vehicle of the consist to check. * @param colour The string to show depending on if we are unloading or loading * @return A percentage of how full the Vehicle is. */ -uint8 CalcPercentVehicleFilled(const Vehicle *v, StringID *colour) +uint8 CalcPercentVehicleFilled(const Vehicle *front, StringID *colour) { int count = 0; int max = 0; @@ -1240,18 +1240,17 @@ uint8 CalcPercentVehicleFilled(const Vehicle *v, StringID *colour) int unloading = 0; bool loading = false; - const Vehicle *u = v; /* The station may be NULL when the (colour) string does not need to be set. */ - const Station *st = Station::GetIfValid(v->last_station_visited); + const Station *st = Station::GetIfValid(front->last_station_visited); assert(colour == NULL || st != NULL); /* Count up max and used */ - for (; v != NULL; v = v->Next()) { + for (const Vehicle *v = front; v != NULL; v = v->Next()) { count += v->cargo.Count(); max += v->cargo_cap; if (v->cargo_cap != 0 && colour != NULL) { unloading += HasBit(v->vehicle_flags, VF_CARGO_UNLOADING) ? 1 : 0; - loading |= !(u->current_order.GetLoadType() & OLFB_NO_LOAD) && st->goods[v->cargo_type].days_since_pickup != 255; + loading |= !(front->current_order.GetLoadType() & OLFB_NO_LOAD) && st->goods[v->cargo_type].days_since_pickup != 255; cars++; } } |