summaryrefslogtreecommitdiff
path: root/src/engine.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2008-12-16 18:09:40 +0000
committerfrosch <frosch@openttd.org>2008-12-16 18:09:40 +0000
commit1fa409177ca661f0355b8308ef5e6b4c77d77734 (patch)
tree110f295bd42bc4e855acaeeb1206cc332c71be78 /src/engine.cpp
parent94a5f66427ec48fae8d939254916c48fcdf5b1ce (diff)
downloadopenttd-1fa409177ca661f0355b8308ef5e6b4c77d77734.tar.xz
(svn r14680) -Feature(ette) [FS#2434]: Use property 4 (model life) also for wagons.
Setting property 4 to 0xFF will protect the vehicle (engine or wagon) from expireing. (Necessary since early introduction dates) Savegames will only be affected after 'resetengines'.
Diffstat (limited to 'src/engine.cpp')
-rw-r--r--src/engine.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index bef633d35..0335c8a87 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -72,6 +72,8 @@ Engine::Engine(VehicleType type, EngineID base)
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 @@ Engine::Engine(VehicleType type, EngineID base)
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 @@ static void CalcEngineReliability(Engine *e)
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 @@ static void CalcEngineReliability(Engine *e)
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 @@ void StartupEngines()
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;