diff options
author | rubidium42 <rubidium@openttd.org> | 2021-05-24 11:47:37 +0200 |
---|---|---|
committer | rubidium42 <rubidium42@users.noreply.github.com> | 2021-05-29 10:07:30 +0200 |
commit | 08308d808c2ab3a6621762127eed6c46f16286c6 (patch) | |
tree | 1b0cc66d3169b27d8adf345e4304fe7c030e7ffb /src/table/company_settings.ini | |
parent | e2f5d9e561b70aec85d67b4eea822ba49f0c20bf (diff) | |
download | openttd-08308d808c2ab3a6621762127eed6c46f16286c6.tar.xz |
Codechange: use separate pre and post callbacks for int settings
Diffstat (limited to 'src/table/company_settings.ini')
-rw-r--r-- | src/table/company_settings.ini | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/table/company_settings.ini b/src/table/company_settings.ini index eecebb40e..019c26dd9 100644 --- a/src/table/company_settings.ini +++ b/src/table/company_settings.ini @@ -5,19 +5,16 @@ ; [pre-amble] -static bool CheckInterval(int32 p1); -static bool InvalidateDetailsWindow(int32 p1); -static bool UpdateIntervalTrains(int32 p1); -static bool UpdateIntervalRoadVeh(int32 p1); -static bool UpdateIntervalShips(int32 p1); -static bool UpdateIntervalAircraft(int32 p1); +static void UpdateServiceInterval(int32 new_value); +static bool CanUpdateServiceInterval(VehicleType type, int32 &new_value); +static void UpdateServiceInterval(VehicleType type, int32 new_value); static const SettingTable _company_settings{ [post-amble] }; [templates] -SDT_BOOL = SDT_BOOL($base, $var, $flags, $guiflags, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup), -SDT_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup), +SDT_BOOL = SDT_BOOL($base, $var, $flags, $guiflags, $def, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), +SDT_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup), [validation] SDT_VAR = static_assert($max <= MAX_$type, "Maximum value for $base.$var exceeds storage size"); @@ -29,7 +26,8 @@ interval = 0 str = STR_NULL strhelp = STR_CONFIG_SETTING_NO_EXPLANATION_AVAILABLE_HELPTEXT strval = STR_NULL -proc = nullptr +pre_cb = nullptr +post_cb = nullptr load = nullptr from = SL_MIN_VERSION to = SL_MAX_VERSION @@ -82,7 +80,7 @@ var = vehicle.servint_ispercent def = false str = STR_CONFIG_SETTING_SERVINT_ISPERCENT strhelp = STR_CONFIG_SETTING_SERVINT_ISPERCENT_HELPTEXT -proc = CheckInterval +post_cb = UpdateServiceInterval [SDT_VAR] base = CompanySettings @@ -95,7 +93,8 @@ max = 800 str = STR_CONFIG_SETTING_SERVINT_TRAINS strhelp = STR_CONFIG_SETTING_SERVINT_TRAINS_HELPTEXT strval = STR_CONFIG_SETTING_SERVINT_VALUE -proc = UpdateIntervalTrains +pre_cb = [](auto new_value) { return CanUpdateServiceInterval(VEH_TRAIN, new_value); } +post_cb = [](auto new_value) { UpdateServiceInterval(VEH_TRAIN, new_value); } [SDT_VAR] base = CompanySettings @@ -108,7 +107,8 @@ max = 800 str = STR_CONFIG_SETTING_SERVINT_ROAD_VEHICLES strhelp = STR_CONFIG_SETTING_SERVINT_ROAD_VEHICLES_HELPTEXT strval = STR_CONFIG_SETTING_SERVINT_VALUE -proc = UpdateIntervalRoadVeh +pre_cb = [](auto new_value) { return CanUpdateServiceInterval(VEH_ROAD, new_value); } +post_cb = [](auto new_value) { UpdateServiceInterval(VEH_ROAD, new_value); } [SDT_VAR] base = CompanySettings @@ -121,7 +121,8 @@ max = 800 str = STR_CONFIG_SETTING_SERVINT_SHIPS strhelp = STR_CONFIG_SETTING_SERVINT_SHIPS_HELPTEXT strval = STR_CONFIG_SETTING_SERVINT_VALUE -proc = UpdateIntervalShips +pre_cb = [](auto new_value) { return CanUpdateServiceInterval(VEH_SHIP, new_value); } +post_cb = [](auto new_value) { UpdateServiceInterval(VEH_SHIP, new_value); } [SDT_VAR] base = CompanySettings @@ -134,4 +135,5 @@ max = 800 str = STR_CONFIG_SETTING_SERVINT_AIRCRAFT strhelp = STR_CONFIG_SETTING_SERVINT_AIRCRAFT_HELPTEXT strval = STR_CONFIG_SETTING_SERVINT_VALUE -proc = UpdateIntervalAircraft +pre_cb = [](auto new_value) { return CanUpdateServiceInterval(VEH_AIRCRAFT, new_value); } +post_cb = [](auto new_value) { UpdateServiceInterval(VEH_AIRCRAFT, new_value); } |