config.json settings shall not override eressea.ini

This commit is contained in:
Enno Rehling 2017-01-21 20:59:16 +01:00
parent 8c4cccbc65
commit f18f083922
2 changed files with 6 additions and 1 deletions

View File

@ -806,7 +806,9 @@ static void json_settings(cJSON *json) {
else {
sprintf(value, "%d", child->valueint);
}
config_set(child->string, value);
if (config_get(child->string) == NULL) {
config_set(child->string, value);
}
}
}
}

View File

@ -69,12 +69,15 @@ static void test_settings(CuTest * tc)
"\"string\" : \"1d4\","
"\"integer\" : 14,"
"\"true\": true,"
"\"game.id\": 4,"
"\"false\": false,"
"\"float\" : 1.5 }}";
cJSON *json = cJSON_Parse(data);
test_cleanup();
config_set("game.id", "42"); // should not be replaced
json_config(json);
CuAssertStrEquals(tc, "42", config_get("game.id"));
CuAssertStrEquals(tc, "1", config_get("true"));
CuAssertStrEquals(tc, "0", config_get("false"));
CuAssertStrEquals(tc, "1d4", config_get("string"));