Add setting flag to enable bool -> int config file load conversion

This commit is contained in:
Jonathan G Rennison
2022-11-17 23:23:29 +00:00
parent 6cf62af092
commit cf6f509859
2 changed files with 5 additions and 0 deletions

View File

@@ -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);