From a316283a6d2af963c9efb4d27de081fa34b0b100 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 4 Feb 2018 18:25:38 +0100 Subject: [PATCH 1/9] plan to eliminate xinclude use, move to single config file with includes. --- conf/e2/config.json | 4 +- scripts/eressea/xmlconf.lua | 4 +- src/jsonconf.c | 82 +++++++++++++++++++++++-------------- src/util/xml.c | 7 ++-- 4 files changed, 60 insertions(+), 37 deletions(-) diff --git a/conf/e2/config.json b/conf/e2/config.json index 5d29cd1f5..863a64c0a 100644 --- a/conf/e2/config.json +++ b/conf/e2/config.json @@ -3,7 +3,9 @@ "keywords.json", "calendar.json", "prefixes.json", - "e2/terrains.json" + "e2/terrains.json", + "e2/rules.xml", + "e2/locales.xml" ], "disabled": [ "jsreport" diff --git a/scripts/eressea/xmlconf.lua b/scripts/eressea/xmlconf.lua index 84f29eceb..1b70b0ccd 100644 --- a/scripts/eressea/xmlconf.lua +++ b/scripts/eressea/xmlconf.lua @@ -5,7 +5,7 @@ end if config.rules then local rules = config.rules .. '/' assert(0 == eressea.config.read(rules .. 'config.json', confdir), "could not read JSON data") - assert(0 == read_xml(confdir .. rules .. 'rules.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?") - assert(0 == read_xml(confdir .. rules .. 'locales.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?") +-- assert(0 == read_xml(confdir .. rules .. 'rules.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?") +-- assert(0 == read_xml(confdir .. rules .. 'locales.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?") end eressea.game.reset() diff --git a/src/jsonconf.c b/src/jsonconf.c index 3c5411b9d..15cc563b6 100644 --- a/src/jsonconf.c +++ b/src/jsonconf.c @@ -887,6 +887,53 @@ static void json_races(cJSON *json) { const char * json_relpath; +static void include_json(const char *filename) { + FILE *F; + if (json_relpath) { + char name[PATH_MAX]; + path_join(json_relpath, filename, name, sizeof(name)); + F = fopen(name, "r"); + } + else { + F = fopen(filename, "r"); + } + if (F) { + long pos; + fseek(F, 0, SEEK_END); + pos = ftell(F); + rewind(F); + if (pos > 0) { + cJSON *config; + char *data; + size_t sz; + + data = malloc(pos + 1); + sz = fread(data, 1, (size_t)pos, F); + data[sz] = 0; + config = cJSON_Parse(data); + free(data); + if (config) { + json_config(config); + cJSON_Delete(config); + } + else { + log_error("invalid JSON, could not parse %s", filename); + } + } + fclose(F); + } +} + +static void include_xml(const char *filename) { + char name[PATH_MAX]; + + if (json_relpath) { + path_join(json_relpath, filename, name, sizeof(name)); + filename = name; + } + read_xml(filename, NULL); +} + static void json_include(cJSON *json) { cJSON *child; if (json->type != cJSON_Array) { @@ -894,39 +941,12 @@ static void json_include(cJSON *json) { return; } for (child = json->child; child; child = child->next) { - FILE *F; - if (json_relpath) { - char name[PATH_MAX]; - path_join(json_relpath, child->valuestring, name, sizeof(name)); - F = fopen(name, "r"); + const char * filename = child->valuestring; + if (strstr(filename, ".xml") != NULL) { + include_xml(filename); } else { - F = fopen(child->valuestring, "r"); - } - if (F) { - long pos; - fseek(F, 0, SEEK_END); - pos = ftell(F); - rewind(F); - if (pos > 0) { - cJSON *config; - char *data; - size_t sz; - - data = malloc(pos + 1); - sz = fread(data, 1, (size_t)pos, F); - data[sz] = 0; - config = cJSON_Parse(data); - free(data); - if (config) { - json_config(config); - cJSON_Delete(config); - } - else { - log_error("invalid JSON, could not parse %s", child->valuestring); - } - } - fclose(F); + include_json(filename); } } } diff --git a/src/util/xml.c b/src/util/xml.c index ec72179c3..21480aece 100644 --- a/src/util/xml.c +++ b/src/util/xml.c @@ -112,7 +112,7 @@ int read_xml(const char *filename, const char *catalog) { xml_reader *reader = xmlReaders; xmlDocPtr doc; - int result; + int result = 0; if (catalog) { xmlLoadCatalog(catalog); @@ -122,8 +122,9 @@ int read_xml(const char *filename, const char *catalog) log_error("could not open '%s'\n", filename); return -1; } - - result = xmlXIncludeProcessFlags(doc, XML_PARSE_XINCLUDE | XML_PARSE_NONET | XML_PARSE_PEDANTIC | XML_PARSE_COMPACT); + if (catalog) { + result = xmlXIncludeProcessFlags(doc, XML_PARSE_XINCLUDE | XML_PARSE_NONET | XML_PARSE_PEDANTIC | XML_PARSE_COMPACT); + } if (result >= 0) { while (reader != NULL) { int i = reader->callback(doc); From 6ef8d1af3c4fdae39ecc44985d8354a2c2aa6e6e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 5 Feb 2018 03:44:26 +0100 Subject: [PATCH 2/9] Use custom URI schemes for config files. TODO: XML files need to be rebased, XIncludes replaced. --- conf/e2/config.json | 31 ++++++++++++++++---- conf/e2/rules.xml | 20 +------------ res/core/common/items.xml | 2 ++ scripts/eressea/xmlconf.lua | 11 ++++---- src/jsonconf.c | 56 ++++++++++++++++++++++++------------- 5 files changed, 69 insertions(+), 51 deletions(-) diff --git a/conf/e2/config.json b/conf/e2/config.json index 863a64c0a..beb582a97 100644 --- a/conf/e2/config.json +++ b/conf/e2/config.json @@ -1,11 +1,30 @@ { "include": [ - "keywords.json", - "calendar.json", - "prefixes.json", - "e2/terrains.json", - "e2/rules.xml", - "e2/locales.xml" + "config://keywords.json", + "config://calendar.json", + "config://prefixes.json", + "config://e2/terrains.json", + "config://e2/locales.xml", + "config://e2/rules.xml", + "rules://core/ships.xml", + "rules://core/spoils.xml", + "rules://core/common/buildings.xml", + "rules://core/common/items.xml", + "rules://core/common/resources.xml", + "rules://core/common/luxuries.xml", + "rules://core/common/herbs.xml", + "rules://core/common/potions.xml", + "rules://core/common/armor.xml", + "rules://core/common/weapons.xml", + "rules://eressea/races.xml", + "rules://eressea/artrewards.xml", + "rules://eressea/buildings.xml", + "rules://eressea/familiars.xml", + "rules://eressea/buildings.xml", + "rules://eressea/equipment.xml", + "rules://eressea/items.xml", + "rules://eressea/spells.xml", + "rules://adamantium.xml" ], "disabled": [ "jsreport" diff --git a/conf/e2/rules.xml b/conf/e2/rules.xml index 22ff8109f..9e40910e0 100644 --- a/conf/e2/rules.xml +++ b/conf/e2/rules.xml @@ -1,24 +1,6 @@ - + - - - - - - - - - - - - - - - - - - diff --git a/res/core/common/items.xml b/res/core/common/items.xml index 564e9fafd..d04b6a252 100644 --- a/res/core/common/items.xml +++ b/res/core/common/items.xml @@ -1,4 +1,5 @@ + @@ -133,3 +134,4 @@ + diff --git a/scripts/eressea/xmlconf.lua b/scripts/eressea/xmlconf.lua index 1b70b0ccd..756d3c18a 100644 --- a/scripts/eressea/xmlconf.lua +++ b/scripts/eressea/xmlconf.lua @@ -1,11 +1,10 @@ -local confdir = 'conf/' -if config.install then - confdir = config.install .. '/' .. confdir -end +local rules = 'conf' + if config.rules then - local rules = config.rules .. '/' - assert(0 == eressea.config.read(rules .. 'config.json', confdir), "could not read JSON data") + rules = rules .. '/' .. config.rules + assert(0 == eressea.config.read(rules .. '/config.json', config.install), "could not read JSON data") -- assert(0 == read_xml(confdir .. rules .. 'rules.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?") -- assert(0 == read_xml(confdir .. rules .. 'locales.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?") end + eressea.game.reset() diff --git a/src/jsonconf.c b/src/jsonconf.c index 15cc563b6..56ff2e675 100644 --- a/src/jsonconf.c +++ b/src/jsonconf.c @@ -887,16 +887,32 @@ static void json_races(cJSON *json) { const char * json_relpath; -static void include_json(const char *filename) { +static const char * uri_to_file(const char * uri, char *name, size_t size) { + const char *pos, *path = json_relpath; + + pos = strstr(uri, "://"); + if (pos) { + size_t slen = pos - uri; + /* identify scheme */ + if (strncmp(uri, "config", slen) == 0) { + path = path_join(path, "conf", name, size); + } + else if (strncmp(uri, "rules", slen) == 0) { + path = path_join(path, "res", name, size); + } + if (path) { + return path_join(path, pos + 3, name, size); + } + } + return uri; +} + +static void include_json(const char *uri) { FILE *F; - if (json_relpath) { - char name[PATH_MAX]; - path_join(json_relpath, filename, name, sizeof(name)); - F = fopen(name, "r"); - } - else { - F = fopen(filename, "r"); - } + char name[PATH_MAX]; + const char *filename = uri_to_file(uri, name, sizeof(name)); + + F = fopen(filename, "r"); if (F) { long pos; fseek(F, 0, SEEK_END); @@ -917,21 +933,20 @@ static void include_json(const char *filename) { cJSON_Delete(config); } else { - log_error("invalid JSON, could not parse %s", filename); + log_error("could not parse JSON from %s", uri); } } fclose(F); } } -static void include_xml(const char *filename) { +static void include_xml(const char *uri) { char name[PATH_MAX]; - - if (json_relpath) { - path_join(json_relpath, filename, name, sizeof(name)); - filename = name; + const char *filename = uri_to_file(uri, name, sizeof(name)); + int err = read_xml(filename, NULL); + if (err != 0) { + log_error("could not parse XML from %s", uri); } - read_xml(filename, NULL); } static void json_include(cJSON *json) { @@ -941,12 +956,13 @@ static void json_include(cJSON *json) { return; } for (child = json->child; child; child = child->next) { - const char * filename = child->valuestring; - if (strstr(filename, ".xml") != NULL) { - include_xml(filename); + const char *uri = child->valuestring; + + if (strstr(uri, ".xml") != NULL) { + include_xml(uri); } else { - include_json(filename); + include_json(uri); } } } From 92f82c360852412ea7b348156c1f3d66657256e9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 4 Feb 2018 18:25:38 +0100 Subject: [PATCH 3/9] plan to eliminate xinclude use, move to single config file with includes. --- conf/e2/config.json | 4 +- scripts/eressea/xmlconf.lua | 4 +- src/jsonconf.c | 82 +++++++++++++++++++++++-------------- src/util/xml.c | 7 ++-- 4 files changed, 60 insertions(+), 37 deletions(-) diff --git a/conf/e2/config.json b/conf/e2/config.json index 5d29cd1f5..863a64c0a 100644 --- a/conf/e2/config.json +++ b/conf/e2/config.json @@ -3,7 +3,9 @@ "keywords.json", "calendar.json", "prefixes.json", - "e2/terrains.json" + "e2/terrains.json", + "e2/rules.xml", + "e2/locales.xml" ], "disabled": [ "jsreport" diff --git a/scripts/eressea/xmlconf.lua b/scripts/eressea/xmlconf.lua index 84f29eceb..1b70b0ccd 100644 --- a/scripts/eressea/xmlconf.lua +++ b/scripts/eressea/xmlconf.lua @@ -5,7 +5,7 @@ end if config.rules then local rules = config.rules .. '/' assert(0 == eressea.config.read(rules .. 'config.json', confdir), "could not read JSON data") - assert(0 == read_xml(confdir .. rules .. 'rules.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?") - assert(0 == read_xml(confdir .. rules .. 'locales.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?") +-- assert(0 == read_xml(confdir .. rules .. 'rules.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?") +-- assert(0 == read_xml(confdir .. rules .. 'locales.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?") end eressea.game.reset() diff --git a/src/jsonconf.c b/src/jsonconf.c index 3c5411b9d..15cc563b6 100644 --- a/src/jsonconf.c +++ b/src/jsonconf.c @@ -887,6 +887,53 @@ static void json_races(cJSON *json) { const char * json_relpath; +static void include_json(const char *filename) { + FILE *F; + if (json_relpath) { + char name[PATH_MAX]; + path_join(json_relpath, filename, name, sizeof(name)); + F = fopen(name, "r"); + } + else { + F = fopen(filename, "r"); + } + if (F) { + long pos; + fseek(F, 0, SEEK_END); + pos = ftell(F); + rewind(F); + if (pos > 0) { + cJSON *config; + char *data; + size_t sz; + + data = malloc(pos + 1); + sz = fread(data, 1, (size_t)pos, F); + data[sz] = 0; + config = cJSON_Parse(data); + free(data); + if (config) { + json_config(config); + cJSON_Delete(config); + } + else { + log_error("invalid JSON, could not parse %s", filename); + } + } + fclose(F); + } +} + +static void include_xml(const char *filename) { + char name[PATH_MAX]; + + if (json_relpath) { + path_join(json_relpath, filename, name, sizeof(name)); + filename = name; + } + read_xml(filename, NULL); +} + static void json_include(cJSON *json) { cJSON *child; if (json->type != cJSON_Array) { @@ -894,39 +941,12 @@ static void json_include(cJSON *json) { return; } for (child = json->child; child; child = child->next) { - FILE *F; - if (json_relpath) { - char name[PATH_MAX]; - path_join(json_relpath, child->valuestring, name, sizeof(name)); - F = fopen(name, "r"); + const char * filename = child->valuestring; + if (strstr(filename, ".xml") != NULL) { + include_xml(filename); } else { - F = fopen(child->valuestring, "r"); - } - if (F) { - long pos; - fseek(F, 0, SEEK_END); - pos = ftell(F); - rewind(F); - if (pos > 0) { - cJSON *config; - char *data; - size_t sz; - - data = malloc(pos + 1); - sz = fread(data, 1, (size_t)pos, F); - data[sz] = 0; - config = cJSON_Parse(data); - free(data); - if (config) { - json_config(config); - cJSON_Delete(config); - } - else { - log_error("invalid JSON, could not parse %s", child->valuestring); - } - } - fclose(F); + include_json(filename); } } } diff --git a/src/util/xml.c b/src/util/xml.c index ec72179c3..21480aece 100644 --- a/src/util/xml.c +++ b/src/util/xml.c @@ -112,7 +112,7 @@ int read_xml(const char *filename, const char *catalog) { xml_reader *reader = xmlReaders; xmlDocPtr doc; - int result; + int result = 0; if (catalog) { xmlLoadCatalog(catalog); @@ -122,8 +122,9 @@ int read_xml(const char *filename, const char *catalog) log_error("could not open '%s'\n", filename); return -1; } - - result = xmlXIncludeProcessFlags(doc, XML_PARSE_XINCLUDE | XML_PARSE_NONET | XML_PARSE_PEDANTIC | XML_PARSE_COMPACT); + if (catalog) { + result = xmlXIncludeProcessFlags(doc, XML_PARSE_XINCLUDE | XML_PARSE_NONET | XML_PARSE_PEDANTIC | XML_PARSE_COMPACT); + } if (result >= 0) { while (reader != NULL) { int i = reader->callback(doc); From da02c1b92efaa4af0c36460b2ae6799efbbc349d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 5 Feb 2018 03:44:26 +0100 Subject: [PATCH 4/9] Use custom URI schemes for config files. TODO: XML files need to be rebased, XIncludes replaced. --- conf/e2/config.json | 31 ++++++++++++++++---- conf/e2/rules.xml | 20 +------------ res/core/common/items.xml | 2 ++ scripts/eressea/xmlconf.lua | 11 ++++---- src/jsonconf.c | 56 ++++++++++++++++++++++++------------- 5 files changed, 69 insertions(+), 51 deletions(-) diff --git a/conf/e2/config.json b/conf/e2/config.json index 863a64c0a..beb582a97 100644 --- a/conf/e2/config.json +++ b/conf/e2/config.json @@ -1,11 +1,30 @@ { "include": [ - "keywords.json", - "calendar.json", - "prefixes.json", - "e2/terrains.json", - "e2/rules.xml", - "e2/locales.xml" + "config://keywords.json", + "config://calendar.json", + "config://prefixes.json", + "config://e2/terrains.json", + "config://e2/locales.xml", + "config://e2/rules.xml", + "rules://core/ships.xml", + "rules://core/spoils.xml", + "rules://core/common/buildings.xml", + "rules://core/common/items.xml", + "rules://core/common/resources.xml", + "rules://core/common/luxuries.xml", + "rules://core/common/herbs.xml", + "rules://core/common/potions.xml", + "rules://core/common/armor.xml", + "rules://core/common/weapons.xml", + "rules://eressea/races.xml", + "rules://eressea/artrewards.xml", + "rules://eressea/buildings.xml", + "rules://eressea/familiars.xml", + "rules://eressea/buildings.xml", + "rules://eressea/equipment.xml", + "rules://eressea/items.xml", + "rules://eressea/spells.xml", + "rules://adamantium.xml" ], "disabled": [ "jsreport" diff --git a/conf/e2/rules.xml b/conf/e2/rules.xml index 22ff8109f..9e40910e0 100644 --- a/conf/e2/rules.xml +++ b/conf/e2/rules.xml @@ -1,24 +1,6 @@ - + - - - - - - - - - - - - - - - - - - diff --git a/res/core/common/items.xml b/res/core/common/items.xml index 564e9fafd..d04b6a252 100644 --- a/res/core/common/items.xml +++ b/res/core/common/items.xml @@ -1,4 +1,5 @@ + @@ -133,3 +134,4 @@ + diff --git a/scripts/eressea/xmlconf.lua b/scripts/eressea/xmlconf.lua index 1b70b0ccd..756d3c18a 100644 --- a/scripts/eressea/xmlconf.lua +++ b/scripts/eressea/xmlconf.lua @@ -1,11 +1,10 @@ -local confdir = 'conf/' -if config.install then - confdir = config.install .. '/' .. confdir -end +local rules = 'conf' + if config.rules then - local rules = config.rules .. '/' - assert(0 == eressea.config.read(rules .. 'config.json', confdir), "could not read JSON data") + rules = rules .. '/' .. config.rules + assert(0 == eressea.config.read(rules .. '/config.json', config.install), "could not read JSON data") -- assert(0 == read_xml(confdir .. rules .. 'rules.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?") -- assert(0 == read_xml(confdir .. rules .. 'locales.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?") end + eressea.game.reset() diff --git a/src/jsonconf.c b/src/jsonconf.c index 15cc563b6..56ff2e675 100644 --- a/src/jsonconf.c +++ b/src/jsonconf.c @@ -887,16 +887,32 @@ static void json_races(cJSON *json) { const char * json_relpath; -static void include_json(const char *filename) { +static const char * uri_to_file(const char * uri, char *name, size_t size) { + const char *pos, *path = json_relpath; + + pos = strstr(uri, "://"); + if (pos) { + size_t slen = pos - uri; + /* identify scheme */ + if (strncmp(uri, "config", slen) == 0) { + path = path_join(path, "conf", name, size); + } + else if (strncmp(uri, "rules", slen) == 0) { + path = path_join(path, "res", name, size); + } + if (path) { + return path_join(path, pos + 3, name, size); + } + } + return uri; +} + +static void include_json(const char *uri) { FILE *F; - if (json_relpath) { - char name[PATH_MAX]; - path_join(json_relpath, filename, name, sizeof(name)); - F = fopen(name, "r"); - } - else { - F = fopen(filename, "r"); - } + char name[PATH_MAX]; + const char *filename = uri_to_file(uri, name, sizeof(name)); + + F = fopen(filename, "r"); if (F) { long pos; fseek(F, 0, SEEK_END); @@ -917,21 +933,20 @@ static void include_json(const char *filename) { cJSON_Delete(config); } else { - log_error("invalid JSON, could not parse %s", filename); + log_error("could not parse JSON from %s", uri); } } fclose(F); } } -static void include_xml(const char *filename) { +static void include_xml(const char *uri) { char name[PATH_MAX]; - - if (json_relpath) { - path_join(json_relpath, filename, name, sizeof(name)); - filename = name; + const char *filename = uri_to_file(uri, name, sizeof(name)); + int err = read_xml(filename, NULL); + if (err != 0) { + log_error("could not parse XML from %s", uri); } - read_xml(filename, NULL); } static void json_include(cJSON *json) { @@ -941,12 +956,13 @@ static void json_include(cJSON *json) { return; } for (child = json->child; child; child = child->next) { - const char * filename = child->valuestring; - if (strstr(filename, ".xml") != NULL) { - include_xml(filename); + const char *uri = child->valuestring; + + if (strstr(uri, ".xml") != NULL) { + include_xml(uri); } else { - include_json(filename); + include_json(uri); } } } From 434b7ae29e6bbf7b0bce2a0787df753510d90974 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 5 Feb 2018 19:35:15 +0100 Subject: [PATCH 5/9] convert all of E2 to new config loading. --- conf/e2/config.json | 48 +++++++++++++-------------- conf/e2/items.json | 49 ++++++++++++++++++++++++++++ conf/e2/locales.json | 14 ++++++++ conf/e2/locales.xml | 13 -------- res/adamantium.xml | 2 ++ res/buildings/castle-2.xml | 2 ++ res/buildings/castle.xml | 4 +++ res/core/armor/chainmail.xml | 2 ++ res/core/armor/laenmail.xml | 2 ++ res/core/armor/laenshield.xml | 2 ++ res/core/armor/plate.xml | 2 ++ res/core/armor/rustychainmail.xml | 3 +- res/core/armor/rustyshield.xml | 2 ++ res/core/armor/shield.xml | 2 ++ res/core/common/armor.xml | 10 ------ res/core/common/buildings.xml | 3 +- res/core/common/construction.xml | 10 ------ res/core/common/herbs.xml | 2 ++ res/core/common/luxuries.xml | 2 ++ res/core/common/potions.xml | 2 ++ res/core/common/resources.xml | 19 ----------- res/core/common/weapons.xml | 24 -------------- res/core/resources/cart.xml | 4 +++ res/core/resources/horse.xml | 4 +++ res/core/resources/hp.xml | 4 +++ res/core/resources/iron.xml | 4 +++ res/core/resources/laen.xml | 4 +++ res/core/resources/log.xml | 4 +++ res/core/resources/mallorn.xml | 4 +++ res/core/resources/mallornseed.xml | 4 +++ res/core/resources/peasant.xml | 4 +++ res/core/resources/seed.xml | 4 +++ res/core/resources/stone.xml | 4 +++ res/core/ships.xml | 3 +- res/core/spoils.xml | 2 ++ res/core/weapons/axe.xml | 4 +++ res/core/weapons/bow.xml | 4 +++ res/core/weapons/catapult.xml | 4 +++ res/core/weapons/crossbow.xml | 4 +++ res/core/weapons/firesword.xml | 4 +++ res/core/weapons/greatbow.xml | 4 +++ res/core/weapons/greatsword.xml | 4 +++ res/core/weapons/halberd.xml | 4 +++ res/core/weapons/laensword.xml | 4 +++ res/core/weapons/lance.xml | 4 +++ res/core/weapons/mallornbow.xml | 4 +++ res/core/weapons/mallorncrossbow.xml | 4 +++ res/core/weapons/mallornlance.xml | 4 +++ res/core/weapons/mallornspear.xml | 4 +++ res/core/weapons/runesword.xml | 4 +++ res/core/weapons/rustyaxe.xml | 4 +++ res/core/weapons/rustygreatsword.xml | 4 +++ res/core/weapons/rustyhalberd.xml | 4 +++ res/core/weapons/rustysword.xml | 4 +++ res/core/weapons/spear.xml | 4 +++ res/core/weapons/sword.xml | 4 +++ res/eressea/artrewards.xml | 4 +-- res/eressea/buildings.xml | 3 +- res/eressea/equipment.xml | 4 ++- res/eressea/familiars.xml | 3 +- res/eressea/items.xml | 2 ++ res/eressea/races.xml | 2 ++ res/eressea/spells.xml | 12 +++---- src/jsonconf.c | 47 ++++++++++++++++++-------- 64 files changed, 299 insertions(+), 130 deletions(-) create mode 100644 conf/e2/items.json create mode 100644 conf/e2/locales.json delete mode 100644 conf/e2/locales.xml delete mode 100644 res/core/common/armor.xml delete mode 100644 res/core/common/construction.xml delete mode 100644 res/core/common/resources.xml delete mode 100644 res/core/common/weapons.xml diff --git a/conf/e2/config.json b/conf/e2/config.json index beb582a97..c2514706a 100644 --- a/conf/e2/config.json +++ b/conf/e2/config.json @@ -1,30 +1,28 @@ { "include": [ - "config://keywords.json", - "config://calendar.json", - "config://prefixes.json", - "config://e2/terrains.json", - "config://e2/locales.xml", - "config://e2/rules.xml", - "rules://core/ships.xml", - "rules://core/spoils.xml", - "rules://core/common/buildings.xml", - "rules://core/common/items.xml", - "rules://core/common/resources.xml", - "rules://core/common/luxuries.xml", - "rules://core/common/herbs.xml", - "rules://core/common/potions.xml", - "rules://core/common/armor.xml", - "rules://core/common/weapons.xml", - "rules://eressea/races.xml", - "rules://eressea/artrewards.xml", - "rules://eressea/buildings.xml", - "rules://eressea/familiars.xml", - "rules://eressea/buildings.xml", - "rules://eressea/equipment.xml", - "rules://eressea/items.xml", - "rules://eressea/spells.xml", - "rules://adamantium.xml" + "config://conf/keywords.json", + "config://conf/calendar.json", + "config://conf/prefixes.json", + "config://conf/e2/terrains.json", + "config://conf/e2/items.json", + "config://conf/e2/locales.json", + "config://conf/e2/rules.xml", + "config://res/core/ships.xml", + "config://res/core/spoils.xml", + "config://res/core/common/buildings.xml", + "config://res/eressea/buildings.xml", + "config://res/buildings/castle.xml", + "config://res/eressea/races.xml", + "config://res/eressea/artrewards.xml", + "config://res/eressea/familiars.xml", + "config://res/eressea/equipment.xml", + "config://res/eressea/spells.xml", + "config://res/eressea/spellbooks/gray.xml", + "config://res/eressea/spellbooks/gwyrrd.xml", + "config://res/eressea/spellbooks/draig.xml", + "config://res/eressea/spellbooks/illaun.xml", + "config://res/eressea/spellbooks/cerddor.xml", + "config://res/eressea/spellbooks/tybied.xml" ], "disabled": [ "jsreport" diff --git a/conf/e2/items.json b/conf/e2/items.json new file mode 100644 index 000000000..dc4664cdc --- /dev/null +++ b/conf/e2/items.json @@ -0,0 +1,49 @@ +{ + "include": [ + "config://res/core/common/items.xml", + "config://res/core/armor/chainmail.xml", + "config://res/core/armor/laenmail.xml", + "config://res/core/armor/laenshield.xml", + "config://res/core/armor/plate.xml", + "config://res/core/armor/rustychainmail.xml", + "config://res/core/armor/rustyshield.xml", + "config://res/core/armor/shield.xml", + "config://res/core/resources/cart.xml", + "config://res/core/resources/horse.xml", + "config://res/core/resources/hp.xml", + "config://res/core/resources/iron.xml", + "config://res/core/resources/laen.xml", + "config://res/core/resources/log.xml", + "config://res/core/resources/mallorn.xml", + "config://res/core/resources/mallornseed.xml", + "config://res/core/resources/seed.xml", + "config://res/core/resources/peasant.xml", + "config://res/core/resources/stone.xml", + "config://res/core/common/luxuries.xml", + "config://res/core/common/herbs.xml", + "config://res/core/common/potions.xml", + "config://res/core/weapons/axe.xml", + "config://res/core/weapons/bow.xml", + "config://res/core/weapons/catapult.xml", + "config://res/core/weapons/crossbow.xml", + "config://res/core/weapons/firesword.xml", + "config://res/core/weapons/greatbow.xml", + "config://res/core/weapons/greatsword.xml", + "config://res/core/weapons/halberd.xml", + "config://res/core/weapons/laensword.xml", + "config://res/core/weapons/lance.xml", + "config://res/core/weapons/mallornbow.xml", + "config://res/core/weapons/mallorncrossbow.xml", + "config://res/core/weapons/mallornlance.xml", + "config://res/core/weapons/mallornspear.xml", + "config://res/core/weapons/runesword.xml", + "config://res/core/weapons/rustyaxe.xml", + "config://res/core/weapons/rustygreatsword.xml", + "config://res/core/weapons/rustyhalberd.xml", + "config://res/core/weapons/rustysword.xml", + "config://res/core/weapons/spear.xml", + "config://res/core/weapons/sword.xml", + "config://res/eressea/items.xml", + "config://res/adamantium.xml" + ] +} diff --git a/conf/e2/locales.json b/conf/e2/locales.json new file mode 100644 index 000000000..4a3a100ef --- /dev/null +++ b/conf/e2/locales.json @@ -0,0 +1,14 @@ +{ + "include": [ + "config://res/core/messages.xml", + "config://res/core/de/strings.xml", + "config://res/core/en/strings.xml", + "config://res/eressea/strings.xml", + "config://res/eressea/spellinfo.xml", + "config://res/names-undead.xml", + "config://res/names-skeletons.xml", + "config://res/names-zombies.xml", + "config://res/names-ghouls.xml", + "config://res/names-dragons.xml" + ] +} diff --git a/conf/e2/locales.xml b/conf/e2/locales.xml deleted file mode 100644 index 7a31bbc17..000000000 --- a/conf/e2/locales.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/res/adamantium.xml b/res/adamantium.xml index e1f0643e2..563299e51 100644 --- a/res/adamantium.xml +++ b/res/adamantium.xml @@ -1,4 +1,5 @@ + @@ -32,3 +33,4 @@ + diff --git a/res/buildings/castle-2.xml b/res/buildings/castle-2.xml index accb92c08..8117524ff 100644 --- a/res/buildings/castle-2.xml +++ b/res/buildings/castle-2.xml @@ -1,4 +1,5 @@ + @@ -19,3 +20,4 @@ + diff --git a/res/buildings/castle.xml b/res/buildings/castle.xml index ce64e8030..14d959ed7 100644 --- a/res/buildings/castle.xml +++ b/res/buildings/castle.xml @@ -1,4 +1,6 @@ + + @@ -22,3 +24,5 @@ + + diff --git a/res/core/armor/chainmail.xml b/res/core/armor/chainmail.xml index b03221b35..048a94ae9 100644 --- a/res/core/armor/chainmail.xml +++ b/res/core/armor/chainmail.xml @@ -1,4 +1,5 @@ + @@ -7,3 +8,4 @@ + diff --git a/res/core/armor/laenmail.xml b/res/core/armor/laenmail.xml index 0e1411945..f26e5363b 100644 --- a/res/core/armor/laenmail.xml +++ b/res/core/armor/laenmail.xml @@ -1,4 +1,5 @@ + @@ -7,3 +8,4 @@ + diff --git a/res/core/armor/laenshield.xml b/res/core/armor/laenshield.xml index 8a9d6d5c3..03f9f479a 100644 --- a/res/core/armor/laenshield.xml +++ b/res/core/armor/laenshield.xml @@ -1,4 +1,5 @@ + @@ -7,3 +8,4 @@ + diff --git a/res/core/armor/plate.xml b/res/core/armor/plate.xml index 97d855a73..f43a704b8 100644 --- a/res/core/armor/plate.xml +++ b/res/core/armor/plate.xml @@ -1,4 +1,5 @@ + @@ -7,3 +8,4 @@ + diff --git a/res/core/armor/rustychainmail.xml b/res/core/armor/rustychainmail.xml index b46380634..f7947bbb1 100644 --- a/res/core/armor/rustychainmail.xml +++ b/res/core/armor/rustychainmail.xml @@ -1,4 +1,5 @@ + @@ -7,4 +8,4 @@ - + diff --git a/res/core/armor/rustyshield.xml b/res/core/armor/rustyshield.xml index 56a8abe5a..218b4fa6a 100644 --- a/res/core/armor/rustyshield.xml +++ b/res/core/armor/rustyshield.xml @@ -1,4 +1,5 @@ + @@ -7,3 +8,4 @@ + diff --git a/res/core/armor/shield.xml b/res/core/armor/shield.xml index b0ee7de3a..af099dc2e 100644 --- a/res/core/armor/shield.xml +++ b/res/core/armor/shield.xml @@ -1,4 +1,5 @@ + @@ -7,3 +8,4 @@ + diff --git a/res/core/common/armor.xml b/res/core/common/armor.xml deleted file mode 100644 index 58abae47f..000000000 --- a/res/core/common/armor.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/res/core/common/buildings.xml b/res/core/common/buildings.xml index 932326f1c..3b8719b3b 100644 --- a/res/core/common/buildings.xml +++ b/res/core/common/buildings.xml @@ -1,4 +1,5 @@ + @@ -167,4 +168,4 @@ - + diff --git a/res/core/common/construction.xml b/res/core/common/construction.xml deleted file mode 100644 index 089ddfe1c..000000000 --- a/res/core/common/construction.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/res/core/common/herbs.xml b/res/core/common/herbs.xml index d7d0ef2e6..9175b4a42 100644 --- a/res/core/common/herbs.xml +++ b/res/core/common/herbs.xml @@ -1,4 +1,5 @@  + @@ -87,3 +88,4 @@ + diff --git a/res/core/common/luxuries.xml b/res/core/common/luxuries.xml index bdf9c110b..05e125b33 100644 --- a/res/core/common/luxuries.xml +++ b/res/core/common/luxuries.xml @@ -1,4 +1,5 @@ + @@ -24,3 +25,4 @@ + diff --git a/res/core/common/potions.xml b/res/core/common/potions.xml index 4812727dd..bb4556eb7 100644 --- a/res/core/common/potions.xml +++ b/res/core/common/potions.xml @@ -1,4 +1,5 @@ + @@ -180,3 +181,4 @@ + diff --git a/res/core/common/resources.xml b/res/core/common/resources.xml deleted file mode 100644 index 91d0e8afc..000000000 --- a/res/core/common/resources.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/res/core/common/weapons.xml b/res/core/common/weapons.xml deleted file mode 100644 index e91b15e69..000000000 --- a/res/core/common/weapons.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/res/core/resources/cart.xml b/res/core/resources/cart.xml index 17dbdcb41..c98e202b0 100644 --- a/res/core/resources/cart.xml +++ b/res/core/resources/cart.xml @@ -1,4 +1,6 @@ + + @@ -6,3 +8,5 @@ + + diff --git a/res/core/resources/horse.xml b/res/core/resources/horse.xml index 608fca20a..6021692e0 100644 --- a/res/core/resources/horse.xml +++ b/res/core/resources/horse.xml @@ -1,6 +1,10 @@ + + + + diff --git a/res/core/resources/hp.xml b/res/core/resources/hp.xml index aa0ad4d29..5d038e7b2 100644 --- a/res/core/resources/hp.xml +++ b/res/core/resources/hp.xml @@ -1,4 +1,8 @@ + + + + diff --git a/res/core/resources/iron.xml b/res/core/resources/iron.xml index 1aff826fc..38ddb33c8 100644 --- a/res/core/resources/iron.xml +++ b/res/core/resources/iron.xml @@ -1,4 +1,6 @@ + + @@ -8,3 +10,5 @@ + + diff --git a/res/core/resources/laen.xml b/res/core/resources/laen.xml index e584fe485..1c14c2eff 100644 --- a/res/core/resources/laen.xml +++ b/res/core/resources/laen.xml @@ -1,4 +1,6 @@ + + @@ -6,3 +8,5 @@ + + diff --git a/res/core/resources/log.xml b/res/core/resources/log.xml index e3710d496..5720c2fd4 100644 --- a/res/core/resources/log.xml +++ b/res/core/resources/log.xml @@ -1,4 +1,6 @@ + + @@ -6,3 +8,5 @@ + + diff --git a/res/core/resources/mallorn.xml b/res/core/resources/mallorn.xml index 3dff091c6..8e50785ca 100644 --- a/res/core/resources/mallorn.xml +++ b/res/core/resources/mallorn.xml @@ -1,4 +1,6 @@ + + @@ -6,3 +8,5 @@ + + diff --git a/res/core/resources/mallornseed.xml b/res/core/resources/mallornseed.xml index 7a5a0310f..7a50c1233 100644 --- a/res/core/resources/mallornseed.xml +++ b/res/core/resources/mallornseed.xml @@ -1,6 +1,10 @@ + + + + diff --git a/res/core/resources/peasant.xml b/res/core/resources/peasant.xml index bce23430c..8c5b22c19 100644 --- a/res/core/resources/peasant.xml +++ b/res/core/resources/peasant.xml @@ -1,4 +1,8 @@ + + + + diff --git a/res/core/resources/seed.xml b/res/core/resources/seed.xml index 99f5f5804..6696b761f 100644 --- a/res/core/resources/seed.xml +++ b/res/core/resources/seed.xml @@ -1,6 +1,10 @@ + + + + diff --git a/res/core/resources/stone.xml b/res/core/resources/stone.xml index e1c5651ed..b8f91eadc 100644 --- a/res/core/resources/stone.xml +++ b/res/core/resources/stone.xml @@ -1,4 +1,6 @@ + + @@ -7,3 +9,5 @@ + + diff --git a/res/core/ships.xml b/res/core/ships.xml index 33d0dc52a..d26975285 100644 --- a/res/core/ships.xml +++ b/res/core/ships.xml @@ -1,4 +1,5 @@ + @@ -73,4 +74,4 @@ - + diff --git a/res/core/spoils.xml b/res/core/spoils.xml index 952971cab..8cd39a455 100644 --- a/res/core/spoils.xml +++ b/res/core/spoils.xml @@ -1,4 +1,5 @@ + @@ -57,3 +58,4 @@ + diff --git a/res/core/weapons/axe.xml b/res/core/weapons/axe.xml index 3f97a5b8a..07f511a62 100644 --- a/res/core/weapons/axe.xml +++ b/res/core/weapons/axe.xml @@ -1,4 +1,6 @@ + + @@ -11,3 +13,5 @@ + + diff --git a/res/core/weapons/bow.xml b/res/core/weapons/bow.xml index 4fb9b2000..a62f90b58 100644 --- a/res/core/weapons/bow.xml +++ b/res/core/weapons/bow.xml @@ -1,4 +1,6 @@ + + @@ -11,3 +13,5 @@ + + diff --git a/res/core/weapons/catapult.xml b/res/core/weapons/catapult.xml index e05c5a025..6312dd4d6 100644 --- a/res/core/weapons/catapult.xml +++ b/res/core/weapons/catapult.xml @@ -1,4 +1,6 @@ + + @@ -12,3 +14,5 @@ + + diff --git a/res/core/weapons/crossbow.xml b/res/core/weapons/crossbow.xml index c7bf4715d..c048e3dcd 100644 --- a/res/core/weapons/crossbow.xml +++ b/res/core/weapons/crossbow.xml @@ -1,4 +1,6 @@ + + @@ -11,3 +13,5 @@ + + diff --git a/res/core/weapons/firesword.xml b/res/core/weapons/firesword.xml index d716e6013..dc3b47af5 100644 --- a/res/core/weapons/firesword.xml +++ b/res/core/weapons/firesword.xml @@ -1,4 +1,6 @@ + + @@ -8,3 +10,5 @@ + + diff --git a/res/core/weapons/greatbow.xml b/res/core/weapons/greatbow.xml index 452ac0250..b30cae8c6 100644 --- a/res/core/weapons/greatbow.xml +++ b/res/core/weapons/greatbow.xml @@ -1,4 +1,6 @@ + + @@ -15,3 +17,5 @@ + + diff --git a/res/core/weapons/greatsword.xml b/res/core/weapons/greatsword.xml index 56285f6af..af2420700 100644 --- a/res/core/weapons/greatsword.xml +++ b/res/core/weapons/greatsword.xml @@ -1,4 +1,6 @@ + + @@ -10,3 +12,5 @@ + + diff --git a/res/core/weapons/halberd.xml b/res/core/weapons/halberd.xml index 7abc86902..8475d53e1 100644 --- a/res/core/weapons/halberd.xml +++ b/res/core/weapons/halberd.xml @@ -1,4 +1,6 @@ + + @@ -12,3 +14,5 @@ + + diff --git a/res/core/weapons/laensword.xml b/res/core/weapons/laensword.xml index 3053d5f1b..325d25d10 100644 --- a/res/core/weapons/laensword.xml +++ b/res/core/weapons/laensword.xml @@ -1,4 +1,6 @@ + + @@ -10,3 +12,5 @@ + + diff --git a/res/core/weapons/lance.xml b/res/core/weapons/lance.xml index 4a02bc06f..9325494fa 100644 --- a/res/core/weapons/lance.xml +++ b/res/core/weapons/lance.xml @@ -1,4 +1,6 @@ + + @@ -10,3 +12,5 @@ + + diff --git a/res/core/weapons/mallornbow.xml b/res/core/weapons/mallornbow.xml index abdcc4810..9164d2c4b 100644 --- a/res/core/weapons/mallornbow.xml +++ b/res/core/weapons/mallornbow.xml @@ -1,4 +1,6 @@ + + @@ -14,3 +16,5 @@ + + diff --git a/res/core/weapons/mallorncrossbow.xml b/res/core/weapons/mallorncrossbow.xml index 385720d8c..e5ec685c0 100644 --- a/res/core/weapons/mallorncrossbow.xml +++ b/res/core/weapons/mallorncrossbow.xml @@ -1,4 +1,6 @@ + + @@ -11,3 +13,5 @@ + + diff --git a/res/core/weapons/mallornlance.xml b/res/core/weapons/mallornlance.xml index 4024d4578..952839fda 100644 --- a/res/core/weapons/mallornlance.xml +++ b/res/core/weapons/mallornlance.xml @@ -1,4 +1,6 @@ + + @@ -10,3 +12,5 @@ + + diff --git a/res/core/weapons/mallornspear.xml b/res/core/weapons/mallornspear.xml index 516f59540..ee827c754 100644 --- a/res/core/weapons/mallornspear.xml +++ b/res/core/weapons/mallornspear.xml @@ -1,4 +1,6 @@ + + @@ -12,3 +14,5 @@ + + diff --git a/res/core/weapons/runesword.xml b/res/core/weapons/runesword.xml index 1bfae2544..6f23697f2 100644 --- a/res/core/weapons/runesword.xml +++ b/res/core/weapons/runesword.xml @@ -1,4 +1,6 @@ + + @@ -8,3 +10,5 @@ + + diff --git a/res/core/weapons/rustyaxe.xml b/res/core/weapons/rustyaxe.xml index fea6b8642..ff4172059 100644 --- a/res/core/weapons/rustyaxe.xml +++ b/res/core/weapons/rustyaxe.xml @@ -1,4 +1,6 @@ + + @@ -11,3 +13,5 @@ + + diff --git a/res/core/weapons/rustygreatsword.xml b/res/core/weapons/rustygreatsword.xml index 7f21cce17..b67e2cf4b 100644 --- a/res/core/weapons/rustygreatsword.xml +++ b/res/core/weapons/rustygreatsword.xml @@ -1,4 +1,6 @@ + + @@ -10,3 +12,5 @@ + + diff --git a/res/core/weapons/rustyhalberd.xml b/res/core/weapons/rustyhalberd.xml index 3f0bd93b7..9d3c4ae6b 100644 --- a/res/core/weapons/rustyhalberd.xml +++ b/res/core/weapons/rustyhalberd.xml @@ -1,4 +1,6 @@ + + @@ -12,3 +14,5 @@ + + diff --git a/res/core/weapons/rustysword.xml b/res/core/weapons/rustysword.xml index 2a76c109b..e5c9a9442 100644 --- a/res/core/weapons/rustysword.xml +++ b/res/core/weapons/rustysword.xml @@ -1,4 +1,6 @@ + + @@ -10,3 +12,5 @@ + + diff --git a/res/core/weapons/spear.xml b/res/core/weapons/spear.xml index 32a79b9a2..e81f608ab 100644 --- a/res/core/weapons/spear.xml +++ b/res/core/weapons/spear.xml @@ -1,4 +1,6 @@ + + @@ -12,3 +14,5 @@ + + diff --git a/res/core/weapons/sword.xml b/res/core/weapons/sword.xml index 4bd2ebdb1..21b481079 100644 --- a/res/core/weapons/sword.xml +++ b/res/core/weapons/sword.xml @@ -1,4 +1,6 @@ + + @@ -10,3 +12,5 @@ + + diff --git a/res/eressea/artrewards.xml b/res/eressea/artrewards.xml index b18fd5b20..9a144da07 100644 --- a/res/eressea/artrewards.xml +++ b/res/eressea/artrewards.xml @@ -1,5 +1,5 @@ - + @@ -11,4 +11,4 @@ - + diff --git a/res/eressea/buildings.xml b/res/eressea/buildings.xml index 1559fd987..b3ab4b6c0 100644 --- a/res/eressea/buildings.xml +++ b/res/eressea/buildings.xml @@ -1,8 +1,9 @@ + - + diff --git a/res/eressea/equipment.xml b/res/eressea/equipment.xml index e4d48aefe..94d0deb07 100644 --- a/res/eressea/equipment.xml +++ b/res/eressea/equipment.xml @@ -1,5 +1,5 @@ - + @@ -271,3 +271,5 @@ + + diff --git a/res/eressea/familiars.xml b/res/eressea/familiars.xml index 7e9bb75dc..112a82420 100644 --- a/res/eressea/familiars.xml +++ b/res/eressea/familiars.xml @@ -1,4 +1,5 @@ + @@ -129,4 +130,4 @@ - + diff --git a/res/eressea/items.xml b/res/eressea/items.xml index 3f5cc3d17..2cfa9e653 100644 --- a/res/eressea/items.xml +++ b/res/eressea/items.xml @@ -1,4 +1,5 @@ + @@ -128,3 +129,4 @@ + diff --git a/res/eressea/races.xml b/res/eressea/races.xml index cdd483851..654a859bd 100644 --- a/res/eressea/races.xml +++ b/res/eressea/races.xml @@ -1,4 +1,5 @@ + + diff --git a/res/eressea/spells.xml b/res/eressea/spells.xml index 6b2e43a15..089ec1a6c 100644 --- a/res/eressea/spells.xml +++ b/res/eressea/spells.xml @@ -1,12 +1,6 @@ - - - - - - - - + + @@ -616,3 +610,5 @@ + + diff --git a/src/jsonconf.c b/src/jsonconf.c index 56ff2e675..2fff42b83 100644 --- a/src/jsonconf.c +++ b/src/jsonconf.c @@ -887,24 +887,45 @@ static void json_races(cJSON *json) { const char * json_relpath; -static const char * uri_to_file(const char * uri, char *name, size_t size) { - const char *pos, *path = json_relpath; +/* TODO: much more configurable authority-to-file lookup */ +static const char * authority_to_path(const char *authority, char *name, size_t size) { + /* source and destination cannot share the same buffer */ + assert(authority < name || authority > name + size); - pos = strstr(uri, "://"); + return join_path(json_relpath, authority, name, size); +} + +static const char * uri_to_file(const char * uri, char *name, size_t size) { + const char *pos, *scheme, *path = uri; + + /* source and destination cannot share the same buffer */ + assert(uri < name || uri > name + size); + + /* identify scheme */ + scheme = uri; + pos = strstr(scheme, "://"); if (pos) { - size_t slen = pos - uri; - /* identify scheme */ - if (strncmp(uri, "config", slen) == 0) { - path = path_join(path, "conf", name, size); + size_t slen = pos - scheme; + if (strncmp(scheme, "config", slen) == 0) { + const char *authority = pos + 3; + /* authority */ + pos = strstr(authority, "/"); + if (pos) { + char buffer[16]; + size_t alen = pos - authority; + assert(alen < sizeof(buffer)); + memcpy(buffer, authority, alen); + buffer[alen] = 0; + + path = authority_to_path(buffer, name, size); + path = path_join(path, pos + 1, name, size); + } } - else if (strncmp(uri, "rules", slen) == 0) { - path = path_join(path, "res", name, size); - } - if (path) { - return path_join(path, pos + 3, name, size); + else { + log_fatal("unknown URI scheme: %s", uri); } } - return uri; + return path; } static void include_json(const char *uri) { From df255b886aed78bab86fbe46109d9b7886e6a466 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 6 Feb 2018 18:46:28 +0100 Subject: [PATCH 6/9] verify xml loading, fix remaining files for e2. --- res/core/de/strings.xml | 2 + res/core/en/strings.xml | 2 + res/core/messages.xml | 31 +- res/eressea/spellbooks/cerddor.xml | 2 + res/eressea/spellbooks/draig.xml | 2 + res/eressea/spellbooks/gray.xml | 2 + res/eressea/spellbooks/gwyrrd.xml | 2 + res/eressea/spellbooks/illaun.xml | 3 +- res/eressea/spellbooks/tybied.xml | 2 + res/eressea/spellinfo.xml | 2 + res/eressea/strings.xml | 2 + res/names-dragons.xml | 4 +- res/names-ghouls.xml | 3 +- res/names-skeletons.xml | 4 +- res/names-undead.xml | 2 + res/names-zombies.xml | 2 + scripts/run-tests-e2.lua | 7 + scripts/run-tests-e3.lua | 7 + src/bindings.c | 7 +- src/convert.c | 2 +- src/jsonconf.c | 19 +- src/laws.c | 5 + src/util/xml.c | 29 +- src/util/xml.h | 2 +- src/xmlreader.c | 616 +++++++++++++++-------------- 25 files changed, 397 insertions(+), 364 deletions(-) diff --git a/res/core/de/strings.xml b/res/core/de/strings.xml index 6801cbb35..896a7e009 100644 --- a/res/core/de/strings.xml +++ b/res/core/de/strings.xml @@ -1,4 +1,5 @@ + diff --git a/res/e3a/armor.xml b/res/e3a/armor.xml index fe1d7fb45..d0d5138ef 100644 --- a/res/e3a/armor.xml +++ b/res/e3a/armor.xml @@ -1,12 +1,83 @@ - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/res/e3a/armor/chainmail.xml b/res/e3a/armor/chainmail.xml deleted file mode 100644 index 509df07e6..000000000 --- a/res/e3a/armor/chainmail.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/res/e3a/armor/laenmail.xml b/res/e3a/armor/laenmail.xml deleted file mode 100644 index f03add574..000000000 --- a/res/e3a/armor/laenmail.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/res/e3a/armor/laenshield.xml b/res/e3a/armor/laenshield.xml deleted file mode 100644 index 8d003bccc..000000000 --- a/res/e3a/armor/laenshield.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/res/e3a/armor/plate.xml b/res/e3a/armor/plate.xml deleted file mode 100644 index 79391fbcb..000000000 --- a/res/e3a/armor/plate.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/res/e3a/armor/rustychainmail.xml b/res/e3a/armor/rustychainmail.xml deleted file mode 100644 index 361564c76..000000000 --- a/res/e3a/armor/rustychainmail.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/res/e3a/armor/rustyshield.xml b/res/e3a/armor/rustyshield.xml deleted file mode 100644 index d9d8a54ef..000000000 --- a/res/e3a/armor/rustyshield.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/res/e3a/armor/scale.xml b/res/e3a/armor/scale.xml deleted file mode 100644 index 4d3e38e8a..000000000 --- a/res/e3a/armor/scale.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/res/e3a/armor/shield.xml b/res/e3a/armor/shield.xml deleted file mode 100644 index 5770711e2..000000000 --- a/res/e3a/armor/shield.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/res/e3a/armor/towershield.xml b/res/e3a/armor/towershield.xml deleted file mode 100644 index aebbfc682..000000000 --- a/res/e3a/armor/towershield.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/res/e3a/buildings.xml b/res/e3a/buildings.xml index 069a24150..6d3db765e 100644 --- a/res/e3a/buildings.xml +++ b/res/e3a/buildings.xml @@ -1,7 +1,6 @@ - - - + + @@ -24,4 +23,4 @@ - + diff --git a/res/e3a/equipment.xml b/res/e3a/equipment.xml index 62123766a..d8c529d8a 100644 --- a/res/e3a/equipment.xml +++ b/res/e3a/equipment.xml @@ -1,4 +1,5 @@ + @@ -7,3 +8,4 @@ + diff --git a/res/e3a/familiars.xml b/res/e3a/familiars.xml index 4a9fad6c8..b30c733ed 100644 --- a/res/e3a/familiars.xml +++ b/res/e3a/familiars.xml @@ -1,4 +1,5 @@ + @@ -101,4 +102,4 @@ - + diff --git a/res/e3a/items.xml b/res/e3a/items.xml index 0399043e5..1d403cfb4 100644 --- a/res/e3a/items.xml +++ b/res/e3a/items.xml @@ -1,6 +1,32 @@  + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -76,3 +102,4 @@ + diff --git a/res/e3a/races.xml b/res/e3a/races.xml index ce0ce336a..feefb0ded 100644 --- a/res/e3a/races.xml +++ b/res/e3a/races.xml @@ -1,13 +1,9 @@ - + + - - - - - @@ -846,3 +842,4 @@ + diff --git a/res/e3a/resources.xml b/res/e3a/resources.xml deleted file mode 100644 index 32a79d52e..000000000 --- a/res/e3a/resources.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/res/e3a/resources/iron.xml b/res/e3a/resources/iron.xml deleted file mode 100644 index 55f63ca67..000000000 --- a/res/e3a/resources/iron.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/res/e3a/resources/mallornseed.xml b/res/e3a/resources/mallornseed.xml deleted file mode 100644 index 576035b34..000000000 --- a/res/e3a/resources/mallornseed.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/res/e3a/resources/seed.xml b/res/e3a/resources/seed.xml deleted file mode 100644 index 62c971540..000000000 --- a/res/e3a/resources/seed.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/res/e3a/resources/stone.xml b/res/e3a/resources/stone.xml deleted file mode 100644 index d8fd08573..000000000 --- a/res/e3a/resources/stone.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/res/e3a/shipnames.xml b/res/e3a/shipnames.xml index 15e261ef0..6d5c46b05 100644 --- a/res/e3a/shipnames.xml +++ b/res/e3a/shipnames.xml @@ -1,4 +1,5 @@  + ein Einbaum @@ -106,3 +107,4 @@ trireme + diff --git a/res/e3a/ships.xml b/res/e3a/ships.xml index 291900a3b..454c99169 100644 --- a/res/e3a/ships.xml +++ b/res/e3a/ships.xml @@ -1,4 +1,5 @@ + @@ -143,4 +144,4 @@ - + diff --git a/res/e3a/spellbooks/cerddor.xml b/res/e3a/spellbooks/cerddor.xml index 9b6e4cd8e..9e1a3f835 100644 --- a/res/e3a/spellbooks/cerddor.xml +++ b/res/e3a/spellbooks/cerddor.xml @@ -1,4 +1,5 @@ + @@ -35,3 +36,4 @@ + diff --git a/res/e3a/spellbooks/common.xml b/res/e3a/spellbooks/common.xml index 688a1b9ae..92f54e1d1 100644 --- a/res/e3a/spellbooks/common.xml +++ b/res/e3a/spellbooks/common.xml @@ -1,4 +1,5 @@ + @@ -42,3 +43,4 @@ + diff --git a/res/e3a/spellbooks/draig.xml b/res/e3a/spellbooks/draig.xml index d97a695b3..a0da7b449 100644 --- a/res/e3a/spellbooks/draig.xml +++ b/res/e3a/spellbooks/draig.xml @@ -1,4 +1,5 @@ + @@ -31,3 +32,4 @@ + diff --git a/res/e3a/spellbooks/gray.xml b/res/e3a/spellbooks/gray.xml index 78645f907..a807963c2 100644 --- a/res/e3a/spellbooks/gray.xml +++ b/res/e3a/spellbooks/gray.xml @@ -1,4 +1,5 @@ + @@ -142,3 +143,4 @@ + diff --git a/res/e3a/spellbooks/gwyrrd.xml b/res/e3a/spellbooks/gwyrrd.xml index 452100ace..83fd4e99c 100644 --- a/res/e3a/spellbooks/gwyrrd.xml +++ b/res/e3a/spellbooks/gwyrrd.xml @@ -1,4 +1,5 @@ + @@ -32,3 +33,4 @@ + diff --git a/res/e3a/spellbooks/illaun.xml b/res/e3a/spellbooks/illaun.xml index 6b89df8fa..02c9b34d8 100644 --- a/res/e3a/spellbooks/illaun.xml +++ b/res/e3a/spellbooks/illaun.xml @@ -1,4 +1,5 @@ + @@ -32,3 +33,4 @@ + diff --git a/res/e3a/spells.xml b/res/e3a/spells.xml index 80d9e6260..25d123d43 100644 --- a/res/e3a/spells.xml +++ b/res/e3a/spells.xml @@ -1,12 +1,6 @@ - - - - - - - - + + @@ -656,3 +650,4 @@ + diff --git a/res/e3a/strings.xml b/res/e3a/strings.xml index 253501f9f..2dd79abb6 100644 --- a/res/e3a/strings.xml +++ b/res/e3a/strings.xml @@ -1,4 +1,5 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/res/e3a/weapons/axe.xml b/res/e3a/weapons/axe.xml deleted file mode 100644 index 6066c4cfc..000000000 --- a/res/e3a/weapons/axe.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/res/e3a/weapons/crossbow.xml b/res/e3a/weapons/crossbow.xml deleted file mode 100644 index 7b2ed743c..000000000 --- a/res/e3a/weapons/crossbow.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/res/e3a/weapons/greatbow.xml b/res/e3a/weapons/greatbow.xml deleted file mode 100644 index 358a55f7d..000000000 --- a/res/e3a/weapons/greatbow.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/res/e3a/weapons/greatsword.xml b/res/e3a/weapons/greatsword.xml deleted file mode 100644 index 5a199321d..000000000 --- a/res/e3a/weapons/greatsword.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - diff --git a/res/e3a/weapons/halberd.xml b/res/e3a/weapons/halberd.xml deleted file mode 100644 index c22e020b4..000000000 --- a/res/e3a/weapons/halberd.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/res/e3a/weapons/laensword.xml b/res/e3a/weapons/laensword.xml deleted file mode 100644 index 50f824e8c..000000000 --- a/res/e3a/weapons/laensword.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - diff --git a/res/e3a/weapons/lance.xml b/res/e3a/weapons/lance.xml deleted file mode 100644 index 285862484..000000000 --- a/res/e3a/weapons/lance.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/res/e3a/weapons/mallorncrossbow.xml b/res/e3a/weapons/mallorncrossbow.xml deleted file mode 100644 index 86991bc10..000000000 --- a/res/e3a/weapons/mallorncrossbow.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/res/e3a/weapons/mallornlance.xml b/res/e3a/weapons/mallornlance.xml deleted file mode 100644 index 0c50d125a..000000000 --- a/res/e3a/weapons/mallornlance.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/res/e3a/weapons/rep_crossbow.xml b/res/e3a/weapons/rep_crossbow.xml deleted file mode 100644 index ffa1c0455..000000000 --- a/res/e3a/weapons/rep_crossbow.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/res/e3a/weapons/rustygreatsword.xml b/res/e3a/weapons/rustygreatsword.xml deleted file mode 100644 index 607f16a6a..000000000 --- a/res/e3a/weapons/rustygreatsword.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - diff --git a/res/e3a/weapons/rustyhalberd.xml b/res/e3a/weapons/rustyhalberd.xml deleted file mode 100644 index a53aec515..000000000 --- a/res/e3a/weapons/rustyhalberd.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - diff --git a/res/eressea/buildings.xml b/res/eressea/buildings.xml index b3ab4b6c0..d239907f1 100644 --- a/res/eressea/buildings.xml +++ b/res/eressea/buildings.xml @@ -1,6 +1,6 @@ - + diff --git a/res/eressea/races.xml b/res/eressea/races.xml index 654a859bd..21ff5b028 100644 --- a/res/eressea/races.xml +++ b/res/eressea/races.xml @@ -1,6 +1,6 @@ - + + - + + diff --git a/res/races/goblin-3.xml b/res/races/goblin-3.xml index a65d4c99a..636f8cc29 100644 --- a/res/races/goblin-3.xml +++ b/res/races/goblin-3.xml @@ -1,4 +1,6 @@ + + + + diff --git a/res/races/wyrm.xml b/res/races/wyrm.xml index dab1a9e1f..df2008a80 100644 --- a/res/races/wyrm.xml +++ b/res/races/wyrm.xml @@ -1,3 +1,6 @@ + + + + + diff --git a/res/races/youngdragon.xml b/res/races/youngdragon.xml index df10a44e9..d8b3d366f 100644 --- a/res/races/youngdragon.xml +++ b/res/races/youngdragon.xml @@ -1,3 +1,5 @@ + + - + + diff --git a/scripts/tests/e3/production.lua b/scripts/tests/e3/production.lua index 3469b06c4..be63158cf 100644 --- a/scripts/tests/e3/production.lua +++ b/scripts/tests/e3/production.lua @@ -53,6 +53,7 @@ function test_dwarf_no_mining_bonus() local r = region.create(0, 0, 'mountain') local f = create_faction('dwarf') local u = unit.create(f, r, 1) + u.name = 'Xolgrim' turn_begin() r:set_resource('iron', 100) From 907c5fc601cee13f5d1875d707bc0eaf7aa036ad Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 6 Feb 2018 21:39:52 +0100 Subject: [PATCH 8/9] unused variable. --- src/convert.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/convert.c b/src/convert.c index 8722cc8d5..6470c9e32 100644 --- a/src/convert.c +++ b/src/convert.c @@ -23,10 +23,9 @@ int main(int argc, char **argv) { if (argc < 2) return usage(); mode = argv[1]; if (strcmp(mode, "rules")==0) { - const char *xmlfile, *catalog; + const char *xmlfile; if (argc < 4) return usage(); xmlfile = argv[2]; - catalog = argv[3]; read_xml(xmlfile); write_rules("rules.dat"); return 0; From d1a393610c024232aeefad011fdeec68962fbd50 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 7 Feb 2018 17:57:24 +0100 Subject: [PATCH 9/9] begin work on 3.16 release --- src/kernel/version.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kernel/version.c b/src/kernel/version.c index 7c5c2435f..4e1c49cf4 100644 --- a/src/kernel/version.c +++ b/src/kernel/version.c @@ -7,7 +7,7 @@ #ifndef ERESSEA_VERSION /* the version number, if it was not passed to make with -D */ -#define ERESSEA_VERSION "3.15.0" +#define ERESSEA_VERSION "3.16.0" #endif const char *eressea_version(void) {