Changeset - r24817:a7332a241fe2
[Not reviewed]
master
0 10 0
Michael Lutz - 4 years ago 2021-02-15 23:09:52
michi@icosahedron.de
Codechange: Allow early-load settings that are not misc settings.
10 files changed with 111 insertions and 103 deletions:
0 comments (0 inline, 0 general)
src/settings.cpp
Show inline comments
 
@@ -83,13 +83,13 @@ VehicleDefaultSettings _old_vds; ///< Us
 
std::string _config_file; ///< Configuration file of OpenTTD
 

	
 
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);
 
typedef void SettingDescProc(IniFile *ini, const SettingDesc *desc, const char *grpname, void *object, bool only_startup);
 
typedef void SettingDescProcList(IniFile *ini, const char *grpname, StringList &list);
 

	
 
static bool IsSignedVarMemType(VarType vt);
 

	
 
/**
 
 * Groups in openttd.cfg that are actually lists.
 
@@ -498,23 +498,25 @@ static void Write_ValidateSetting(void *
 
 * 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
 
 *        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)
 
static void IniLoadSettings(IniFile *ini, const SettingDesc *sd, 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->desc;
 
		const SaveLoad        *sld = &sd->save;
 

	
 
		if (!SlIsObjectCurrentlyValid(sld->version_from, sld->version_to)) continue;
 
		if (sd->desc.startup != only_startup) continue;
 

	
 
		/* For settings.xx.yy load the settings from [xx] yy = ? */
 
		std::string s{ sdb->name };
 
		auto sc = s.find('.');
 
		if (sc != std::string::npos) {
 
			group = ini->GetGroup(s.substr(0, sc));
 
@@ -609,13 +611,13 @@ static void IniLoadSettings(IniFile *ini
 
 * @param object pointer to the object been saved
 
 * The function works as follows: for each item in the SettingDesc structure we
 
 * have a look if the value has changed since we started the game (the original
 
 * 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)
 
static void IniSaveSettings(IniFile *ini, const SettingDesc *sd, const char *grpname, void *object, bool)
 
{
 
	IniGroup *group_def = nullptr, *group;
 
	IniItem *item;
 
	char buf[512];
 
	void *ptr;
 

	
 
@@ -794,24 +796,24 @@ static void IniSaveSettingList(IniFile *
 
 * @param ini IniFile handle to the ini file with the source data
 
 * @param grpname character string identifying the section-header of the ini file that will be parsed
 
 * @param desc Destination WindowDesc
 
 */
 
void IniLoadWindowSettings(IniFile *ini, const char *grpname, void *desc)
 
{
 
	IniLoadSettings(ini, _window_settings, grpname, desc);
 
	IniLoadSettings(ini, _window_settings, grpname, desc, false);
 
}
 

	
 
/**
 
 * Save a WindowDesc to config.
 
 * @param ini IniFile handle to the ini file where the destination data is saved
 
 * @param grpname character string identifying the section-header of the ini file
 
 * @param desc Source WindowDesc
 
 */
 
void IniSaveWindowSettings(IniFile *ini, const char *grpname, void *desc)
 
{
 
	IniSaveSettings(ini, _window_settings, grpname, desc);
 
	IniSaveSettings(ini, _window_settings, grpname, desc, false);
 
}
 

	
 
/**
 
 * Check whether the setting is editable in the current gamemode.
 
 * @param do_command true if this is about checking a command from the server.
 
 * @return true if editable.
 
@@ -1710,26 +1712,24 @@ static void GRFSaveConfig(IniFile *ini, 
 
		seprintf(pos, lastof(key), "|%s", c->filename);
 
		group->GetItem(key, true)->SetValue(params);
 
	}
 
}
 

	
 
/* Common handler for saving/loading variables to the configuration file */
 
static void HandleSettingDescs(IniFile *ini, SettingDescProc *proc, SettingDescProcList *proc_list, bool basic_settings = true, bool other_settings = true)
 
static void HandleSettingDescs(IniFile *ini, SettingDescProc *proc, SettingDescProcList *proc_list, bool only_startup = false)
 
{
 
	if (basic_settings) {
 
		proc(ini, (const SettingDesc*)_misc_settings,    "misc",  nullptr);
 
	proc(ini, (const SettingDesc*)_misc_settings,    "misc",  nullptr, only_startup);
 
#if defined(_WIN32) && !defined(DEDICATED)
 
		proc(ini, (const SettingDesc*)_win32_settings,   "win32", nullptr);
 
	proc(ini, (const SettingDesc*)_win32_settings,   "win32", nullptr, only_startup);
 
#endif /* _WIN32 */
 
	}
 

	
 
	if (other_settings) {
 
		proc(ini, _settings,         "patches",  &_settings_newgame);
 
		proc(ini, _currency_settings,"currency", &_custom_currency);
 
		proc(ini, _company_settings, "company",  &_settings_client.company);
 
	proc(ini, _settings,         "patches",  &_settings_newgame, only_startup);
 
	proc(ini, _currency_settings,"currency", &_custom_currency, only_startup);
 
	proc(ini, _company_settings, "company",  &_settings_client.company, only_startup);
 

	
 
	if (!only_startup) {
 
		proc_list(ini, "server_bind_addresses", _network_bind_list);
 
		proc_list(ini, "servers", _network_host_list);
 
		proc_list(ini, "bans",    _network_ban_list);
 
	}
 
}
 

	
 
@@ -1739,30 +1739,30 @@ static IniFile *IniLoadConfig()
 
	ini->LoadFromDisk(_config_file, NO_DIRECTORY);
 
	return ini;
 
}
 

	
 
/**
 
 * Load the values from the configuration files
 
 * @param minimal Load the minimal amount of the configuration to "bootstrap" the blitter and such.
 
 * @param startup Load the minimal amount of the configuration to "bootstrap" the blitter and such.
 
 */
 
void LoadFromConfig(bool minimal)
 
void LoadFromConfig(bool startup)
 
{
 
	IniFile *ini = IniLoadConfig();
 
	if (!minimal) ResetCurrencies(false); // Initialize the array of currencies, without preserving the custom one
 
	if (!startup) ResetCurrencies(false); // Initialize the array of currencies, without preserving the custom one
 

	
 
	/* Load basic settings only during bootstrap, load other settings not during bootstrap */
 
	HandleSettingDescs(ini, IniLoadSettings, IniLoadSettingList, minimal, !minimal);
 
	HandleSettingDescs(ini, IniLoadSettings, IniLoadSettingList, startup);
 

	
 
	if (!minimal) {
 
	if (!startup) {
 
		_grfconfig_newgame = GRFLoadConfig(ini, "newgrf", false);
 
		_grfconfig_static  = GRFLoadConfig(ini, "newgrf-static", true);
 
		AILoadConfig(ini, "ai_players");
 
		GameLoadConfig(ini, "game_scripts");
 

	
 
		PrepareOldDiffCustom();
 
		IniLoadSettings(ini, _gameopt_settings, "gameopt", &_settings_newgame);
 
		IniLoadSettings(ini, _gameopt_settings, "gameopt", &_settings_newgame, false);
 
		HandleOldDiffCustom(false);
 

	
 
		ValidateSettings();
 

	
 
		/* Display scheduled errors */
 
		extern void ScheduleErrorMessage(ErrorList &datas);
src/settings_internal.h
Show inline comments
 
@@ -100,12 +100,13 @@ struct SettingDescBase {
 
	StringID str;           ///< (translated) string with descriptive text; gui and console
 
	StringID str_help;      ///< (Translated) string with help text; gui only.
 
	StringID str_val;       ///< (Translated) first string describing the value.
 
	OnChange *proc;         ///< callback procedure for when the value is changed
 
	OnConvert *proc_cnvt;   ///< callback procedure when loading value mechanism fails
 
	SettingCategory cat;    ///< assigned categories of the setting
 
	bool startup;           ///< setting has to be loaded directly at startup?
 
};
 

	
 
struct SettingDesc {
 
	SettingDescBase desc;   ///< Settings structure (going to configuration file)
 
	SaveLoad save;          ///< Internal structure (going to savegame, parts to config)
 

	
src/table/company_settings.ini
Show inline comments
 
@@ -13,14 +13,14 @@ static bool UpdateIntervalShips(int32 p1
 
static bool UpdateIntervalAircraft(int32 p1);
 

	
 
static const SettingDesc _company_settings[] = {
 
[post-amble]
 
};
 
[templates]
 
SDT_BOOL = SDT_BOOL($base, $var,        $flags, $guiflags, $def,                        $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra),
 
SDT_VAR  =  SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra),
 
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()
 

	
 
[defaults]
 
flags    = 0
 
guiflags = SGF_PER_COMPANY
 
interval = 0
 
@@ -30,12 +30,13 @@ strval   = STR_NULL
 
proc     = nullptr
 
load     = nullptr
 
from     = SL_MIN_VERSION
 
to       = SL_MAX_VERSION
 
cat      = SC_ADVANCED
 
extra    = 0
 
startup  = false
 

	
 

	
 

	
 
[SDT_BOOL]
 
base     = CompanySettings
 
var      = engine_renew
src/table/currency_settings.ini
Show inline comments
 
@@ -6,15 +6,15 @@
 

	
 
[pre-amble]
 
static const SettingDesc _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),
 
SDT_CHR = SDT_CHR($base, $var,        $flags, $guiflags, $def,                        $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra),
 
SDT_STR = SDT_STR($base, $var, $type, $flags, $guiflags, $def,                        $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra),
 
SDT_VAR = SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup),
 
SDT_CHR = SDT_CHR($base, $var,        $flags, $guiflags, $def,                        $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup),
 
SDT_STR = SDT_STR($base, $var, $type, $flags, $guiflags, $def,                        $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup),
 
SDT_END = SDT_END()
 

	
 
[defaults]
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NONE
 
interval = 0
 
@@ -24,12 +24,13 @@ strval   = STR_NULL
 
proc     = nullptr
 
load     = nullptr
 
from     = SL_MIN_VERSION
 
to       = SL_MAX_VERSION
 
cat      = SC_ADVANCED
 
extra    = 0
 
startup  = false
 

	
 

	
 

	
 
[SDT_VAR]
 
base     = CurrencySpec
 
var      = rate
src/table/gameopt_settings.ini
Show inline comments
 
@@ -34,19 +34,19 @@ static const SettingDesc _gameopt_settin
 
 * and why not byte for example?
 
 * 'SLE_FILE_I16 | SLE_VAR_U16' in "diff_custom" is needed to get around SlArray() hack
 
 * for savegames version 0 - though it is an array, it has to go through the byteswap process */
 
[post-amble]
 
};
 
[templates]
 
SDTG_GENERAL = SDTG_GENERAL($name, $sdt_cmd, $sle_cmd, $type, $flags, $guiflags, $var, $length, $def, $min, $max, $interval, $full, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra),
 
SDTG_VAR     =     SDTG_VAR($name,                     $type, $flags, $guiflags, $var,          $def, $min, $max, $interval,        $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra),
 
SDTG_GENERAL = SDTG_GENERAL($name, $sdt_cmd, $sle_cmd, $type, $flags, $guiflags, $var, $length, $def, $min, $max, $interval, $full, $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),
 
SDT_NULL     =   SDT_NULL($length, $from, $to),
 
SDTC_OMANY   = SDTC_OMANY(       $var, $type, $flags, $guiflags, $def,       $max, $full,            $str, $strhelp, $strval, $proc, $from, $to,        $cat, $extra),
 
SDTG_OMANY   = SDTG_OMANY($name,       $type, $flags, $guiflags, $var, $def, $max, $full,            $str, $strhelp, $strval, $proc, $from, $to,        $cat, $extra),
 
SDT_OMANY    =  SDT_OMANY($base, $var, $type, $flags, $guiflags, $def,       $max, $full,            $str, $strhelp, $strval, $proc, $from, $to, $load, $cat, $extra),
 
SDT_VAR      =    SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max,        $interval, $str, $strhelp, $strval, $proc, $from, $to,        $cat, $extra),
 
SDTC_OMANY   = SDTC_OMANY(       $var, $type, $flags, $guiflags, $def,       $max, $full,            $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),
 
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()
 

	
 
[defaults]
 
flags    = 0
 
guiflags = SGF_NONE
 
interval = 0
 
@@ -56,12 +56,13 @@ strval   = STR_NULL
 
proc     = nullptr
 
load     = nullptr
 
from     = SL_MIN_VERSION
 
to       = SL_MAX_VERSION
 
cat      = SC_ADVANCED
 
extra    = 0
 
startup  = false
 

	
 

	
 

	
 
[SDTG_GENERAL]
 
name     = ""diff_custom""
 
sdt_cmd  = SDT_INTLIST
src/table/misc_settings.ini
Show inline comments
 
@@ -16,20 +16,20 @@ extern bool _allow_hidpi_window;
 
#endif
 

	
 
static const SettingDescGlobVarList _misc_settings[] = {
 
[post-amble]
 
};
 
[templates]
 
SDTG_LIST  =  SDTG_LIST($name, $type, $length, $flags, $guiflags, $var, $def,                               $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra),
 
SDTG_MMANY = SDTG_MMANY($name, $type,          $flags, $guiflags, $var, $def,                        $full, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra),
 
SDTG_OMANY = SDTG_OMANY($name, $type,          $flags, $guiflags, $var, $def,       $max,            $full, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra),
 
SDTG_STR   =   SDTG_STR($name, $type,          $flags, $guiflags, $var, $def,                               $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra),
 
SDTG_SSTR  =  SDTG_SSTR($name, $type,          $flags, $guiflags, $var, $def,                               $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra),
 
SDTG_BOOL  =  SDTG_BOOL($name,                 $flags, $guiflags, $var, $def,                               $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra),
 
SDTG_VAR   =   SDTG_VAR($name, $type,          $flags, $guiflags, $var, $def, $min, $max, $interval,        $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra),
 
SDTC_VAR   =   SDTC_VAR($var,  $type,          $flags, $guiflags,       $def, $min, $max, $interval,        $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra),
 
SDTG_LIST  =  SDTG_LIST($name, $type, $length, $flags, $guiflags, $var, $def,                               $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup),
 
SDTG_MMANY = SDTG_MMANY($name, $type,          $flags, $guiflags, $var, $def,                        $full, $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),
 
SDTG_STR   =   SDTG_STR($name, $type,          $flags, $guiflags, $var, $def,                               $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup),
 
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),
 
SDTC_VAR   =   SDTC_VAR($var,  $type,          $flags, $guiflags,       $def, $min, $max, $interval,        $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra, $startup),
 
SDTG_END   = SDTG_END()
 

	
 
[defaults]
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NONE
 
interval = 0
 
@@ -39,12 +39,13 @@ strval   = STR_NULL
 
proc     = nullptr
 
load     = nullptr
 
from     = SL_MIN_VERSION
 
to       = SL_MAX_VERSION
 
cat      = SC_ADVANCED
 
extra    = 0
 
startup  = true
 

	
 

	
 

	
 
[SDTG_MMANY]
 
name     = ""display_opt""
 
type     = SLE_UINT8
src/table/settings.h.preamble
Show inline comments
 
@@ -53,87 +53,87 @@ static size_t ConvertLandscape(const cha
 
 * properly, for any kind of reasons.  In order to allow a process of self-cleaning
 
 * mechanism, a callback procedure is made available.  You will have to supply the function, which
 
 * will work on a string, one function per setting. And of course, enable the callback param
 
 * on the appropriate macro.
 
 */
 

	
 
#define NSD_GENERAL(name, def, cmd, guiflags, min, max, interval, many, str, strhelp, strval, proc, load, cat)\
 
	{name, (const void*)(size_t)(def), cmd, guiflags, min, max, interval, many, str, strhelp, strval, proc, load, cat}
 
#define NSD_GENERAL(name, def, cmd, guiflags, min, max, interval, many, str, strhelp, strval, proc, load, cat, startup)\
 
	{name, (const void*)(size_t)(def), cmd, guiflags, min, max, interval, many, str, strhelp, strval, proc, load, cat, startup}
 

	
 
/* Macros for various objects to go in the configuration file.
 
 * This section is for global variables */
 
#define SDTG_GENERAL(name, sdt_cmd, sle_cmd, type, flags, guiflags, var, length, def, min, max, interval, full, str, strhelp, strval, proc, from, to, cat, extra)\
 
	{NSD_GENERAL(name, def, sdt_cmd, guiflags, min, max, interval, full, str, strhelp, strval, proc, nullptr, cat), SLEG_GENERAL(sle_cmd, var, type | flags, length, from, to, extra)}
 
#define SDTG_GENERAL(name, sdt_cmd, sle_cmd, type, flags, guiflags, var, length, def, min, max, interval, full, str, strhelp, strval, proc, from, to, cat, extra, startup)\
 
	{NSD_GENERAL(name, def, sdt_cmd, guiflags, min, max, interval, full, str, strhelp, strval, proc, nullptr, cat, startup), SLEG_GENERAL(sle_cmd, var, type | flags, length, from, to, extra)}
 

	
 
#define SDTG_VAR(name, type, flags, guiflags, var, def, min, max, interval, str, strhelp, strval, proc, from, to, cat, extra)\
 
	SDTG_GENERAL(name, SDT_NUMX, SL_VAR, type, flags, guiflags, var, 0, def, min, max, interval, nullptr, str, strhelp, strval, proc, from, to, cat, extra)
 
#define SDTG_VAR(name, type, flags, guiflags, var, def, min, max, interval, str, strhelp, strval, proc, from, to, cat, extra, startup)\
 
	SDTG_GENERAL(name, SDT_NUMX, SL_VAR, type, flags, guiflags, var, 0, def, min, max, interval, nullptr, str, strhelp, strval, proc, from, to, cat, extra, startup)
 

	
 
#define SDTG_BOOL(name, flags, guiflags, var, def, str, strhelp, strval, proc, from, to, cat, extra)\
 
	SDTG_GENERAL(name, SDT_BOOLX, SL_VAR, SLE_BOOL, flags, guiflags, var, 0, def, 0, 1, 0, nullptr, str, strhelp, strval, proc, from, to, cat, extra)
 
#define SDTG_BOOL(name, flags, guiflags, var, def, str, strhelp, strval, proc, from, to, cat, extra, startup)\
 
	SDTG_GENERAL(name, SDT_BOOLX, SL_VAR, SLE_BOOL, flags, guiflags, var, 0, def, 0, 1, 0, nullptr, str, strhelp, strval, proc, from, to, cat, extra, startup)
 

	
 
#define SDTG_LIST(name, type, length, flags, guiflags, var, def, str, strhelp, strval, proc, from, to, cat, extra)\
 
	SDTG_GENERAL(name, SDT_INTLIST, SL_ARR, type, flags, guiflags, var, length, def, 0, 0, 0, nullptr, str, strhelp, strval, proc, from, to, cat, extra)
 
#define SDTG_LIST(name, type, length, flags, guiflags, var, def, str, strhelp, strval, proc, from, to, cat, extra, startup)\
 
	SDTG_GENERAL(name, SDT_INTLIST, SL_ARR, type, flags, guiflags, var, length, def, 0, 0, 0, nullptr, str, strhelp, strval, proc, from, to, cat, extra, startup)
 

	
 
#define SDTG_STR(name, type, flags, guiflags, var, def, str, strhelp, strval, proc, from, to, cat, extra)\
 
	SDTG_GENERAL(name, SDT_STRING, SL_STR, type, flags, guiflags, var, sizeof(var), def, 0, 0, 0, nullptr, str, strhelp, strval, proc, from, to, cat, extra)
 
#define SDTG_STR(name, type, flags, guiflags, var, def, str, strhelp, strval, proc, from, to, cat, extra, startup)\
 
	SDTG_GENERAL(name, SDT_STRING, SL_STR, type, flags, guiflags, var, sizeof(var), def, 0, 0, 0, nullptr, str, strhelp, strval, proc, from, to, cat, extra, startup)
 

	
 
#define SDTG_SSTR(name, type, flags, guiflags, var, def, str, strhelp, strval, proc, from, to, cat, extra)\
 
    SDTG_GENERAL(name, SDT_STDSTRING, SL_STDSTR, type, flags, guiflags, var, sizeof(var), def, 0, 0, 0, nullptr, str, strhelp, strval, proc, from, to, cat, extra)
 
#define SDTG_SSTR(name, type, flags, guiflags, var, def, str, strhelp, strval, proc, from, to, cat, extra, startup)\
 
    SDTG_GENERAL(name, SDT_STDSTRING, SL_STDSTR, type, flags, guiflags, var, sizeof(var), def, 0, 0, 0, nullptr, str, strhelp, strval, proc, from, to, cat, extra, startup)
 

	
 
#define SDTG_OMANY(name, type, flags, guiflags, var, def, max, full, str, strhelp, strval, proc, from, to, cat, extra)\
 
	SDTG_GENERAL(name, SDT_ONEOFMANY, SL_VAR, type, flags, guiflags, var, 0, def, 0, max, 0, full, str, strhelp, strval, proc, from, to, cat, extra)
 
#define SDTG_OMANY(name, type, flags, guiflags, var, def, max, full, str, strhelp, strval, proc, from, to, cat, extra, startup)\
 
	SDTG_GENERAL(name, SDT_ONEOFMANY, SL_VAR, type, flags, guiflags, var, 0, def, 0, max, 0, full, str, strhelp, strval, proc, from, to, cat, extra, startup)
 

	
 
#define SDTG_MMANY(name, type, flags, guiflags, var, def, full, str, strhelp, strval, proc, from, to, cat, extra)\
 
	SDTG_GENERAL(name, SDT_MANYOFMANY, SL_VAR, type, flags, guiflags, var, 0, def, 0, 0, 0, full, str, strhelp, strval, proc, from, to, cat, extra)
 
#define SDTG_MMANY(name, type, flags, guiflags, var, def, full, str, strhelp, strval, proc, from, to, cat, extra, startup)\
 
	SDTG_GENERAL(name, SDT_MANYOFMANY, SL_VAR, type, flags, guiflags, var, 0, def, 0, 0, 0, full, str, strhelp, strval, proc, from, to, cat, extra, startup)
 

	
 
#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}, SLEG_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}, SLEG_END()}
 
#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)\
 
	{NSD_GENERAL(name, def, sdt_cmd, guiflags, min, max, interval, full, str, strhelp, strval, proc, load, cat), SLE_GENERAL(sle_cmd, base, var, type | flags, length, from, to, extra)}
 
#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)\
 
	{NSD_GENERAL(name, def, sdt_cmd, guiflags, min, max, interval, full, str, strhelp, strval, proc, load, cat, startup), SLE_GENERAL(sle_cmd, base, var, type | flags, length, from, to, extra)}
 

	
 
#define SDT_VAR(base, var, type, flags, guiflags, def, min, max, interval, str, strhelp, strval, proc, from, to, cat, extra)\
 
	SDT_GENERAL(#var, SDT_NUMX, SL_VAR, type, flags, guiflags, base, var, 1, def, min, max, interval, nullptr, str, strhelp, strval, proc, nullptr, from, to, cat, extra)
 
#define SDT_VAR(base, var, type, flags, guiflags, def, min, max, interval, str, strhelp, strval, proc, from, to, cat, extra, startup)\
 
	SDT_GENERAL(#var, SDT_NUMX, SL_VAR, type, flags, guiflags, base, var, 1, def, min, max, interval, nullptr, str, strhelp, strval, proc, nullptr, from, to, cat, extra, startup)
 

	
 
#define SDT_BOOL(base, var, flags, guiflags, def, str, strhelp, strval, proc, from, to, cat, extra)\
 
	SDT_GENERAL(#var, SDT_BOOLX, SL_VAR, SLE_BOOL, flags, guiflags, base, var, 1, def, 0, 1, 0, nullptr, str, strhelp, strval, proc, nullptr, from, to, cat, extra)
 
#define SDT_BOOL(base, var, flags, guiflags, def, str, strhelp, strval, proc, from, to, cat, extra, startup)\
 
	SDT_GENERAL(#var, SDT_BOOLX, SL_VAR, SLE_BOOL, flags, guiflags, base, var, 1, def, 0, 1, 0, nullptr, str, strhelp, strval, proc, nullptr, from, to, cat, extra, startup)
 

	
 
#define SDT_LIST(base, var, type, flags, guiflags, def, str, strhelp, strval, proc, from, to, cat, extra)\
 
	SDT_GENERAL(#var, SDT_INTLIST, SL_ARR, type, flags, guiflags, base, var, lengthof(((base*)8)->var), def, 0, 0, 0, nullptr, str, strhelp, strval, proc, nullptr, from, to, cat, extra)
 
#define SDT_LIST(base, var, type, flags, guiflags, def, str, strhelp, strval, proc, from, to, cat, extra, startup)\
 
	SDT_GENERAL(#var, SDT_INTLIST, SL_ARR, type, flags, guiflags, base, var, lengthof(((base*)8)->var), def, 0, 0, 0, nullptr, str, strhelp, strval, proc, nullptr, from, to, cat, extra, startup)
 

	
 
#define SDT_STR(base, var, type, flags, guiflags, def, str, strhelp, strval, proc, from, to, cat, extra)\
 
	SDT_GENERAL(#var, SDT_STRING, SL_STR, type, flags, guiflags, base, var, sizeof(((base*)8)->var), def, 0, 0, 0, nullptr, str, strhelp, strval, proc, nullptr, from, to, cat, extra)
 
#define SDT_STR(base, var, type, flags, guiflags, def, str, strhelp, strval, proc, from, to, cat, extra, startup)\
 
	SDT_GENERAL(#var, SDT_STRING, SL_STR, type, flags, guiflags, base, var, sizeof(((base*)8)->var), def, 0, 0, 0, nullptr, str, strhelp, strval, proc, nullptr, from, to, cat, extra, startup)
 

	
 
#define SDT_CHR(base, var, flags, guiflags, def, str, strhelp, strval, proc, from, to, cat, extra)\
 
	SDT_GENERAL(#var, SDT_STRING, SL_VAR, SLE_CHAR, flags, guiflags, base, var, 1, def, 0, 0, 0, nullptr, str, strhelp, strval, proc, nullptr, from, to, cat, extra)
 
#define SDT_CHR(base, var, flags, guiflags, def, str, strhelp, strval, proc, from, to, cat, extra, startup)\
 
	SDT_GENERAL(#var, SDT_STRING, SL_VAR, SLE_CHAR, flags, guiflags, base, var, 1, def, 0, 0, 0, nullptr, str, strhelp, strval, proc, nullptr, from, to, cat, extra, startup)
 

	
 
#define SDT_OMANY(base, var, type, flags, guiflags, def, max, full, str, strhelp, strval, proc, from, to, load, cat, extra)\
 
	SDT_GENERAL(#var, SDT_ONEOFMANY, SL_VAR, type, flags, guiflags, base, var, 1, def, 0, max, 0, full, str, strhelp, strval, proc, load, from, to, cat, extra)
 
#define SDT_OMANY(base, var, type, flags, guiflags, def, max, full, str, strhelp, strval, proc, from, to, load, cat, extra, startup)\
 
	SDT_GENERAL(#var, SDT_ONEOFMANY, SL_VAR, type, flags, guiflags, base, var, 1, def, 0, max, 0, full, str, strhelp, strval, proc, load, from, to, cat, extra, startup)
 

	
 
#define SDT_MMANY(base, var, type, flags, guiflags, def, full, str, proc, strhelp, strval, from, to, cat, extra)\
 
	SDT_GENERAL(#var, SDT_MANYOFMANY, SL_VAR, type, flags, guiflags, base, var, 1, def, 0, 0, 0, full, str, strhelp, strval, proc, nullptr, from, to, cat, extra)
 
#define SDT_MMANY(base, var, type, flags, guiflags, def, full, str, proc, strhelp, strval, from, to, cat, extra, startup)\
 
	SDT_GENERAL(#var, SDT_MANYOFMANY, SL_VAR, type, flags, guiflags, base, var, 1, def, 0, 0, 0, full, str, strhelp, strval, proc, nullptr, from, to, cat, extra, startup)
 

	
 
#define SDT_NULL(length, from, to)\
 
	{{"", nullptr, SDT_NUMX, SGF_NONE, 0, 0, 0, nullptr, STR_NULL, STR_NULL, STR_NULL, nullptr, nullptr, SC_NONE}, SLE_CONDNULL(length, from, to)}
 
	{{"", nullptr, SDT_NUMX, SGF_NONE, 0, 0, 0, nullptr, STR_NULL, STR_NULL, STR_NULL, nullptr, nullptr, SC_NONE, false}, SLE_CONDNULL(length, from, to)}
 

	
 

	
 
#define SDTC_VAR(var, type, flags, guiflags, def, min, max, interval, str, strhelp, strval, proc, from, to, cat, extra)\
 
	SDTG_GENERAL(#var, SDT_NUMX, SL_VAR, type, flags, guiflags, _settings_client.var, 1, def, min, max, interval, nullptr, str, strhelp, strval, proc, from, to, cat, extra)
 
#define SDTC_VAR(var, type, flags, guiflags, def, min, max, interval, str, strhelp, strval, proc, from, to, cat, extra, startup)\
 
	SDTG_GENERAL(#var, SDT_NUMX, SL_VAR, type, flags, guiflags, _settings_client.var, 1, def, min, max, interval, nullptr, str, strhelp, strval, proc, from, to, cat, extra, startup)
 

	
 
#define SDTC_BOOL(var, flags, guiflags, def, str, strhelp, strval, proc, from, to, cat, extra)\
 
	SDTG_GENERAL(#var, SDT_BOOLX, SL_VAR, SLE_BOOL, flags, guiflags, _settings_client.var, 1, def, 0, 1, 0, nullptr, str, strhelp, strval, proc, from, to, cat, extra)
 
#define SDTC_BOOL(var, flags, guiflags, def, str, strhelp, strval, proc, from, to, cat, extra, startup)\
 
	SDTG_GENERAL(#var, SDT_BOOLX, SL_VAR, SLE_BOOL, flags, guiflags, _settings_client.var, 1, def, 0, 1, 0, nullptr, str, strhelp, strval, proc, from, to, cat, extra, startup)
 

	
 
#define SDTC_LIST(var, type, flags, guiflags, def, str, strhelp, strval, proc, from, to, cat, extra)\
 
	SDTG_GENERAL(#var, SDT_INTLIST, SL_ARR, type, flags, guiflags, _settings_client.var, lengthof(_settings_client.var), def, 0, 0, 0, nullptr, str, strhelp, strval, proc, from, to, cat, extra)
 
#define SDTC_LIST(var, type, flags, guiflags, def, str, strhelp, strval, proc, from, to, cat, extra, startup)\
 
	SDTG_GENERAL(#var, SDT_INTLIST, SL_ARR, type, flags, guiflags, _settings_client.var, lengthof(_settings_client.var), def, 0, 0, 0, nullptr, str, strhelp, strval, proc, from, to, cat, extra, startup)
 

	
 
#define SDTC_STR(var, type, flags, guiflags, def, str, strhelp, strval, proc, from, to, cat, extra)\
 
	SDTG_GENERAL(#var, SDT_STRING, SL_STR, type, flags, guiflags, _settings_client.var, sizeof(_settings_client.var), def, 0, 0, 0, nullptr, str, strhelp, strval, proc, from, to, cat, extra)
 
#define SDTC_STR(var, type, flags, guiflags, def, str, strhelp, strval, proc, from, to, cat, extra, startup)\
 
	SDTG_GENERAL(#var, SDT_STRING, SL_STR, type, flags, guiflags, _settings_client.var, sizeof(_settings_client.var), def, 0, 0, 0, nullptr, str, strhelp, strval, proc, from, to, cat, extra, startup)
 

	
 
#define SDTC_OMANY(var, type, flags, guiflags, def, max, full, str, strhelp, strval, proc, from, to, cat, extra)\
 
	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)
 
#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}, SLE_END()}
 
#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()}
 

	
src/table/settings.ini
Show inline comments
 
@@ -58,24 +58,24 @@ static bool UpdateClientConfigValues(int
 
 * vehicles could decide on different moments that they are heading back to a
 
 * service depot, causing desyncs on a massive scale. */
 
const SettingDesc _settings[] = {
 
[post-amble]
 
};
 
[templates]
 
SDTG_BOOL  =  SDTG_BOOL($name,              $flags, $guiflags, $var, $def,                        $str, $strhelp, $strval, $proc, $from, $to,        $cat, $extra),
 
SDTG_VAR   =   SDTG_VAR($name,       $type, $flags, $guiflags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to,        $cat, $extra),
 
SDTG_OMANY = SDTG_OMANY($name,       $type, $flags, $guiflags, $var, $def,       $max, $full,     $str, $strhelp, $strval, $proc, $from, $to,        $cat, $extra),
 
SDTC_BOOL  =  SDTC_BOOL(       $var,        $flags, $guiflags, $def,                              $str, $strhelp, $strval, $proc, $from, $to,        $cat, $extra),
 
SDTC_LIST  =  SDTC_LIST(       $var, $type, $flags, $guiflags, $def,                              $str, $strhelp, $strval, $proc, $from, $to,        $cat, $extra),
 
SDTC_OMANY = SDTC_OMANY(       $var, $type, $flags, $guiflags, $def,             $max, $full,     $str, $strhelp, $strval, $proc, $from, $to,        $cat, $extra),
 
SDTC_STR   =   SDTC_STR(       $var, $type, $flags, $guiflags, $def,                              $str, $strhelp, $strval, $proc, $from, $to,        $cat, $extra),
 
SDTC_VAR   =   SDTC_VAR(       $var, $type, $flags, $guiflags, $def,       $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to,        $cat, $extra),
 
SDT_BOOL   =   SDT_BOOL($base, $var,        $flags, $guiflags, $def,                              $str, $strhelp, $strval, $proc, $from, $to,        $cat, $extra),
 
SDT_OMANY  =  SDT_OMANY($base, $var, $type, $flags, $guiflags, $def,             $max, $full,     $str, $strhelp, $strval, $proc, $from, $to, $load, $cat, $extra),
 
SDT_STR    =    SDT_STR($base, $var, $type, $flags, $guiflags, $def,                              $str, $strhelp, $strval, $proc, $from, $to,        $cat, $extra),
 
SDT_VAR    =    SDT_VAR($base, $var, $type, $flags, $guiflags, $def,       $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to,        $cat, $extra),
 
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,                              $str, $strhelp, $strval, $proc, $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_STR   =   SDTC_STR(       $var, $type, $flags, $guiflags, $def,                              $str, $strhelp, $strval, $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_STR    =    SDT_STR($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()
 

	
 
[defaults]
 
flags    = 0
 
guiflags = SGF_NONE
 
@@ -86,12 +86,13 @@ strval   = STR_NULL
 
proc     = nullptr
 
load     = nullptr
 
from     = SL_MIN_VERSION
 
to       = SL_MAX_VERSION
 
cat      = SC_ADVANCED
 
extra    = 0
 
startup  = false
 

	
 

	
 

	
 
; Saved settings variables.
 
; Do not ADD or REMOVE something in this "difficulty.XXX" table or before it. It breaks savegame compatibility.
 
[SDT_VAR]
src/table/win32_settings.ini
Show inline comments
 
@@ -12,14 +12,14 @@ extern uint _display_hz;
 

	
 
static const SettingDescGlobVarList _win32_settings[] = {
 
[post-amble]
 
};
 
#endif /* _WIN32 */
 
[templates]
 
SDTG_BOOL = SDTG_BOOL($name,        $flags, $guiflags, $var, $def,                        $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra),
 
SDTG_VAR  =  SDTG_VAR($name, $type, $flags, $guiflags, $var, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra),
 
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()
 

	
 
[defaults]
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NONE
 
interval = 0
 
@@ -29,12 +29,13 @@ strval   = STR_NULL
 
proc     = nullptr
 
load     = nullptr
 
from     = SL_MIN_VERSION
 
to       = SL_MAX_VERSION
 
cat      = SC_ADVANCED
 
extra    = 0
 
startup  = true
 

	
 

	
 

	
 
[SDTG_VAR]
 
name     = ""display_hz""
 
type     = SLE_UINT
src/table/window_settings.ini
Show inline comments
 
@@ -7,14 +7,14 @@
 
[pre-amble]
 

	
 
static const SettingDesc _window_settings[] = {
 
[post-amble]
 
};
 
[templates]
 
SDT_BOOL = SDT_BOOL($base, $var,        $flags, $guiflags, $def,                        $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra),
 
SDT_VAR  =  SDT_VAR($base, $var, $type, $flags, $guiflags, $def, $min, $max, $interval, $str, $strhelp, $strval, $proc, $from, $to, $cat, $extra),
 
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()
 

	
 
[defaults]
 
base     = WindowDesc
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = SGF_NONE
 
@@ -25,12 +25,13 @@ strval   = STR_NULL
 
proc     = nullptr
 
load     = nullptr
 
from     = SL_MIN_VERSION
 
to       = SL_MAX_VERSION
 
cat      = SC_ADVANCED
 
extra    = 0
 
startup  = false
 

	
 

	
 

	
 
[SDT_BOOL]
 
var      = pref_sticky
 
def      = false
0 comments (0 inline, 0 general)