summaryrefslogtreecommitdiff
path: root/src/vehicle.cpp
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2011-08-03 20:55:08 +0000
committermichi_cc <michi_cc@openttd.org>2011-08-03 20:55:08 +0000
commit08b7981f37431f57ca2fa8dd25db4088c7c69d4e (patch)
treed55fa560c79768b03077cb544552875e8064d17e /src/vehicle.cpp
parent442b92ff33c31317f77786f23539c2566f8252f3 (diff)
downloadopenttd-08b7981f37431f57ca2fa8dd25db4088c7c69d4e.tar.xz
(svn r22713) -Feature: [NewGRF] Per vehicle custom cargo ageing period.
Diffstat (limited to 'src/vehicle.cpp')
-rw-r--r--src/vehicle.cpp14
1 files changed, 8 insertions, 6 deletions
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;