* Function to tell if a vehicle needs to be autorenewed * @param *c The vehicle owner * @param use_renew_setting Should the company renew setting be considered? * @return true if the vehicle is old enough for replacement */
| 154 | * @return true if the vehicle is old enough for replacement |
| 155 | */ |
| 156 | bool Vehicle::NeedsAutorenewing(const Company *c, bool use_renew_setting) const |
| 157 | { |
| 158 | /* We can always generate the Company pointer when we have the vehicle. |
| 159 | * However this takes time and since the Company pointer is often present |
| 160 | * when this function is called then it's faster to pass the pointer as an |
| 161 | * argument rather than finding it again. */ |
| 162 | assert(c == Company::Get(this->owner)); |
| 163 | |
| 164 | if (use_renew_setting && !c->settings.engine_renew) return false; |
| 165 | if (this->age - this->max_age < (c->settings.engine_renew_months * 30)) return false; |
| 166 | |
| 167 | /* Only engines need renewing */ |
| 168 | if (this->type == VEH_TRAIN && !Train::From(this)->IsEngine()) return false; |
| 169 | |
| 170 | return true; |
| 171 | } |
| 172 | |
| 173 | /** |
| 174 | * Service a vehicle and all subsequent vehicles in the consist |
no test coverage detected