Changeset - r23678:26fe843cbb90
[Not reviewed]
master
0 8 0
Charles Pigott - 6 years ago 2019-04-22 10:10:44
charlespigott@googlemail.com
Codechange: Set size of SettingGuiFlag & SettingDescType enums, and use them properly
8 files changed with 14 insertions and 16 deletions:
0 comments (0 inline, 0 general)
src/settings_internal.h
Show inline comments
 
@@ -20,7 +20,7 @@
 
 * @see VarTypes
 
 * @see SettingDescBase
 
 */
 
enum SettingDescTypeLong {
 
enum SettingDescType : byte {
 
	/* 4 bytes allocated a maximum of 16 types for GenericType */
 
	SDT_BEGIN       = 0,
 
	SDT_NUMX        = 0, ///< any number-type
 
@@ -32,10 +32,9 @@ enum SettingDescTypeLong {
 
	SDT_END,
 
	/* 10 more possible primitives */
 
};
 
typedef SimpleTinyEnumT<SettingDescTypeLong, byte> SettingDescType;
 

	
 

	
 
enum SettingGuiFlagLong {
 
enum SettingGuiFlag : uint16 {
 
	/* 1 byte allocated for a maximum of 8 flags
 
	 * Flags directing saving/loading of a variable */
 
	SGF_NONE = 0,
 
@@ -49,8 +48,7 @@ enum SettingGuiFlagLong {
 
	SGF_SCENEDIT_TOO = 1 << 7, ///< this setting can be changed in the scenario editor (only makes sense when SGF_NEWGAME_ONLY is set)
 
	SGF_PER_COMPANY  = 1 << 8, ///< this setting can be different for each company (saved in company struct)
 
};
 
DECLARE_ENUM_AS_BIT_SET(SettingGuiFlagLong)
 
typedef SimpleTinyEnumT<SettingGuiFlagLong, uint16> SettingGuiFlag;
 
DECLARE_ENUM_AS_BIT_SET(SettingGuiFlag)
 

	
 
/**
 
 * A SettingCategory defines a grouping of the settings.
src/table/currency_settings.ini
Show inline comments
 
@@ -18,7 +18,7 @@ SDT_END = SDT_END()
 

	
 
[defaults]
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = 0
 
guiflags = SGF_NONE
 
interval = 0
 
str      = STR_NULL
 
strhelp  = STR_CONFIG_SETTING_NO_EXPLANATION_AVAILABLE_HELPTEXT
src/table/gameopt_settings.ini
Show inline comments
 
@@ -50,7 +50,7 @@ SDT_END      = SDT_END()
 

	
 
[defaults]
 
flags    = 0
 
guiflags = 0
 
guiflags = SGF_NONE
 
interval = 0
 
str      = STR_NULL
 
strhelp  = STR_CONFIG_SETTING_NO_EXPLANATION_AVAILABLE_HELPTEXT
src/table/misc_settings.ini
Show inline comments
 
@@ -25,7 +25,7 @@ SDTG_END   = SDTG_END()
 

	
 
[defaults]
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = 0
 
guiflags = SGF_NONE
 
interval = 0
 
str      = STR_NULL
 
strhelp  = STR_CONFIG_SETTING_NO_EXPLANATION_AVAILABLE_HELPTEXT
src/table/settings.h.preamble
Show inline comments
 
@@ -57,7 +57,7 @@ static size_t ConvertLandscape(const cha
 
 */
 

	
 
#define NSD_GENERAL(name, def, cmd, guiflags, min, max, interval, many, str, strhelp, strval, proc, load, cat)\
 
	{name, (const void*)(size_t)(def), {(byte)cmd}, {(uint16)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}
 

	
 
/* Macros for various objects to go in the configuration file.
 
 * This section is for global variables */
 
@@ -83,9 +83,9 @@ static size_t ConvertLandscape(const cha
 
	SDTG_GENERAL(name, SDT_MANYOFMANY, SL_VAR, type, flags, guiflags, var, 0, def, 0, 0, 0, full, str, strhelp, strval, proc, from, to, cat)
 

	
 
#define SDTG_NULL(length, from, to)\
 
	{{"", nullptr, {0}, {0}, 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}, SLEG_NULL(length, from, to)}
 

	
 
#define SDTG_END() {{nullptr, nullptr, {0}, {0}, 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}, SLEG_END()}
 

	
 
/* Macros for various objects to go in the configuration file.
 
 * This section is for structures where their various members are saved */
 
@@ -114,7 +114,7 @@ static size_t ConvertLandscape(const cha
 
	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)
 

	
 
#define SDT_NULL(length, from, to)\
 
	{{"", nullptr, {0}, {0}, 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}, SLE_CONDNULL(length, from, to)}
 

	
 

	
 
#define SDTC_VAR(var, type, flags, guiflags, def, min, max, interval, str, strhelp, strval, proc, from, to, cat)\
 
@@ -132,5 +132,5 @@ static size_t ConvertLandscape(const cha
 
#define SDTC_OMANY(var, type, flags, guiflags, def, max, full, str, strhelp, strval, proc, from, to, cat)\
 
	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)
 

	
 
#define SDT_END() {{nullptr, nullptr, {0}, {0}, 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}, SLE_END()}
 

	
src/table/settings.ini
Show inline comments
 
@@ -81,7 +81,7 @@ SDT_END    = SDT_END()
 

	
 
[defaults]
 
flags    = 0
 
guiflags = 0
 
guiflags = SGF_NONE
 
interval = 0
 
str      = STR_NULL
 
strhelp  = STR_CONFIG_SETTING_NO_EXPLANATION_AVAILABLE_HELPTEXT
src/table/win32_settings.ini
Show inline comments
 
@@ -23,7 +23,7 @@ SDTG_END  = SDTG_END()
 

	
 
[defaults]
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = 0
 
guiflags = SGF_NONE
 
interval = 0
 
str      = STR_NULL
 
strhelp  = STR_CONFIG_SETTING_NO_EXPLANATION_AVAILABLE_HELPTEXT
src/table/window_settings.ini
Show inline comments
 
@@ -19,7 +19,7 @@ SDT_END  = SDT_END()
 
[defaults]
 
base     = WindowDesc
 
flags    = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
 
guiflags = 0
 
guiflags = SGF_NONE
 
interval = 0
 
str      = STR_NULL
 
strhelp  = STR_CONFIG_SETTING_NO_EXPLANATION_AVAILABLE_HELPTEXT
0 comments (0 inline, 0 general)