Add "very reduced" mode to the vehicle breakdowns setting

This commit is contained in:
Jonathan G Rennison
2023-03-21 17:30:16 +00:00
parent a6babb23d3
commit 664c486fea
3 changed files with 17 additions and 7 deletions

View File

@@ -2026,3 +2026,5 @@ STR_ERROR_TUNNEL_DISALLOWED_ROAD :{WHITE}Tunnels
STR_REFIT_SHIP_PART_DROPDOWN_TOOLTIP :{BLACK}Select which part of this ship to refit STR_REFIT_SHIP_PART_DROPDOWN_TOOLTIP :{BLACK}Select which part of this ship to refit
STR_REFIT_WHOLE_SHIP :Whole ship STR_REFIT_WHOLE_SHIP :Whole ship
STR_REFIT_SHIP_PART :Part {NUM} STR_REFIT_SHIP_PART :Part {NUM}
STR_VERY_REDUCED :Very reduced

View File

@@ -164,6 +164,14 @@ static const SettingDescEnumEntry _viewport_map_modes[] = {
{ 0, STR_NULL } { 0, STR_NULL }
}; };
static const SettingDescEnumEntry _vehicle_breakdown_modes[] = {
{ 0, STR_DISASTER_NONE },
{ 64, STR_VERY_REDUCED },
{ 1, STR_DISASTER_REDUCED },
{ 2, STR_DISASTER_NORMAL },
{ 0, STR_NULL }
};
/* Some settings do not need to be synchronised when playing in multiplayer. /* Some settings do not need to be synchronised when playing in multiplayer.
* These include for example the GUI settings and will not be saved with the * These include for example the GUI settings and will not be saved with the
* savegame. * savegame.
@@ -365,18 +373,14 @@ def = 0
min = 0 min = 0
max = 2 max = 2
[SDT_VAR] [SDT_ENUM]
var = difficulty.vehicle_breakdowns var = difficulty.vehicle_breakdowns
type = SLE_UINT8 type = SLE_UINT8
from = SLV_97 from = SLV_97
flags = SF_GUI_DROPDOWN
def = 1 def = 1
min = 0 enumlist = _vehicle_breakdown_modes
max = 2
interval = 1
str = STR_CONFIG_SETTING_VEHICLE_BREAKDOWNS str = STR_CONFIG_SETTING_VEHICLE_BREAKDOWNS
strhelp = STR_CONFIG_SETTING_VEHICLE_BREAKDOWNS_HELPTEXT strhelp = STR_CONFIG_SETTING_VEHICLE_BREAKDOWNS_HELPTEXT
strval = STR_DISASTER_NONE
cat = SC_BASIC cat = SC_BASIC
[SDT_VAR] [SDT_VAR]

View File

@@ -2175,6 +2175,9 @@ void CheckVehicleBreakdown(Vehicle *v)
} }
/** /**
* Chance is (1 - reliability) * breakdown_setting * breakdown_chance / 10. * Chance is (1 - reliability) * breakdown_setting * breakdown_chance / 10.
* breakdown_setting is scaled by 2 to support a value of 1/2 (setting value 64).
* Chance is (1 - reliability) * breakdown_scaling_x2 * breakdown_chance / 20.
*
* At 90% reliabilty, normal setting (2) and average breakdown_chance (128), * At 90% reliabilty, normal setting (2) and average breakdown_chance (128),
* a vehicle will break down (on average) every 100 days. * a vehicle will break down (on average) every 100 days.
* This *should* mean that vehicles break down about as often as (or a little less than) they used to. * This *should* mean that vehicles break down about as often as (or a little less than) they used to.
@@ -2182,7 +2185,8 @@ void CheckVehicleBreakdown(Vehicle *v)
* their impact will be significantly less. * their impact will be significantly less.
*/ */
uint32 r1 = Random(); uint32 r1 = Random();
if ((uint32) (0xffff - v->reliability) * _settings_game.difficulty.vehicle_breakdowns * chance > GB(r1, 0, 24) * 10) { uint32 breakdown_scaling_x2 = (_settings_game.difficulty.vehicle_breakdowns == 64) ? 1 : (_settings_game.difficulty.vehicle_breakdowns * 2);
if ((uint32) (0xffff - v->reliability) * breakdown_scaling_x2 * chance > GB(r1, 0, 24) * 10 * 2) {
uint32 r2 = Random(); uint32 r2 = Random();
v->breakdown_ctr = GB(r1, 24, 6) + 0xF; v->breakdown_ctr = GB(r1, 24, 6) + 0xF;
if (v->type == VEH_TRAIN) SetBit(Train::From(v)->First()->flags, VRF_CONSIST_BREAKDOWN); if (v->type == VEH_TRAIN) SetBit(Train::From(v)->First()->flags, VRF_CONSIST_BREAKDOWN);