diff options
author | truelight <truelight@openttd.org> | 2007-06-22 18:28:44 +0000 |
---|---|---|
committer | truelight <truelight@openttd.org> | 2007-06-22 18:28:44 +0000 |
commit | f80fa33cc5f45bc74c10324fdec598c9486cf44b (patch) | |
tree | 20623f97dba17284a729f18f337f9277809b8527 /src/vehicle.cpp | |
parent | 74b867db72f3534d271cdf43747f80c99e0ae2df (diff) | |
download | openttd-f80fa33cc5f45bc74c10324fdec598c9486cf44b.tar.xz |
(svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
Diffstat (limited to 'src/vehicle.cpp')
-rw-r--r-- | src/vehicle.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp index f04a1a3ea..b4c3daf92 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -2271,19 +2271,32 @@ bool IsVehicleInDepot(const Vehicle *v) /** * Calculates how full a vehicle is. * @param v The Vehicle to check. For trains, use the first engine. + * @param color The string to show depending on if we are unloading or loading * @return A percentage of how full the Vehicle is. */ -uint8 CalcPercentVehicleFilled(Vehicle *v) +uint8 CalcPercentVehicleFilled(Vehicle *v, StringID *color) { int count = 0; int max = 0; + int cars = 0; + int unloading = 0; + + assert(color != NULL); /* Count up max and used */ for (; v != NULL; v = v->next) { count += v->cargo.Count(); max += v->cargo_cap; + if (v->cargo_cap != 0) { + unloading += HASBIT(v->vehicle_flags, VF_CARGO_UNLOADING) ? 1 : 0; + cars++; + } } + if (unloading == 0) *color = STR_PERCENT_UP; + else if (cars == unloading) *color = STR_PERCENT_DOWN; + else *color = STR_PERCENT_UP_DOWN; + /* Train without capacity */ if (max == 0) return 100; |