File diff r9353:bc33456736f9 → r9354:358e967da2ca
src/engine.cpp
Show inline comments
 
@@ -214,26 +214,26 @@ void LoadCustomEngineNames()
 

	
 
static void CalcEngineReliability(Engine *e)
 
{
 
	uint age = e->age;
 

	
 
	/* Check for early retirement */
 
	if (e->player_avail != 0 && !_patches.never_expire_vehicles) {
 
	if (e->player_avail != 0 && !_settings.vehicle.never_expire_vehicles) {
 
		int retire_early = e->info.retire_early;
 
		uint retire_early_max_age = max(0, e->duration_phase_1 + e->duration_phase_2 - retire_early * 12);
 
		if (retire_early != 0 && age >= retire_early_max_age) {
 
			/* Early retirement is enabled and we're past the date... */
 
			e->player_avail = 0;
 
			AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
 
		}
 
	}
 

	
 
	if (age < e->duration_phase_1) {
 
		uint start = e->reliability_start;
 
		e->reliability = age * (e->reliability_max - start) / e->duration_phase_1 + start;
 
	} else if ((age -= e->duration_phase_1) < e->duration_phase_2 || _patches.never_expire_vehicles) {
 
	} else if ((age -= e->duration_phase_1) < e->duration_phase_2 || _settings.vehicle.never_expire_vehicles) {
 
		/* We are at the peak of this engines life. It will have max reliability.
 
		 * This is also true if the engines never expire. They will not go bad over time */
 
		e->reliability = e->reliability_max;
 
	} else if ((age -= e->duration_phase_2) < e->duration_phase_3) {
 
		uint max = e->reliability_max;
 
		e->reliability = (int)age * (int)(e->reliability_final - max) / e->duration_phase_3 + max;
 
@@ -290,13 +290,13 @@ void StartupEngines()
 
		if (ei->unk2 & 0x80) {
 
			e->age = 0xFFFF;
 
		} else {
 
			CalcEngineReliability(e);
 
		}
 

	
 
		e->lifelength = ei->lifelength + _patches.extend_vehicle_life;
 
		e->lifelength = ei->lifelength + _settings.vehicle.extend_vehicle_life;
 

	
 
		/* prevent certain engines from ever appearing. */
 
		if (!HasBit(ei->climates, _opt.landscape)) {
 
			e->flags |= ENGINE_AVAILABLE;
 
			e->player_avail = 0;
 
		}