Codechange: Make GetDefaultValueCallback() more similar to other setting override callbacks (#13259)

This commit is contained in:
Loïc Guilloux
2025-01-04 00:17:47 +01:00
committed by GitHub
parent d38ecd6525
commit a52923b3b9
4 changed files with 16 additions and 31 deletions

View File

@@ -265,9 +265,8 @@ static void UpdateServiceInterval(VehicleType type, int32_t new_value)
/**
* 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 int32_t GetDefaultServiceInterval(VehicleType type)
static int32_t GetDefaultServiceInterval(const IntSettingDesc &sd, VehicleType type)
{
VehicleDefaultSettings *vds;
if (_game_mode == GM_MENU || !Company::IsValidID(_current_company)) {
@@ -276,28 +275,19 @@ static int32_t GetDefaultServiceInterval(VehicleType type)
vds = &Company::Get(_current_company)->settings.vehicle;
}
int32_t new_value;
if (vds->servint_ispercent) {
new_value = DEF_SERVINT_PERCENT;
} else if (TimerGameEconomy::UsingWallclockUnits(_game_mode == GM_MENU)) {
if (vds->servint_ispercent) return DEF_SERVINT_PERCENT;
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();
}
} else {
switch (type) {
case VEH_TRAIN: new_value = DEF_SERVINT_DAYS_TRAINS; break;
case VEH_ROAD: new_value = DEF_SERVINT_DAYS_ROADVEH; break;
case VEH_AIRCRAFT: new_value = DEF_SERVINT_DAYS_AIRCRAFT; break;
case VEH_SHIP: new_value = DEF_SERVINT_DAYS_SHIPS; break;
case VEH_TRAIN: return DEF_SERVINT_MINUTES_TRAINS;
case VEH_ROAD: return DEF_SERVINT_MINUTES_ROADVEH;
case VEH_AIRCRAFT: return DEF_SERVINT_MINUTES_AIRCRAFT;
case VEH_SHIP: return DEF_SERVINT_MINUTES_SHIPS;
default: NOT_REACHED();
}
}
return new_value;
return sd.def;
}
static void TrainAccelerationModelChanged(int32_t)