Fix trains with non-front parts needing repair not being serviced
This commit is contained in:
@@ -191,6 +191,8 @@ struct Train FINAL : public GroundVehicle<Train, VEH_TRAIN> {
|
|||||||
int advisory_max_speed;
|
int advisory_max_speed;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool ConsistNeedsRepair() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MaxSpeedInfo GetCurrentMaxSpeedInfoInternal(bool update_state) const;
|
MaxSpeedInfo GetCurrentMaxSpeedInfoInternal(bool update_state) const;
|
||||||
|
|
||||||
|
@@ -1201,6 +1201,16 @@ void Train::UpdateAcceleration()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Train::ConsistNeedsRepair() const
|
||||||
|
{
|
||||||
|
if (!HasBit(this->flags, VRF_CONSIST_BREAKDOWN)) return false;
|
||||||
|
|
||||||
|
for (const Train *u = this; u != nullptr; u = u->Next()) {
|
||||||
|
if (HasBit(u->flags, VRF_NEED_REPAIR)) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the width of a train vehicle image in the GUI.
|
* Get the width of a train vehicle image in the GUI.
|
||||||
* @param offset Additional offset for positioning the sprite; set to nullptr if not needed
|
* @param offset Additional offset for positioning the sprite; set to nullptr if not needed
|
||||||
|
@@ -232,7 +232,7 @@ bool Vehicle::NeedsServicing() const
|
|||||||
if ((this->ServiceIntervalIsPercent() ?
|
if ((this->ServiceIntervalIsPercent() ?
|
||||||
(this->reliability >= this->GetEngine()->reliability * (100 - this->service_interval) / 100) :
|
(this->reliability >= this->GetEngine()->reliability * (100 - this->service_interval) / 100) :
|
||||||
(this->date_of_last_service + this->service_interval >= _date))
|
(this->date_of_last_service + this->service_interval >= _date))
|
||||||
&& !(this->type == VEH_TRAIN && HasBit(Train::From(this)->flags, VRF_NEED_REPAIR))
|
&& !(this->type == VEH_TRAIN && HasBit(Train::From(this)->flags, VRF_CONSIST_BREAKDOWN) && Train::From(this)->ConsistNeedsRepair())
|
||||||
&& !(this->type == VEH_ROAD && RoadVehicle::From(this)->critical_breakdown_count > 0)
|
&& !(this->type == VEH_ROAD && RoadVehicle::From(this)->critical_breakdown_count > 0)
|
||||||
&& !(this->type == VEH_SHIP && Ship::From(this)->critical_breakdown_count > 0)) {
|
&& !(this->type == VEH_SHIP && Ship::From(this)->critical_breakdown_count > 0)) {
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user