From 80bcbce62bf0510a7fd6c21e0ea30068907459e5 Mon Sep 17 00:00:00 2001 From: truelight Date: Fri, 22 Jun 2007 18:28:44 +0000 Subject: (svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading --- src/vehicle.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/vehicle.cpp') 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; -- cgit v1.2.3-70-g09d2