Add setting to disable vehicle expiry after a given year
This commit is contained in:
@@ -578,6 +578,18 @@ static bool IsWagon(EngineID index)
|
|||||||
return e->type == VEH_TRAIN && e->u.rail.railveh_type == RAILVEH_WAGON;
|
return e->type == VEH_TRAIN && e->u.rail.railveh_type == RAILVEH_WAGON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void RetireEngineIfPossible(Engine *e, int age_threshold)
|
||||||
|
{
|
||||||
|
if (_settings_game.vehicle.no_expire_vehicles_after > 0) {
|
||||||
|
YearMonthDay ymd;
|
||||||
|
ConvertDateToYMD(e->intro_date, &ymd);
|
||||||
|
if ((ymd.year * 12) + ymd.month + age_threshold >= _settings_game.vehicle.no_expire_vehicles_after * 12) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
e->company_avail = 0;
|
||||||
|
AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update #Engine::reliability and (if needed) update the engine GUIs.
|
* Update #Engine::reliability and (if needed) update the engine GUIs.
|
||||||
* @param e %Engine to update.
|
* @param e %Engine to update.
|
||||||
@@ -592,8 +604,7 @@ static void CalcEngineReliability(Engine *e)
|
|||||||
uint retire_early_max_age = max(0, e->duration_phase_1 + e->duration_phase_2 - retire_early * 12);
|
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) {
|
if (retire_early != 0 && age >= retire_early_max_age) {
|
||||||
/* Early retirement is enabled and we're past the date... */
|
/* Early retirement is enabled and we're past the date... */
|
||||||
e->company_avail = 0;
|
RetireEngineIfPossible(e, retire_early_max_age);
|
||||||
AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -608,12 +619,11 @@ static void CalcEngineReliability(Engine *e)
|
|||||||
uint max = e->reliability_max;
|
uint max = e->reliability_max;
|
||||||
e->reliability = (int)age * (int)(e->reliability_final - max) / e->duration_phase_3 + max;
|
e->reliability = (int)age * (int)(e->reliability_final - max) / e->duration_phase_3 + max;
|
||||||
} else {
|
} else {
|
||||||
|
e->reliability = e->reliability_final;
|
||||||
/* time's up for this engine.
|
/* time's up for this engine.
|
||||||
* We will now completely retire this design */
|
* We will now completely retire this design */
|
||||||
e->company_avail = 0;
|
|
||||||
e->reliability = e->reliability_final;
|
|
||||||
/* Kick this engine out of the lists */
|
/* Kick this engine out of the lists */
|
||||||
AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
|
RetireEngineIfPossible(e, e->duration_phase_1 + e->duration_phase_2 + e->duration_phase_3);
|
||||||
}
|
}
|
||||||
SetWindowClassesDirty(WC_BUILD_VEHICLE); // Update to show the new reliability
|
SetWindowClassesDirty(WC_BUILD_VEHICLE); // Update to show the new reliability
|
||||||
SetWindowClassesDirty(WC_REPLACE_VEHICLE);
|
SetWindowClassesDirty(WC_REPLACE_VEHICLE);
|
||||||
|
@@ -1326,6 +1326,10 @@ STR_CONFIG_SETTING_WARN_INCOME_LESS :Warn if a vehic
|
|||||||
STR_CONFIG_SETTING_WARN_INCOME_LESS_HELPTEXT :When enabled, a news message gets sent when a vehicle has not made any profit within a calendar year
|
STR_CONFIG_SETTING_WARN_INCOME_LESS_HELPTEXT :When enabled, a news message gets sent when a vehicle has not made any profit within a calendar year
|
||||||
STR_CONFIG_SETTING_NEVER_EXPIRE_VEHICLES :Vehicles never expire: {STRING2}
|
STR_CONFIG_SETTING_NEVER_EXPIRE_VEHICLES :Vehicles never expire: {STRING2}
|
||||||
STR_CONFIG_SETTING_NEVER_EXPIRE_VEHICLES_HELPTEXT :When enabled, all vehicle models remain available forever after their introduction
|
STR_CONFIG_SETTING_NEVER_EXPIRE_VEHICLES_HELPTEXT :When enabled, all vehicle models remain available forever after their introduction
|
||||||
|
STR_CONFIG_SETTING_NO_EXPIRE_VEHICLES_AFTER :No vehicles expire after: {STRING2}
|
||||||
|
STR_CONFIG_SETTING_NO_EXPIRE_VEHICLES_AFTER_HELPTEXT :Vehicles which would otherwise expire after this year remain available forever
|
||||||
|
STR_CONFIG_SETTING_NO_EXPIRE_VEHICLES_AFTER_VALUE :{NUM}
|
||||||
|
STR_CONFIG_SETTING_NO_EXPIRE_VEHICLES_AFTER_ZERO :Off
|
||||||
STR_CONFIG_SETTING_AUTORENEW_VEHICLE :Autorenew vehicle when it gets old: {STRING2}
|
STR_CONFIG_SETTING_AUTORENEW_VEHICLE :Autorenew vehicle when it gets old: {STRING2}
|
||||||
STR_CONFIG_SETTING_AUTORENEW_VEHICLE_HELPTEXT :When enabled, a vehicle nearing its end of life gets automatically replaced when the renew conditions are fulfilled
|
STR_CONFIG_SETTING_AUTORENEW_VEHICLE_HELPTEXT :When enabled, a vehicle nearing its end of life gets automatically replaced when the renew conditions are fulfilled
|
||||||
STR_CONFIG_SETTING_AUTORENEW_MONTHS :Autorenew when vehicle is {STRING2} maximum age
|
STR_CONFIG_SETTING_AUTORENEW_MONTHS :Autorenew when vehicle is {STRING2} maximum age
|
||||||
|
@@ -1848,6 +1848,7 @@ static SettingsContainer &GetSettingsTree()
|
|||||||
limitations->Add(new SettingEntry("construction.chunnel"));
|
limitations->Add(new SettingEntry("construction.chunnel"));
|
||||||
limitations->Add(new SettingEntry("station.never_expire_airports"));
|
limitations->Add(new SettingEntry("station.never_expire_airports"));
|
||||||
limitations->Add(new SettingEntry("vehicle.never_expire_vehicles"));
|
limitations->Add(new SettingEntry("vehicle.never_expire_vehicles"));
|
||||||
|
limitations->Add(new SettingEntry("vehicle.no_expire_vehicles_after"));
|
||||||
limitations->Add(new SettingEntry("vehicle.max_trains"));
|
limitations->Add(new SettingEntry("vehicle.max_trains"));
|
||||||
limitations->Add(new SettingEntry("vehicle.max_roadveh"));
|
limitations->Add(new SettingEntry("vehicle.max_roadveh"));
|
||||||
limitations->Add(new SettingEntry("vehicle.max_aircraft"));
|
limitations->Add(new SettingEntry("vehicle.max_aircraft"));
|
||||||
|
@@ -540,6 +540,7 @@ struct VehicleSettings {
|
|||||||
uint8 freight_trains; ///< value to multiply the weight of cargo by
|
uint8 freight_trains; ///< value to multiply the weight of cargo by
|
||||||
bool dynamic_engines; ///< enable dynamic allocation of engine data
|
bool dynamic_engines; ///< enable dynamic allocation of engine data
|
||||||
bool never_expire_vehicles; ///< never expire vehicles
|
bool never_expire_vehicles; ///< never expire vehicles
|
||||||
|
Year no_expire_vehicles_after; ///< do not expire vehicles ater this year
|
||||||
byte extend_vehicle_life; ///< extend vehicle life by this many years
|
byte extend_vehicle_life; ///< extend vehicle life by this many years
|
||||||
byte road_side; ///< the side of the road vehicles drive on
|
byte road_side; ///< the side of the road vehicles drive on
|
||||||
uint8 plane_crashes; ///< number of plane crashes, 0 = none, 1 = reduced, 2 = normal
|
uint8 plane_crashes; ///< number of plane crashes, 0 = none, 1 = reduced, 2 = normal
|
||||||
|
@@ -1379,6 +1379,21 @@ def = false
|
|||||||
str = STR_CONFIG_SETTING_NEVER_EXPIRE_VEHICLES
|
str = STR_CONFIG_SETTING_NEVER_EXPIRE_VEHICLES
|
||||||
strhelp = STR_CONFIG_SETTING_NEVER_EXPIRE_VEHICLES_HELPTEXT
|
strhelp = STR_CONFIG_SETTING_NEVER_EXPIRE_VEHICLES_HELPTEXT
|
||||||
|
|
||||||
|
[SDT_VAR]
|
||||||
|
base = GameSettings
|
||||||
|
var = vehicle.no_expire_vehicles_after
|
||||||
|
type = SLE_INT32
|
||||||
|
guiflags = SGF_NO_NETWORK | SGF_0ISDISABLED
|
||||||
|
def = 0
|
||||||
|
min = MIN_YEAR
|
||||||
|
max = MAX_YEAR
|
||||||
|
interval = 1
|
||||||
|
str = STR_CONFIG_SETTING_NO_EXPIRE_VEHICLES_AFTER
|
||||||
|
strhelp = STR_CONFIG_SETTING_NO_EXPIRE_VEHICLES_AFTER_HELPTEXT
|
||||||
|
strval = STR_CONFIG_SETTING_NO_EXPIRE_VEHICLES_AFTER_VALUE
|
||||||
|
cat = SC_EXPERT
|
||||||
|
patxname = ""vehicle.no_expire_vehicles_after""
|
||||||
|
|
||||||
;; vehicle.exact_intro_date
|
;; vehicle.exact_intro_date
|
||||||
[SDT_NULL]
|
[SDT_NULL]
|
||||||
length = 1
|
length = 1
|
||||||
|
Reference in New Issue
Block a user