summaryrefslogtreecommitdiff
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
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.
-rw-r--r--src/saveload/linkgraph_sl.cpp4
-rw-r--r--src/settings.cpp169
-rw-r--r--src/settings_internal.h2
-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
11 files changed, 107 insertions, 117 deletions
diff --git a/src/saveload/linkgraph_sl.cpp b/src/saveload/linkgraph_sl.cpp
index 3abf986e0..af2890244 100644
--- a/src/saveload/linkgraph_sl.cpp
+++ b/src/saveload/linkgraph_sl.cpp
@@ -74,7 +74,7 @@ const SaveLoad *GetLinkGraphJobDesc()
int setting = 0;
const SettingDesc *desc = GetSettingDescription(setting);
- while (desc->save.cmd != SL_END) {
+ while (desc != nullptr) {
if (desc->name != nullptr && strncmp(desc->name, prefix, prefixlen) == 0) {
SaveLoad sl = desc->save;
sl.address_proc = proc;
@@ -86,7 +86,7 @@ const SaveLoad *GetLinkGraphJobDesc()
int i = 0;
do {
saveloads.push_back(job_desc[i++]);
- } while (saveloads[saveloads.size() - 1].cmd != SL_END);
+ } while (saveloads.back().cmd != SL_END);
}
return &saveloads[0];
diff --git a/src/settings.cpp b/src/settings.cpp
index 2133fd63b..746e477da 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -87,12 +87,34 @@ typedef std::list<ErrorMessageData> ErrorList;
static ErrorList _settings_error_list; ///< Errors while loading minimal settings.
-typedef void SettingDescProc(IniFile *ini, const SettingDesc *desc, const char *grpname, void *object, bool only_startup);
+typedef void SettingDescProc(IniFile *ini, const SettingTable &desc, const char *grpname, void *object, bool only_startup);
typedef void SettingDescProcList(IniFile *ini, const char *grpname, StringList &list);
static bool IsSignedVarMemType(VarType vt);
/**
+ * Get the setting at the given index into the settings table.
+ * @param index The index to look for.
+ * @return The setting at the given index, or nullptr when the index is invalid.
+ */
+const SettingDesc *GetSettingDescription(uint index)
+{
+ if (index >= _settings.size()) return nullptr;
+ return &_settings.begin()[index];
+}
+
+/**
+ * Get the setting at the given index into the company settings table.
+ * @param index The index to look for.
+ * @return The setting at the given index, or nullptr when the index is invalid.
+ */
+static const SettingDesc *GetCompanySettingDescription(uint index)
+{
+ if (index >= _company_settings.size()) return nullptr;
+ return &_company_settings.begin()[index];
+}
+
+/**
* Groups in openttd.cfg that are actually lists.
*/
static const char * const _list_group_names[] = {
@@ -529,23 +551,23 @@ static void Write_ValidateStdString(void *ptr, const SettingDesc *sd, const char
/**
* Load values from a group of an IniFile structure into the internal representation
* @param ini pointer to IniFile structure that holds administrative information
- * @param sd pointer to SettingDesc structure whose internally pointed variables will
+ * @param settings_table table with SettingDesc structures whose internally pointed variables will
* be given values
* @param grpname the group of the IniFile to search in for the new values
* @param object pointer to the object been loaded
* @param only_startup load only the startup settings set
*/
-static void IniLoadSettings(IniFile *ini, const SettingDesc *sd, const char *grpname, void *object, bool only_startup)
+static void IniLoadSettings(IniFile *ini, const SettingTable &settings_table, const char *grpname, void *object, bool only_startup)
{
IniGroup *group;
IniGroup *group_def = ini->GetGroup(grpname);
- for (; sd->save.cmd != SL_END; sd++) {
- const SettingDescBase *sdb = sd;
- const SaveLoad *sld = &sd->save;
+ for (auto &sd : settings_table) {
+ const SettingDescBase *sdb = &sd;
+ const SaveLoad *sld = &sd.save;
if (!SlIsObjectCurrentlyValid(sld->version_from, sld->version_to)) continue;
- if (sd->startup != only_startup) continue;
+ if (sd.startup != only_startup) continue;
/* For settings.xx.yy load the settings from [xx] yy = ? */
std::string s{ sdb->name };
@@ -578,11 +600,11 @@ static void IniLoadSettings(IniFile *ini, const SettingDesc *sd, const char *grp
case SDT_NUMX:
case SDT_ONEOFMANY:
case SDT_MANYOFMANY:
- Write_ValidateSetting(ptr, sd, (int32)(size_t)p);
+ Write_ValidateSetting(ptr, &sd, (int32)(size_t)p);
break;
case SDT_STDSTRING:
- Write_ValidateStdString(ptr, sd, (const char *)p);
+ Write_ValidateStdString(ptr, &sd, (const char *)p);
break;
case SDT_INTLIST: {
@@ -593,8 +615,8 @@ static void IniLoadSettings(IniFile *ini, const SettingDesc *sd, const char *grp
/* Use default */
LoadIntList((const char*)sdb->def, ptr, sld->length, GetVarMemType(sld->conv));
- } else if (sd->proc_cnvt != nullptr) {
- sd->proc_cnvt((const char*)p);
+ } else if (sd.proc_cnvt != nullptr) {
+ sd.proc_cnvt((const char*)p);
}
break;
}
@@ -615,16 +637,16 @@ static void IniLoadSettings(IniFile *ini, const SettingDesc *sd, const char *grp
* values are reloaded when saving). If settings indeed have changed, we get
* these and save them.
*/
-static void IniSaveSettings(IniFile *ini, const SettingDesc *sd, const char *grpname, void *object, bool)
+static void IniSaveSettings(IniFile *ini, const SettingTable &settings_table, const char *grpname, void *object, bool)
{
IniGroup *group_def = nullptr, *group;
IniItem *item;
char buf[512];
void *ptr;
- for (; sd->save.cmd != SL_END; sd++) {
- const SettingDescBase *sdb = sd;
- const SaveLoad *sld = &sd->save;
+ for (auto &sd : settings_table) {
+ const SettingDescBase *sdb = &sd;
+ const SaveLoad *sld = &sd.save;
/* If the setting is not saved to the configuration
* file, just continue with the next setting */
@@ -1424,7 +1446,7 @@ static void HandleOldDiffCustom(bool savegame)
}
for (uint i = 0; i < options_to_load; i++) {
- const SettingDesc *sd = &_settings[i];
+ const SettingDesc *sd = GetSettingDescription(i);
/* Skip deprecated options */
if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) continue;
void *var = GetVariableAddress(savegame ? &_settings_game : &_settings_newgame, &sd->save);
@@ -1708,9 +1730,9 @@ static void GRFSaveConfig(IniFile *ini, const char *grpname, const GRFConfig *li
/* Common handler for saving/loading variables to the configuration file */
static void HandleSettingDescs(IniFile *ini, SettingDescProc *proc, SettingDescProcList *proc_list, bool only_startup = false)
{
- proc(ini, (const SettingDesc*)_misc_settings, "misc", nullptr, only_startup);
+ proc(ini, _misc_settings, "misc", nullptr, only_startup);
#if defined(_WIN32) && !defined(DEDICATED)
- proc(ini, (const SettingDesc*)_win32_settings, "win32", nullptr, only_startup);
+ proc(ini, _win32_settings, "win32", nullptr, only_startup);
#endif /* _WIN32 */
proc(ini, _settings, "patches", &_settings_newgame, only_startup);
@@ -1855,12 +1877,6 @@ void DeleteGRFPresetFromConfig(const char *config_name)
delete ini;
}
-const SettingDesc *GetSettingDescription(uint index)
-{
- if (index >= lengthof(_settings)) return nullptr;
- return &_settings[index];
-}
-
/**
* Network-safe changing of settings (server-only).
* @param tile unused
@@ -1923,8 +1939,8 @@ CommandCost CmdChangeSetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
*/
CommandCost CmdChangeCompanySetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
- if (p1 >= lengthof(_company_settings)) return CMD_ERROR;
- const SettingDesc *sd = &_company_settings[p1];
+ const SettingDesc *sd = GetCompanySettingDescription(p1);
+ if (sd == nullptr) return CMD_ERROR;
if (flags & DC_EXEC) {
void *var = GetVariableAddress(&Company::Get(_current_company)->settings, &sd->save);
@@ -1955,8 +1971,19 @@ CommandCost CmdChangeCompanySetting(TileIndex tile, DoCommandFlag flags, uint32
*/
uint GetSettingIndex(const SettingDesc *sd)
{
- assert((sd->flags & SGF_PER_COMPANY) == 0);
- return sd - _settings;
+ assert(sd != nullptr && (sd->flags & SGF_PER_COMPANY) == 0);
+ return sd - _settings.begin();
+}
+
+/**
+ * Get the index of the company setting with this description.
+ * @param sd the setting to get the index for.
+ * @return the index of the setting to be used for CMD_CHANGE_COMPANY_SETTING.
+ */
+static uint GetCompanySettingIndex(const SettingDesc *sd)
+{
+ assert(sd != nullptr && (sd->flags & SGF_PER_COMPANY) != 0);
+ return sd - _company_settings.begin();
}
/**
@@ -1970,7 +1997,7 @@ bool SetSettingValue(const SettingDesc *sd, int32 value, bool force_newgame)
{
if ((sd->flags & SGF_PER_COMPANY) != 0) {
if (Company::IsValidID(_local_company) && _game_mode != GM_MENU) {
- return DoCommandP(0, sd - _company_settings, value, CMD_CHANGE_COMPANY_SETTING);
+ return DoCommandP(0, GetCompanySettingIndex(sd), value, CMD_CHANGE_COMPANY_SETTING);
}
void *var = GetVariableAddress(&_settings_client.company, &sd->save);
@@ -2020,10 +2047,9 @@ bool SetSettingValue(const SettingDesc *sd, int32 value, bool force_newgame)
void SetDefaultCompanySettings(CompanyID cid)
{
Company *c = Company::Get(cid);
- const SettingDesc *sd;
- for (sd = _company_settings; sd->save.cmd != SL_END; sd++) {
- void *var = GetVariableAddress(&c->settings, &sd->save);
- Write_ValidateSetting(var, sd, (int32)(size_t)sd->def);
+ for (auto &sd : _company_settings) {
+ void *var = GetVariableAddress(&c->settings, &sd.save);
+ Write_ValidateSetting(var, &sd, (int32)(size_t)sd.def);
}
}
@@ -2032,14 +2058,14 @@ void SetDefaultCompanySettings(CompanyID cid)
*/
void SyncCompanySettings()
{
- const SettingDesc *sd;
uint i = 0;
- for (sd = _company_settings; sd->save.cmd != SL_END; sd++, i++) {
- const void *old_var = GetVariableAddress(&Company::Get(_current_company)->settings, &sd->save);
- const void *new_var = GetVariableAddress(&_settings_client.company, &sd->save);
- uint32 old_value = (uint32)ReadValue(old_var, sd->save.conv);
- uint32 new_value = (uint32)ReadValue(new_var, sd->save.conv);
+ for (auto &sd : _company_settings) {
+ const void *old_var = GetVariableAddress(&Company::Get(_current_company)->settings, &sd.save);
+ const void *new_var = GetVariableAddress(&_settings_client.company, &sd.save);
+ uint32 old_value = (uint32)ReadValue(old_var, sd.save.conv);
+ uint32 new_value = (uint32)ReadValue(new_var, sd.save.conv);
if (old_value != new_value) NetworkSendCommand(0, i, new_value, CMD_CHANGE_COMPANY_SETTING, nullptr, nullptr, _local_company);
+ i++;
}
}
@@ -2050,9 +2076,7 @@ void SyncCompanySettings()
*/
uint GetCompanySettingIndex(const char *name)
{
- const SettingDesc *sd = GetSettingFromName(name);
- assert(sd != nullptr && (sd->flags & SGF_PER_COMPANY) != 0);
- return sd - _company_settings;
+ return GetCompanySettingIndex(GetSettingFromName(name));
}
/**
@@ -2088,26 +2112,26 @@ bool SetSettingValue(const SettingDesc *sd, const char *value, bool force_newgam
const SettingDesc *GetSettingFromName(const char *name)
{
/* First check all full names */
- for (const SettingDesc *sd = _settings; sd->save.cmd != SL_END; sd++) {
- if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) continue;
- if (strcmp(sd->name, name) == 0) return sd;
+ for (auto &sd : _settings) {
+ if (!SlIsObjectCurrentlyValid(sd.save.version_from, sd.save.version_to)) continue;
+ if (strcmp(sd.name, name) == 0) return &sd;
}
/* Then check the shortcut variant of the name. */
- for (const SettingDesc *sd = _settings; sd->save.cmd != SL_END; sd++) {
- if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) continue;
- const char *short_name = strchr(sd->name, '.');
+ for (auto &sd : _settings) {
+ if (!SlIsObjectCurrentlyValid(sd.save.version_from, sd.save.version_to)) continue;
+ const char *short_name = strchr(sd.name, '.');
if (short_name != nullptr) {
short_name++;
- if (strcmp(short_name, name) == 0) return sd;
+ if (strcmp(short_name, name) == 0) return &sd;
}
}
if (strncmp(name, "company.", 8) == 0) name += 8;
/* And finally the company-based settings */
- for (const SettingDesc *sd = _company_settings; sd->save.cmd != SL_END; sd++) {
- if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) continue;
- if (strcmp(sd->name, name) == 0) return sd;
+ for (auto &sd : _company_settings) {
+ if (!SlIsObjectCurrentlyValid(sd.save.version_from, sd.save.version_to)) continue;
+ if (strcmp(sd.name, name) == 0) return &sd;
}
return nullptr;
@@ -2196,20 +2220,20 @@ void IConsoleListSettings(const char *prefilter)
{
IConsolePrintF(CC_WARNING, "All settings with their current value:");
- for (const SettingDesc *sd = _settings; sd->save.cmd != SL_END; sd++) {
- if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) continue;
- if (prefilter != nullptr && strstr(sd->name, prefilter) == nullptr) continue;
+ for (auto &sd : _settings) {
+ if (!SlIsObjectCurrentlyValid(sd.save.version_from, sd.save.version_to)) continue;
+ if (prefilter != nullptr && strstr(sd.name, prefilter) == nullptr) continue;
char value[80];
- const void *ptr = GetVariableAddress(&GetGameSettings(), &sd->save);
+ const void *ptr = GetVariableAddress(&GetGameSettings(), &sd.save);
- if (sd->cmd == SDT_BOOLX) {
+ if (sd.cmd == SDT_BOOLX) {
seprintf(value, lastof(value), (*(const bool *)ptr != 0) ? "on" : "off");
- } else if (sd->cmd == SDT_STDSTRING) {
+ } else if (sd.cmd == SDT_STDSTRING) {
seprintf(value, lastof(value), "%s", reinterpret_cast<const std::string *>(ptr)->c_str());
} else {
- seprintf(value, lastof(value), sd->min < 0 ? "%d" : "%u", (int32)ReadValue(ptr, sd->save.conv));
+ seprintf(value, lastof(value), sd.min < 0 ? "%d" : "%u", (int32)ReadValue(ptr, sd.save.conv));
}
- IConsolePrintF(CC_DEFAULT, "%s = %s", sd->name, value);
+ IConsolePrintF(CC_DEFAULT, "%s = %s", sd.name, value);
}
IConsolePrintF(CC_WARNING, "Use 'setting' command to change a value");
@@ -2217,41 +2241,40 @@ void IConsoleListSettings(const char *prefilter)
/**
* Save and load handler for settings
- * @param osd SettingDesc struct containing all information
+ * @param settings SettingDesc struct containing all information
* @param object can be either nullptr in which case we load global variables or
* a pointer to a struct which is getting saved
*/
-static void LoadSettings(const SettingDesc *osd, void *object)
+static void LoadSettings(const SettingTable &settings, void *object)
{
- for (; osd->save.cmd != SL_END; osd++) {
- const SaveLoad *sld = &osd->save;
+ for (auto &osd : settings) {
+ const SaveLoad *sld = &osd.save;
void *ptr = GetVariableAddress(object, sld);
if (!SlObjectMember(ptr, sld)) continue;
- if (IsNumericType(sld->conv)) Write_ValidateSetting(ptr, osd, ReadValue(ptr, sld->conv));
+ if (IsNumericType(sld->conv)) Write_ValidateSetting(ptr, &osd, ReadValue(ptr, sld->conv));
}
}
/**
* Save and load handler for settings
- * @param sd SettingDesc struct containing all information
+ * @param settings SettingDesc struct containing all information
* @param object can be either nullptr in which case we load global variables or
* a pointer to a struct which is getting saved
*/
-static void SaveSettings(const SettingDesc *sd, void *object)
+static void SaveSettings(const SettingTable &settings, void *object)
{
/* We need to write the CH_RIFF header, but unfortunately can't call
* SlCalcLength() because we have a different format. So do this manually */
- const SettingDesc *i;
size_t length = 0;
- for (i = sd; i->save.cmd != SL_END; i++) {
- length += SlCalcObjMemberLength(object, &i->save);
+ for (auto &sd : settings) {
+ length += SlCalcObjMemberLength(object, &sd.save);
}
SlSetLength(length);
- for (i = sd; i->save.cmd != SL_END; i++) {
- void *ptr = GetVariableAddress(object, &i->save);
- SlObjectMember(ptr, &i->save);
+ for (auto &sd : settings) {
+ void *ptr = GetVariableAddress(object, &sd.save);
+ SlObjectMember(ptr, &sd.save);
}
}
diff --git a/src/settings_internal.h b/src/settings_internal.h
index f92480a76..fca85de0c 100644
--- a/src/settings_internal.h
+++ b/src/settings_internal.h
@@ -107,6 +107,8 @@ struct SettingDesc : SettingDescBase {
SettingType GetType() const;
};
+typedef std::initializer_list<const SettingDesc> SettingTable;
+
const SettingDesc *GetSettingFromName(const char *name);
bool SetSettingValue(const SettingDesc *sd, int32 value, bool force_newgame = false);
bool SetSettingValue(const SettingDesc *sd, const char *value, bool force_newgame = false);
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]
-
-};