mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-01-18 05:01:13 +00:00
Fix: Restore ability to disable service interval
This commit is contained in:
parent
7493b2d0c1
commit
b88df0b2d7
@ -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()) {
|
||||
|
@ -14,6 +14,7 @@ static void UpdateServiceInterval(VehicleType type, int32_t new_value);
|
||||
static void SettingsValueAbsolute(const IntSettingDesc &sd, uint first_param, int32_t value);
|
||||
static void ServiceIntervalSettingsValueText(const IntSettingDesc &sd, uint first_param, int32_t value);
|
||||
static int32_t GetDefaultServiceInterval(const IntSettingDesc &sd, VehicleType type);
|
||||
static std::tuple<int32_t, uint32_t> GetServiceIntervalRange(const IntSettingDesc &sd);
|
||||
|
||||
static const SettingVariant _company_settings_table[] = {
|
||||
[post-amble]
|
||||
@ -103,6 +104,7 @@ pre_cb = [](auto &new_value) { return CanUpdateServiceInterval(VEH_TRAIN, new_
|
||||
post_cb = [](auto new_value) { UpdateServiceInterval(VEH_TRAIN, new_value); }
|
||||
def_cb = [](auto &sd) { return GetDefaultServiceInterval(sd, VEH_TRAIN); }
|
||||
val_cb = ServiceIntervalSettingsValueText
|
||||
range_cb = GetServiceIntervalRange
|
||||
|
||||
[SDT_VAR]
|
||||
var = vehicle.servint_roadveh
|
||||
@ -119,6 +121,7 @@ pre_cb = [](auto &new_value) { return CanUpdateServiceInterval(VEH_ROAD, new_v
|
||||
post_cb = [](auto new_value) { UpdateServiceInterval(VEH_ROAD, new_value); }
|
||||
def_cb = [](auto &sd) { return GetDefaultServiceInterval(sd, VEH_ROAD); }
|
||||
val_cb = ServiceIntervalSettingsValueText
|
||||
range_cb = GetServiceIntervalRange
|
||||
|
||||
[SDT_VAR]
|
||||
var = vehicle.servint_ships
|
||||
@ -135,6 +138,7 @@ pre_cb = [](auto &new_value) { return CanUpdateServiceInterval(VEH_SHIP, new_v
|
||||
post_cb = [](auto new_value) { UpdateServiceInterval(VEH_SHIP, new_value); }
|
||||
def_cb = [](auto &sd) { return GetDefaultServiceInterval(sd, VEH_SHIP); }
|
||||
val_cb = ServiceIntervalSettingsValueText
|
||||
range_cb = GetServiceIntervalRange
|
||||
|
||||
[SDT_VAR]
|
||||
var = vehicle.servint_aircraft
|
||||
@ -151,3 +155,4 @@ pre_cb = [](auto &new_value) { return CanUpdateServiceInterval(VEH_AIRCRAFT, n
|
||||
post_cb = [](auto new_value) { UpdateServiceInterval(VEH_AIRCRAFT, new_value); }
|
||||
def_cb = [](auto &sd) { return GetDefaultServiceInterval(sd, VEH_AIRCRAFT); }
|
||||
val_cb = ServiceIntervalSettingsValueText
|
||||
range_cb = GetServiceIntervalRange
|
||||
|
Loading…
Reference in New Issue
Block a user