summaryrefslogtreecommitdiff
path: root/src/table
diff options
context:
space:
mode:
authorrubidium42 <rubidium@openttd.org>2021-05-18 21:01:42 +0200
committerrubidium42 <rubidium42@users.noreply.github.com>2021-05-27 18:49:43 +0200
commit3bb6ce8827b71ae1dcfde4a7836fb6c636fb5a67 (patch)
tree683666e0514c5acc04c698205a088c43afccc2ff /src/table
parent425d50372fab501acc97981953a6c002c0a750cf (diff)
downloadopenttd-3bb6ce8827b71ae1dcfde4a7836fb6c636fb5a67.tar.xz
Codechange: use initializer_lists for the settings tables
Not using vectors as those require copying from the initializer list and that makes unique_ptrs to the actual SettingDesc objects later impossible.
Diffstat (limited to 'src/table')
-rw-r--r--src/table/company_settings.ini8
-rw-r--r--src/table/currency_settings.ini6
-rw-r--r--src/table/gameopt_settings.ini6
-rw-r--r--src/table/misc_settings.ini6
-rw-r--r--src/table/settings.h.preamble4
-rw-r--r--src/table/settings.ini6
-rw-r--r--src/table/win32_settings.ini6
-rw-r--r--src/table/window_settings.ini7
8 files changed, 7 insertions, 42 deletions
diff --git a/src/table/company_settings.ini b/src/table/company_settings.ini
index eea2371fc..eecebb40e 100644
--- a/src/table/company_settings.ini
+++ b/src/table/company_settings.ini
@@ -12,13 +12,12 @@ static bool UpdateIntervalRoadVeh(int32 p1);
static bool UpdateIntervalShips(int32 p1);
static bool UpdateIntervalAircraft(int32 p1);
-static const SettingDesc _company_settings[] = {
+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_END = SDT_END()
[validation]
SDT_VAR = static_assert($max <= MAX_$type, "Maximum value for $base.$var exceeds storage size");
@@ -136,8 +135,3 @@ str = STR_CONFIG_SETTING_SERVINT_AIRCRAFT
strhelp = STR_CONFIG_SETTING_SERVINT_AIRCRAFT_HELPTEXT
strval = STR_CONFIG_SETTING_SERVINT_VALUE
proc = UpdateIntervalAircraft
-
-[SDT_END]
-
-
-};
diff --git a/src/table/currency_settings.ini b/src/table/currency_settings.ini
index d2f12473e..613f9bfa5 100644
--- a/src/table/currency_settings.ini
+++ b/src/table/currency_settings.ini
@@ -5,13 +5,12 @@
;
[pre-amble]
-static const SettingDesc _currency_settings[] = {
+static const SettingTable _currency_settings{
[post-amble]
};
[templates]
SDT_VAR = SDT_VAR ($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup),
SDT_SSTR = SDT_SSTR($base, $var, $type, $flags, $guiflags, $def, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup),
-SDT_END = SDT_END()
[validation]
SDT_VAR = static_assert($max <= MAX_$type, "Maximum value for $base.$var exceeds storage size");
@@ -67,6 +66,3 @@ base = CurrencySpec
var = suffix
type = SLE_STRQ
def = "" credits""
-
-[SDT_END]
-
diff --git a/src/table/gameopt_settings.ini b/src/table/gameopt_settings.ini
index b0b1798ab..39caa45c9 100644
--- a/src/table/gameopt_settings.ini
+++ b/src/table/gameopt_settings.ini
@@ -23,7 +23,7 @@ static const char *_osk_activation = "disabled|double|single|immediately";
static const char *_settings_profiles = "easy|medium|hard";
static const char *_news_display = "off|summarized|full";
-static const SettingDesc _gameopt_settings[] = {
+static const SettingTable _gameopt_settings{
/* In version 4 a new difficulty setting has been added to the difficulty settings,
* town attitude towards demolishing. Needs special handling because some dimwit thought
* it funny to have the GameDifficulty struct be an array while it is a struct of
@@ -43,7 +43,6 @@ SDTC_OMANY = SDTC_OMANY( $var, $type, $flags, $guiflags, $def, $ma
SDTG_OMANY = SDTG_OMANY($name, $type, $flags, $guiflags, $var, $def, $max, $full, $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_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup),
-SDT_END = SDT_END()
[validation]
SDTG_VAR = static_assert($max <= MAX_$type, "Maximum value for $var exceeds storage size");
@@ -186,6 +185,3 @@ def = 1
max = 1
full = _roadsides
cat = SC_BASIC
-
-[SDT_END]
-
diff --git a/src/table/misc_settings.ini b/src/table/misc_settings.ini
index 2613b4ddd..4e1c3482e 100644
--- a/src/table/misc_settings.ini
+++ b/src/table/misc_settings.ini
@@ -16,7 +16,7 @@ extern bool _allow_hidpi_window;
#define WITHOUT_COCOA
#endif
-static const SettingDesc _misc_settings[] = {
+static const SettingTable _misc_settings{
[post-amble]
};
[templates]
@@ -26,7 +26,6 @@ SDTG_OMANY = SDTG_OMANY($name, $type, $flags, $guiflags, $var, $def,
SDTG_SSTR = SDTG_SSTR($name, $type, $flags, $guiflags, $var, $def, $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_END = SDTG_END()
[validation]
SDTG_VAR = static_assert($max <= MAX_$type, "Maximum value for $var exceeds storage size");
@@ -353,6 +352,3 @@ ifdef = WITH_COCOA
name = ""allow_hidpi""
var = _allow_hidpi_window
def = true
-
-[SDTG_END]
-
diff --git a/src/table/settings.h.preamble b/src/table/settings.h.preamble
index 6410b0360..f9bb27902 100644
--- a/src/table/settings.h.preamble
+++ b/src/table/settings.h.preamble
@@ -83,8 +83,6 @@ static size_t ConvertLandscape(const char *value);
#define SDTG_NULL(length, from, to)\
{{"", nullptr, SDT_NUMX, SGF_NONE, 0, 0, 0, nullptr, STR_NULL, STR_NULL, STR_NULL, nullptr, nullptr, SC_NONE, false}, SLEG_NULL(length, from, to)}
-#define SDTG_END() {{nullptr, nullptr, SDT_NUMX, SGF_NONE, 0, 0, 0, nullptr, STR_NULL, STR_NULL, STR_NULL, nullptr, nullptr, SC_NONE, false}, SLEG_END()}
-
/* Macros for various objects to go in the configuration file.
* This section is for structures where their various members are saved */
#define SDT_GENERAL(name, sdt_cmd, sle_cmd, type, flags, guiflags, base, var, length, def, min, max, interval, full, str, strhelp, strval, proc, load, from, to, cat, extra, startup)\
@@ -127,5 +125,3 @@ static size_t ConvertLandscape(const char *value);
#define SDTC_OMANY(var, type, flags, guiflags, def, max, full, str, strhelp, strval, proc, from, to, cat, extra, startup)\
SDTG_GENERAL(#var, SDT_ONEOFMANY, SL_VAR, type, flags, guiflags, _settings_client.var, 1, def, 0, max, 0, full, str, strhelp, strval, proc, from, to, cat, extra, startup)
-#define SDT_END() {{nullptr, nullptr, SDT_NUMX, SGF_NONE, 0, 0, 0, nullptr, STR_NULL, STR_NULL, STR_NULL, nullptr, nullptr, SC_NONE, false}, SLE_END()}
-
diff --git a/src/table/settings.ini b/src/table/settings.ini
index eea30e003..ed07dfb11 100644
--- a/src/table/settings.ini
+++ b/src/table/settings.ini
@@ -59,7 +59,7 @@ static bool UpdateClientConfigValues(int32 p1);
* 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
* service depot, causing desyncs on a massive scale. */
-const SettingDesc _settings[] = {
+const SettingTable _settings{
[post-amble]
};
[templates]
@@ -76,7 +76,6 @@ SDT_OMANY = SDT_OMANY($base, $var, $type, $flags, $guiflags, $def,
SDT_SSTR = SDT_SSTR($base, $var, $type, $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_NULL = SDT_NULL($length, $from, $to),
-SDT_END = SDT_END()
[validation]
SDTG_VAR = static_assert($max <= MAX_$type, "Maximum value for $var exceeds storage size");
@@ -4112,6 +4111,3 @@ str = STR_CONFIG_SETTING_RIGHT_MOUSE_BTN_EMU
strhelp = STR_CONFIG_SETTING_RIGHT_MOUSE_BTN_EMU_HELPTEXT
strval = STR_CONFIG_SETTING_RIGHT_MOUSE_BTN_EMU_COMMAND
cat = SC_BASIC
-
-[SDT_END]
-
diff --git a/src/table/win32_settings.ini b/src/table/win32_settings.ini
index 963a11df8..669474cc7 100644
--- a/src/table/win32_settings.ini
+++ b/src/table/win32_settings.ini
@@ -9,14 +9,13 @@
#if defined(_WIN32) && !defined(DEDICATED)
extern bool _window_maximize;
-static const SettingDesc _win32_settings[] = {
+static const SettingTable _win32_settings{
[post-amble]
};
#endif /* _WIN32 */
[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_END = SDTG_END()
[validation]
SDTG_VAR = static_assert($max <= MAX_$type, "Maximum value for $var exceeds storage size");
@@ -42,6 +41,3 @@ name = ""window_maximize""
var = _window_maximize
def = false
cat = SC_BASIC
-
-[SDTG_END]
-
diff --git a/src/table/window_settings.ini b/src/table/window_settings.ini
index fb252076c..5e11ea002 100644
--- a/src/table/window_settings.ini
+++ b/src/table/window_settings.ini
@@ -6,13 +6,12 @@
[pre-amble]
-static const SettingDesc _window_settings[] = {
+static const SettingTable _window_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_END = SDT_END()
[validation]
SDT_VAR = static_assert($max <= MAX_$type, "Maximum value for $base.$var exceeds storage size");
@@ -52,7 +51,3 @@ type = SLE_INT16
def = 0
min = 0
max = 32000
-
-[SDT_END]
-
-};