summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-08-22 21:33:58 +0000
committerfrosch <frosch@openttd.org>2011-08-22 21:33:58 +0000
commit28117b3eb09f71288f4aef2b72c63e4203b4bb71 (patch)
tree506335068e16991ce8e8c62a0bf8c6cd99d514db
parent3957f428b15cb3bcdcbc451be423ef391a98d81a (diff)
downloadopenttd-28117b3eb09f71288f4aef2b72c63e4203b4bb71.tar.xz
(svn r22816) -Feature(ette): [NewGRF] Also age wagons and articulated parts.
-rw-r--r--src/roadveh_cmd.cpp3
-rw-r--r--src/train_cmd.cpp6
-rw-r--r--src/vehicle.cpp2
3 files changed, 6 insertions, 5 deletions
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 672c6e426..15c2bf49a 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -1591,12 +1591,13 @@ static void CheckIfRoadVehNeedsService(RoadVehicle *v)
void RoadVehicle::OnNewDay()
{
+ AgeVehicle(this);
+
if (!this->IsFrontEngine()) return;
if ((++this->day_counter & 7) == 0) DecreaseVehicleValue(this);
if (this->blocked_ctr == 0) CheckVehicleBreakdown(this);
- AgeVehicle(this);
CheckIfRoadVehNeedsService(this);
CheckOrders(this);
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 149aa25da..4bbe26064 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -3778,11 +3778,12 @@ static void CheckIfTrainNeedsService(Train *v)
void Train::OnNewDay()
{
+ AgeVehicle(this);
+
if ((++this->day_counter & 7) == 0) DecreaseVehicleValue(this);
if (this->IsFrontEngine()) {
CheckVehicleBreakdown(this);
- AgeVehicle(this);
CheckIfTrainNeedsService(this);
@@ -3806,9 +3807,6 @@ void Train::OnNewDay()
SetWindowDirty(WC_VEHICLE_DETAILS, this->index);
SetWindowClassesDirty(WC_TRAINS_LIST);
}
- } else if (this->IsEngine()) {
- /* Also age engines that aren't front engines */
- AgeVehicle(this);
}
}
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index ab1b4df2f..4aa24f546 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -1138,6 +1138,8 @@ void AgeVehicle(Vehicle *v)
{
if (v->age < MAX_DAY) v->age++;
+ if (!v->IsPrimaryVehicle() && (v->type != VEH_TRAIN || !Train::From(v)->IsEngine())) return;
+
int age = v->age - v->max_age;
if (age == DAYS_IN_LEAP_YEAR * 0 || age == DAYS_IN_LEAP_YEAR * 1 ||
age == DAYS_IN_LEAP_YEAR * 2 || age == DAYS_IN_LEAP_YEAR * 3 || age == DAYS_IN_LEAP_YEAR * 4) {