summaryrefslogtreecommitdiff
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
commita87af0d7e57af8ec5bb04d7c6aa449d9c27ba32c (patch)
tree110f295bd42bc4e855acaeeb1206cc332c71be78
parent1599ade7caf73fbb49409644357062ef95fc04ad (diff)
downloadopenttd-a87af0d7e57af8ec5bb04d7c6aa449d9c27ba32c.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'.
-rw-r--r--src/engine.cpp16
-rw-r--r--src/oldloader.cpp8
2 files changed, 10 insertions, 14 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;
diff --git a/src/oldloader.cpp b/src/oldloader.cpp
index 49482bb6d..67fa7742d 100644
--- a/src/oldloader.cpp
+++ b/src/oldloader.cpp
@@ -1347,13 +1347,7 @@ static const OldChunks engine_chunk[] = {
static bool LoadOldEngine(LoadgameState *ls, int num)
{
Engine *e = GetTempDataEngine(num);
- if (!LoadChunk(ls, e, engine_chunk)) return false;
-
- /* Make sure wagons are marked as do-not-age */
- if ((num >= 27 && num < 54) || (num >= 57 && num < 84) || (num >= 89 && num < 116))
- e->age = 0xFFFF;
-
- return true;
+ return LoadChunk(ls, e, engine_chunk);
}
static bool LoadOldEngineName(LoadgameState *ls, int num)