Changeset - r25526:33520e7899c5
[Not reviewed]
master
0 4 0
rubidium42 - 4 years ago 2021-05-22 06:32:51
rubidium@openttd.org
Cleanup: remove and/or fix some confusing comments

The comments for SettingDescType; it is a byte, so not 4 bytes and since it is not a flag there are about 250 other possibilities left instead of 9.
SettingGuiFlag is uint16 so has 2 bytes allocated.
SettingDescGlobVarList and related comments imply that global vars cannot be used elsewhere, but they are used for settings just fine. Even then the type is not used anywhere else but the definition of the table.
4 files changed with 4 insertions and 21 deletions:
0 comments (0 inline, 0 general)
src/settings_internal.h
Show inline comments
 
@@ -19,22 +19,16 @@
 
 * @see SettingDescBase
 
 */
 
enum SettingDescType : byte {
 
	/* 4 bytes allocated a maximum of 16 types for GenericType */
 
	SDT_BEGIN       = 0,
 
	SDT_NUMX        = 0, ///< any number-type
 
	SDT_BOOLX       = 1, ///< a boolean number
 
	SDT_ONEOFMANY   = 2, ///< bitmasked number where only ONE bit may be set
 
	SDT_MANYOFMANY  = 3, ///< bitmasked number where MULTIPLE bits may be set
 
	SDT_INTLIST     = 4, ///< list of integers separated by a comma ','
 
	SDT_STDSTRING   = 6, ///< \c std::string
 
	SDT_END,
 
	/* 9 more possible primitives */
 
};
 

	
 

	
 
enum SettingGuiFlag : uint16 {
 
	/* 1 byte allocated for a maximum of 8 flags
 
	 * Flags directing saving/loading of a variable */
 
	/* 2 bytes allocated for a maximum of 16 flags. */
 
	SGF_NONE = 0,
 
	SGF_0ISDISABLED   = 1 << 0, ///< a value of zero means the feature is disabled
 
	SGF_DISPLAY_ABS   = 1 << 1, ///< display absolute value of the setting
 
@@ -114,15 +108,6 @@ struct SettingDesc {
 
	SettingType GetType() const;
 
};
 

	
 
/* NOTE: The only difference between SettingDesc and SettingDescGlob is
 
 * that one uses global variables as a source and the other offsets
 
 * in a struct which are bound to a certain variable during runtime.
 
 * The only way to differentiate between these two is to check if an object
 
 * has been passed to the function or not. If not, then it is a global variable
 
 * and save->variable has its address, otherwise save->variable only holds the
 
 * offset in a certain struct */
 
typedef SettingDesc SettingDescGlobVarList;
 

	
 
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);
src/table/misc_settings.ini
Show inline comments
 
@@ -16,7 +16,7 @@ extern bool _allow_hidpi_window;
 
#define WITHOUT_COCOA
 
#endif
 

	
 
static const SettingDescGlobVarList _misc_settings[] = {
 
static const SettingDesc _misc_settings[] = {
 
[post-amble]
 
};
 
[templates]
src/table/settings.h.preamble
Show inline comments
 
@@ -23,9 +23,7 @@ static size_t ConvertLandscape(const cha
 
 * The macros can be grouped depending on where the config variable is
 
 * stored:
 
 * 1. SDTG_something
 
 *    These are for global variables, so this is the one you will use
 
 *    for a #SettingDescGlobVarList section. Here 'var' refers to a
 
 *    global variable.
 
 *    These are for global variables. Here 'var' refers to a global variable.
 
 * 2. SDTC_something
 
 *    These are for client-only variables. Here the 'var' refers to an
 
 *    entry inside _settings_client.
src/table/win32_settings.ini
Show inline comments
 
@@ -9,7 +9,7 @@
 
#if defined(_WIN32) && !defined(DEDICATED)
 
extern bool _window_maximize;
 

	
 
static const SettingDescGlobVarList _win32_settings[] = {
 
static const SettingDesc _win32_settings[] = {
 
[post-amble]
 
};
 
#endif /* _WIN32 */
0 comments (0 inline, 0 general)