From 08b7981f37431f57ca2fa8dd25db4088c7c69d4e Mon Sep 17 00:00:00 2001 From: michi_cc Date: Wed, 3 Aug 2011 20:55:08 +0000 Subject: (svn r22713) -Feature: [NewGRF] Per vehicle custom cargo ageing period. --- src/vehicle.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/vehicle.cpp') diff --git a/src/vehicle.cpp b/src/vehicle.cpp index ccbb96068..ab1b4df2f 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -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; -- cgit v1.2.3-54-g00ecf