summaryrefslogtreecommitdiff
path: root/src/table/settings.ini
diff options
context:
space:
mode:
authorrubidium42 <rubidium@openttd.org>2021-05-24 09:44:20 +0200
committerrubidium42 <rubidium42@users.noreply.github.com>2021-05-29 10:07:30 +0200
commite2f5d9e561b70aec85d67b4eea822ba49f0c20bf (patch)
tree991721d92ede3f190db9fc3c0dac85d127e2c330 /src/table/settings.ini
parentea9715d970911300b17f8a55dd1047f3706d22f4 (diff)
downloadopenttd-e2f5d9e561b70aec85d67b4eea822ba49f0c20bf.tar.xz
Codechange: use separate pre and post callbacks for string settings
Diffstat (limited to 'src/table/settings.ini')
-rw-r--r--src/table/settings.ini49
1 files changed, 26 insertions, 23 deletions
diff --git a/src/table/settings.ini b/src/table/settings.ini
index 4f105b5f6..1de905c5b 100644
--- a/src/table/settings.ini
+++ b/src/table/settings.ini
@@ -43,9 +43,8 @@ static bool SpriteZoomMinChanged(int32 p1);
static bool MaxVehiclesChanged(int32 p1);
static bool InvalidateShipPathCache(int32 p1);
-static bool UpdateClientName(int32 p1);
-static bool UpdateServerPassword(int32 p1);
-static bool UpdateRconPassword(int32 p1);
+static bool ReplaceAsteriskWithEmptyPassword(std::string &newval);
+static void UpdateClientConfigValues();
static bool UpdateClientConfigValues(int32 p1);
/* End - Callback Functions for the various settings */
@@ -54,7 +53,7 @@ static bool UpdateClientConfigValues(int32 p1);
* These include for example the GUI settings and will not be saved with the
* savegame.
* It is also a bit tricky since you would think that service_interval
- * for example doesn't need to be synched. Every client assigns the
+ * for example does not need to be synched. Every client assigns the
* service_interval value to the v->service_interval, meaning that every client
* assigns its own value. If the setting was company-based, that would mean that
* vehicles could decide on different moments that they are heading back to a
@@ -63,18 +62,18 @@ const SettingTable _settings{
[post-amble]
};
[templates]
-SDTG_BOOL = SDTG_BOOL($name, $flags, $guiflags, $var, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup),
-SDTG_VAR = SDTG_VAR($name, $type, $flags, $guiflags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup),
-SDTG_OMANY = SDTG_OMANY($name, $type, $flags, $guiflags, $var, $def, $max, $full, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup),
-SDTC_BOOL = SDTC_BOOL( $var, $flags, $guiflags, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup),
-SDTC_LIST = SDTC_LIST( $var, $type, $flags, $guiflags, $def, $from, $to, $cat, $extra, $startup),
-SDTC_OMANY = SDTC_OMANY( $var, $type, $flags, $guiflags, $def, $max, $full, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup),
-SDTC_SSTR = SDTC_SSTR( $var, $type, $flags, $guiflags, $def, $length, $proc, $from, $to, $cat, $extra, $startup),
-SDTC_VAR = SDTC_VAR( $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, $proc, $from, $to, $cat, $extra, $startup),
-SDT_OMANY = SDT_OMANY($base, $var, $type, $flags, $guiflags, $def, $max, $full, $str, $strhelp, $strval, $proc, $from, $to, $load, $cat, $extra, $startup),
-SDT_SSTR = SDT_SSTR($base, $var, $type, $flags, $guiflags, $def, $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),
+SDTG_BOOL = SDTG_BOOL($name, $flags, $guiflags, $var, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup),
+SDTG_VAR = SDTG_VAR($name, $type, $flags, $guiflags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup),
+SDTG_OMANY = SDTG_OMANY($name, $type, $flags, $guiflags, $var, $def, $max, $full, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup),
+SDTC_BOOL = SDTC_BOOL( $var, $flags, $guiflags, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup),
+SDTC_LIST = SDTC_LIST( $var, $type, $flags, $guiflags, $def, $from, $to, $cat, $extra, $startup),
+SDTC_OMANY = SDTC_OMANY( $var, $type, $flags, $guiflags, $def, $max, $full, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup),
+SDTC_SSTR = SDTC_SSTR( $var, $type, $flags, $guiflags, $def, $length, $pre_cb, $post_cb, $from, $to, $cat, $extra, $startup),
+SDTC_VAR = SDTC_VAR( $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, $proc, $from, $to, $cat, $extra, $startup),
+SDT_OMANY = SDT_OMANY($base, $var, $type, $flags, $guiflags, $def, $max, $full, $str, $strhelp, $strval, $proc, $from, $to, $load, $cat, $extra, $startup),
+SDT_SSTR = SDT_SSTR($base, $var, $type, $flags, $guiflags, $def, $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, $proc, $from, $to, $cat, $extra, $startup),
SDT_NULL = SDT_NULL($length, $from, $to),
[validation]
@@ -93,6 +92,8 @@ 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
@@ -2646,7 +2647,7 @@ type = SLE_STRQ
from = SLV_118
flags = SLF_NO_NETWORK_SYNC
def = nullptr
-proc = RedrawScreen
+post_cb = [](auto) { MarkWholeScreenDirty(); }
cat = SC_BASIC
[SDT_SSTR]
@@ -2656,7 +2657,7 @@ type = SLE_STRQ
from = SLV_118
flags = SLF_NO_NETWORK_SYNC
def = nullptr
-proc = RedrawScreen
+post_cb = [](auto) { MarkWholeScreenDirty(); }
cat = SC_BASIC
[SDT_SSTR]
@@ -2666,7 +2667,7 @@ type = SLE_STRQ
from = SLV_126
flags = SLF_NO_NETWORK_SYNC
def = nullptr
-proc = RedrawScreen
+post_cb = [](auto) { MarkWholeScreenDirty(); }
cat = SC_BASIC
@@ -3921,7 +3922,8 @@ type = SLE_STR
length = NETWORK_CLIENT_NAME_LENGTH
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
def = nullptr
-proc = UpdateClientName
+pre_cb = NetworkValidateClientName
+post_cb = NetworkUpdateClientName
cat = SC_BASIC
[SDTC_SSTR]
@@ -3931,7 +3933,8 @@ length = NETWORK_PASSWORD_LENGTH
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
guiflags = SGF_NETWORK_ONLY
def = nullptr
-proc = UpdateServerPassword
+pre_cb = ReplaceAsteriskWithEmptyPassword
+post_cb = [](auto) { NetworkServerUpdateGameInfo(); }
cat = SC_BASIC
[SDTC_SSTR]
@@ -3941,7 +3944,7 @@ length = NETWORK_PASSWORD_LENGTH
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
guiflags = SGF_NETWORK_ONLY
def = nullptr
-proc = UpdateRconPassword
+pre_cb = ReplaceAsteriskWithEmptyPassword
cat = SC_BASIC
[SDTC_SSTR]
@@ -3967,7 +3970,7 @@ length = NETWORK_NAME_LENGTH
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
guiflags = SGF_NETWORK_ONLY
def = nullptr
-proc = UpdateClientConfigValues
+post_cb = [](auto) { UpdateClientConfigValues(); }
cat = SC_BASIC
[SDTC_SSTR]