Fix #11345: Use correct default button value for vehicle service interval setting

This commit is contained in:
André Cheng
2024-03-25 20:38:44 +00:00
committed by rubidium42
parent a4071b78d7
commit fd80a1ec66
3 changed files with 32 additions and 0 deletions

View File

@@ -240,6 +240,32 @@ static void UpdateServiceInterval(VehicleType type, int32_t new_value)
SetWindowClassesDirty(WC_VEHICLE_DETAILS);
}
/**
* Checks if the service intervals in the settings are specified as percentages and corrects the default value accordingly.
* @param new_value Contains the service interval's default value in days, or 50 (default in percentage).
*/
static void GetDefaultServiceInterval(VehicleType type, int32_t &new_value)
{
VehicleDefaultSettings *vds;
if (_game_mode == GM_MENU || !Company::IsValidID(_current_company)) {
vds = &_settings_client.company.vehicle;
} else {
vds = &Company::Get(_current_company)->settings.vehicle;
}
if (vds->servint_ispercent) {
new_value = DEF_SERVINT_PERCENT;
} else if (TimerGameEconomy::UsingWallclockUnits(_game_mode == GM_MENU)) {
switch (type) {
case VEH_TRAIN: new_value = DEF_SERVINT_MINUTES_TRAINS; break;
case VEH_ROAD: new_value = DEF_SERVINT_MINUTES_ROADVEH; break;
case VEH_AIRCRAFT: new_value = DEF_SERVINT_MINUTES_AIRCRAFT; break;
case VEH_SHIP: new_value = DEF_SERVINT_MINUTES_SHIPS; break;
default: NOT_REACHED();
}
}
}
static void TrainAccelerationModelChanged(int32_t)
{
for (Train *t : Train::Iterate()) {