(svn r22713) -Feature: [NewGRF] Per vehicle custom cargo ageing period.

This commit is contained in:
michi_cc
2011-08-03 20:55:08 +00:00
parent 442b92ff33
commit 08b7981f37
17 changed files with 74 additions and 16 deletions

View File

@@ -60,7 +60,6 @@
VehicleID _new_vehicle_id;
uint16 _returned_refit_capacity; ///< Stores the capacity after a refit operation.
uint16 _returned_mail_refit_capacity; ///< Stores the mail capacity after a refit operation (Aircraft only).
byte _age_cargo_skip_counter; ///< Skip aging of cargo?
/** The pool with all our precious vehicles. */
@@ -245,6 +244,7 @@ Vehicle::Vehicle(VehicleType type)
this->fill_percent_te_id = INVALID_TE_ID;
this->first = this;
this->colourmap = PAL_NONE;
this->cargo_age_counter = 1;
}
/**
@@ -586,8 +586,6 @@ static AutoreplaceMap _vehicles_to_autoreplace;
void InitializeVehicles()
{
_age_cargo_skip_counter = 1;
_vehicles_to_autoreplace.Reset();
ResetVehiclePosHash();
}
@@ -801,8 +799,6 @@ void CallVehicleTicks()
{
_vehicles_to_autoreplace.Clear();
_age_cargo_skip_counter = (_age_cargo_skip_counter == 0) ? CARGO_AGING_TICKS - 1 : (_age_cargo_skip_counter - 1);
RunVehicleDayProc();
Station *st;
@@ -825,7 +821,13 @@ void CallVehicleTicks()
case VEH_ROAD:
case VEH_AIRCRAFT:
case VEH_SHIP:
if (_age_cargo_skip_counter == 0) v->cargo.AgeCargo();
if (v->vcache.cached_cargo_age_period != 0) {
v->cargo_age_counter = min(v->cargo_age_counter, v->vcache.cached_cargo_age_period);
if (--v->cargo_age_counter == 0) {
v->cargo.AgeCargo();
v->cargo_age_counter = v->vcache.cached_cargo_age_period;
}
}
if (v->type == VEH_TRAIN && Train::From(v)->IsWagon()) continue;
if (v->type == VEH_AIRCRAFT && v->subtype != AIR_HELICOPTER) continue;