diff --git a/src/settings.cpp b/src/settings.cpp index 26d74af446..5acc7c6a1c 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -409,6 +409,10 @@ size_t IntSettingDesc::ParseValue(const char *str) const char *end; size_t val = strtoul(str, &end, 0); if (end == str) { + if (this->flags & SF_CONVERT_BOOL_TO_INT) { + if (strcmp(str, "true") == 0 || strcmp(str, "on") == 0) return 1; + if (strcmp(str, "false") == 0 || strcmp(str, "off") == 0) return 0; + } ErrorMessageData msg(STR_CONFIG_ERROR, STR_CONFIG_ERROR_INVALID_VALUE); msg.SetDParamStr(0, str); msg.SetDParamStr(1, this->name); diff --git a/src/settings_internal.h b/src/settings_internal.h index 0c8338e5f3..b1179f2c86 100644 --- a/src/settings_internal.h +++ b/src/settings_internal.h @@ -35,6 +35,7 @@ enum SettingFlag : uint32 { SF_GUI_VELOCITY = 1 << 18, ///< setting value is a velocity SF_GUI_ADVISE_DEFAULT = 1 << 19, ///< Advise the user to leave this setting at its default value SF_ENUM_PRE_CB_VALIDATE = 1 << 20, ///< Call the pre_check callback for enum incoming value validation + SF_CONVERT_BOOL_TO_INT = 1 << 21, ///< Accept a boolean value when loading an int-type setting from the config file }; DECLARE_ENUM_AS_BIT_SET(SettingFlag)