diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 7e41da1aa9..a385451092 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -237,12 +237,23 @@ bool Vehicle::NeedsServicing() const * vehicles to go for service is lame. */ if (this->vehstatus & (VS_STOPPED | VS_CRASHED)) return false; + bool service_not_due; + /* Service intervals can be measured in different units, which we handle individually. */ + if (this->ServiceIntervalIsPercent()) { + /* Service interval is in percents. */ + service_not_due = (this->reliability >= this->GetEngine()->reliability * (100 - this->GetServiceInterval()) / 100); + } else if (EconTime::UsingWallclockUnits()) { + /* Service interval is in minutes. */ + service_not_due = (this->date_of_last_service + (this->GetServiceInterval() * EconTime::DAYS_IN_ECONOMY_WALLCLOCK_MONTH) >= EconTime::CurDate()); + } else { + /* Service interval is in days. */ + service_not_due = (this->date_of_last_service + this->GetServiceInterval() >= EconTime::CurDate()); + } + /* Are we ready for the next service cycle? */ bool needs_service = true; const Company *c = Company::Get(this->owner); - if ((this->ServiceIntervalIsPercent() ? - (this->reliability >= this->GetEngine()->reliability * (100 - this->service_interval) / 100) : - (this->date_of_last_service + this->service_interval >= EconTime::CurDate())) + if (service_not_due && !(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_SHIP && Ship::From(this)->critical_breakdown_count > 0)) {