diff --git a/scripts/eressea/xmlconf.lua b/scripts/eressea/xmlconf.lua index 1aaa39bdd..0840a31f7 100644 --- a/scripts/eressea/xmlconf.lua +++ b/scripts/eressea/xmlconf.lua @@ -6,3 +6,4 @@ if config.install then confdir = config.install .. '/' .. confdir end read_xml(confdir .. 'config.xml', confdir .. 'catalog.xml') +eressea.config.read(confdir .. 'config.json') diff --git a/src/bind_config.c b/src/bind_config.c index e0930481f..2de4c0d2a 100644 --- a/src/bind_config.c +++ b/src/bind_config.c @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include "kernel/building.h" #include "kernel/race.h" @@ -50,6 +52,22 @@ int config_parse(const char *json) int config_read(const char *filename) { + FILE *F = fopen(filename, "rt"); + if (F) { + int result; + char *data; + size_t sz; + + fseek(F, 0, SEEK_END); + sz = ftell(F); + rewind(F); + data = malloc(sz); + fread(data, 1, sz, F); + fclose(F); + result = config_parse(data); + free(data); + return result; + } return 1; } diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c index 2ba555e9e..b6d6ece6b 100644 --- a/src/kernel/jsonconf.c +++ b/src/kernel/jsonconf.c @@ -643,10 +643,10 @@ static void json_configs(cJSON *json) { return; } for (child = json->child; child; child = child->next) { - cJSON *config; - char *data; FILE *F = fopen(child->valuestring, "rt"); if (F) { + cJSON *config; + char *data; size_t sz; fseek(F, 0, SEEK_END); sz = ftell(F); @@ -657,6 +657,7 @@ static void json_configs(cJSON *json) { config = cJSON_Parse(data); free(data); json_config(config); + cJSON_Delete(config); } } } diff --git a/src/kernel/jsonconf.test.c b/src/kernel/jsonconf.test.c index 5ddba65ce..b7fabc3e3 100644 --- a/src/kernel/jsonconf.test.c +++ b/src/kernel/jsonconf.test.c @@ -15,6 +15,7 @@ #include #include #include +#include #include static const struct race * race_with_flag(const char * name) { @@ -393,6 +394,7 @@ static void test_keywords(CuTest * tc) CuAssertIntEquals(tc, K_MOVE, get_keyword("nach", lang)); CuAssertStrEquals(tc, "LERNEN", locale_string(lang, "keyword::study")); + CuAssertStrEquals(tc, "NACH", locale_string(lang, "keyword::move")); test_cleanup(); }