File diff r19232:d9c6c042a8d5 → r19233:bd16563de8bd
src/vehicle.cpp
Show inline comments
 
@@ -67,9 +67,10 @@ INSTANTIATE_POOL_METHODS(Vehicle)
 
/**
 
 * 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
 
 */
 
bool Vehicle::NeedsAutorenewing(const Company *c) const
 
bool Vehicle::NeedsAutorenewing(const Company *c, bool use_renew_setting) const
 
{
 
	/* We can always generate the Company pointer when we have the vehicle.
 
	 * However this takes time and since the Company pointer is often present
 
@@ -77,7 +78,7 @@ bool Vehicle::NeedsAutorenewing(const Co
 
	 * argument rather than finding it again. */
 
	assert(c == Company::Get(this->owner));
 

	
 
	if (!c->settings.engine_renew) return false;
 
	if (use_renew_setting && !c->settings.engine_renew) return false;
 
	if (this->age - this->max_age < (c->settings.engine_renew_months * 30)) return false;
 

	
 
	/* Only engines need renewing */
 
@@ -131,10 +132,13 @@ bool Vehicle::NeedsServicing() const
 
	if (needed_money > c->money) return false;
 

	
 
	for (const Vehicle *v = this; v != NULL; v = (v->type == VEH_TRAIN) ? Train::From(v)->GetNextUnit() : NULL) {
 
		EngineID new_engine = EngineReplacementForCompany(c, v->engine_type, v->group_id);
 
		bool replace_when_old = false;
 
		EngineID new_engine = EngineReplacementForCompany(c, v->engine_type, v->group_id, &replace_when_old);
 

	
 
		/* Check engine availability */
 
		if (new_engine == INVALID_ENGINE || !HasBit(Engine::Get(new_engine)->company_avail, v->owner)) continue;
 
		/* Is the vehicle old if we are not always replacing? */
 
		if (replace_when_old && !v->NeedsAutorenewing(c, false)) continue;
 

	
 
		/* Check refittability */
 
		uint32 available_cargo_types, union_mask;