|
@@ -2154,49 +2154,49 @@ CommandCost SendAllVehiclesToDepot(Vehic
|
|
|
* 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, StringID *color)
|
|
|
{
|
|
|
int count = 0;
|
|
|
int max = 0;
|
|
|
int cars = 0;
|
|
|
int unloading = 0;
|
|
|
bool loading = false;
|
|
|
|
|
|
assert(color != NULL);
|
|
|
|
|
|
const Vehicle *u = v;
|
|
|
const Station *st = GetStation(v->last_station_visited);
|
|
|
|
|
|
/* 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;
|
|
|
loading |= !HasBit(u->current_order.GetUnloadType(), OF_UNLOAD) && st->goods[v->cargo_type].days_since_pickup != 255;
|
|
|
loading |= !(u->current_order.GetUnloadType() & OUFB_UNLOAD) && st->goods[v->cargo_type].days_since_pickup != 255;
|
|
|
cars++;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (unloading == 0 && loading) *color = STR_PERCENT_UP;
|
|
|
else if (cars == unloading || !loading) *color = STR_PERCENT_DOWN;
|
|
|
else *color = STR_PERCENT_UP_DOWN;
|
|
|
|
|
|
/* Train without capacity */
|
|
|
if (max == 0) return 100;
|
|
|
|
|
|
/* Return the percentage */
|
|
|
return (count * 100) / max;
|
|
|
}
|
|
|
|
|
|
void VehicleEnterDepot(Vehicle *v)
|
|
|
{
|
|
|
switch (v->type) {
|
|
|
case VEH_TRAIN:
|
|
|
InvalidateWindowClasses(WC_TRAINS_LIST);
|
|
|
if (!IsFrontEngine(v)) v = v->First();
|
|
|
UpdateSignalsOnSegment(v->tile, INVALID_DIAGDIR, v->owner);
|
|
|
v->load_unload_time_rem = 0;
|
|
|
/* Reset reversed flag */
|