src/engine.cpp
changeset 10427 cf023efb9a97
parent 10208 72c00af5c95d
child 10430 3125f2adebc5
--- a/src/engine.cpp	Tue Dec 16 17:58:27 2008 +0000
+++ b/src/engine.cpp	Tue Dec 16 18:09:40 2008 +0000
@@ -72,6 +72,8 @@
 	if (base >= _engine_counts[type]) {
 		/* Mark engine as valid anyway */
 		this->info.climates = 0x80;
+		/* Set model life to maximum to make wagons available */
+		this->info.base_life = 0xFF;
 		return;
 	}
 
@@ -86,6 +88,10 @@
 			this->u.rail = _orig_rail_vehicle_info[base];
 			this->image_index = this->u.rail.image_index;
 			this->info.string_id = STR_8000_KIRBY_PAUL_TANK_STEAM + base;
+
+			/* Set the default model life of original wagons to "infinite" */
+			if (this->u.rail.railveh_type == RAILVEH_WAGON) this->info.base_life = 0xFF;
+
 			break;
 
 		case VEH_ROAD:
@@ -195,7 +201,7 @@
 	uint age = e->age;
 
 	/* Check for early retirement */
-	if (e->company_avail != 0 && !_settings_game.vehicle.never_expire_vehicles) {
+	if (e->company_avail != 0 && !_settings_game.vehicle.never_expire_vehicles && e->info.base_life != 0xFF) {
 		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) {
@@ -208,7 +214,7 @@
 	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 || _settings_game.vehicle.never_expire_vehicles) {
+	} else if ((age -= e->duration_phase_1) < e->duration_phase_2 || _settings_game.vehicle.never_expire_vehicles || e->info.base_life == 0xFF) {
 		/* 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;
@@ -264,11 +270,7 @@
 
 		e->reliability_spd_dec = ei->decay_speed << 2;
 
-		if (IsWagon(e->index)) {
-			e->age = 0xFFFF;
-		} else {
-			CalcEngineReliability(e);
-		}
+		CalcEngineReliability(e);
 
 		e->lifelength = ei->lifelength + _settings_game.vehicle.extend_vehicle_life;