Changeset - r17997:5866700f3901
[Not reviewed]
master
0 3 0
frosch - 13 years ago 2011-08-22 21:33:58
frosch@openttd.org
(svn r22816) -Feature(ette): [NewGRF] Also age wagons and articulated parts.
3 files changed with 6 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/roadveh_cmd.cpp
Show inline comments
 
@@ -1588,18 +1588,19 @@ static void CheckIfRoadVehNeedsService(R
 
	v->dest_tile = rfdd.tile;
 
	SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
}
 

	
 
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);
 

	
 
	if (this->running_ticks == 0) return;
 

	
src/train_cmd.cpp
Show inline comments
 
@@ -3775,17 +3775,18 @@ static void CheckIfTrainNeedsService(Tra
 
	v->dest_tile = tfdd.tile;
 
	SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
}
 

	
 
void Train::OnNewDay()
 
{
 
	AgeVehicle(this);
 

	
 
	if ((++this->day_counter & 7) == 0) DecreaseVehicleValue(this);
 

	
 
	if (this->IsFrontEngine()) {
 
		CheckVehicleBreakdown(this);
 
		AgeVehicle(this);
 

	
 
		CheckIfTrainNeedsService(this);
 

	
 
		CheckOrders(this);
 

	
 
		/* update destination */
 
@@ -3803,15 +3804,12 @@ void Train::OnNewDay()
 

	
 
			SubtractMoneyFromCompanyFract(this->owner, cost);
 

	
 
			SetWindowDirty(WC_VEHICLE_DETAILS, this->index);
 
			SetWindowClassesDirty(WC_TRAINS_LIST);
 
		}
 
	} else if (this->IsEngine()) {
 
		/* Also age engines that aren't front engines */
 
		AgeVehicle(this);
 
	}
 
}
 

	
 
Trackdir Train::GetVehicleTrackdir() const
 
{
 
	if (this->vehstatus & VS_CRASHED) return INVALID_TRACKDIR;
src/vehicle.cpp
Show inline comments
 
@@ -1135,12 +1135,14 @@ bool Vehicle::HandleBreakdown()
 
 * @param v Vehicle to update.
 
 */
 
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) {
 
		v->reliability_spd_dec <<= 1;
 
	}
 

	
0 comments (0 inline, 0 general)