(svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading

This commit is contained in:
truelight
2007-06-22 18:28:44 +00:00
parent 74b867db72
commit f80fa33cc5
6 changed files with 35 additions and 13 deletions

View File

@@ -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;