Fix: Restore ability to disable service interval

This commit is contained in:
glx22
2025-01-04 21:17:54 +01:00
committed by Loïc Guilloux
parent 7493b2d0c1
commit b88df0b2d7
2 changed files with 24 additions and 1 deletions

View File

@@ -247,7 +247,7 @@ static bool CanUpdateServiceInterval(VehicleType, int32_t &new_value)
/* Test if the interval is valid */
int32_t interval = GetServiceIntervalClamped(new_value, vds->servint_ispercent);
return interval == new_value;
return new_value == 0 || interval == new_value;
}
static void UpdateServiceInterval(VehicleType type, int32_t new_value)
@@ -290,6 +290,24 @@ static int32_t GetDefaultServiceInterval(const IntSettingDesc &sd, VehicleType t
return sd.def;
}
static std::tuple<int32_t, uint32_t> GetServiceIntervalRange(const IntSettingDesc &)
{
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) return { MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT };
if (TimerGameEconomy::UsingWallclockUnits(_game_mode == GM_MENU)) {
return { MIN_SERVINT_MINUTES, MAX_SERVINT_MINUTES };
}
return { MIN_SERVINT_DAYS, MAX_SERVINT_DAYS };
}
static void TrainAccelerationModelChanged(int32_t)
{
for (Train *t : Train::Iterate()) {