remove pointless <resourcelimit/> wrapper from XML.

This commit is contained in:
Enno Rehling 2017-02-26 14:00:20 +01:00
parent d4b973fea4
commit 6e27adb892
9 changed files with 68 additions and 93 deletions

View File

@ -5,9 +5,7 @@
<item weight="200" score="200">
<construction skill="mining" minskill="8"/>
</item>
<resourcelimit>
<modifier type="require" building="mine"/>
</resourcelimit>
<modifier type="require" building="mine"/>
</resource>
<resource name="adamantiumaxe">

View File

@ -1,11 +1,9 @@
<?xml version="1.0"?>
<resource name="iron" limited="yes" material="yes">
<item weight="500" score="10">
<construction skill="mining" minskill="1"/>
</item>
<resourcelimit>
<item weight="500" score="10">
<construction skill="mining" minskill="1"/>
</item>
<modifier building="mine" type="skill" value="1"/>
<modifier building="mine" type="material" value="0.5"/>
<modifier race="dwarf" type="material" value="0.60"/>
</resourcelimit>
</resource>

View File

@ -1,9 +1,7 @@
<?xml version="1.0"?>
<resource name="laen" limited="yes" material="yes">
<item weight="200" score="100">
<construction skill="mining" minskill="7"/>
</item>
<resourcelimit>
<item weight="200" score="100">
<construction skill="mining" minskill="7"/>
</item>
<modifier type="require" building="mine"/>
</resourcelimit>
</resource>

View File

@ -1,10 +1,8 @@
<?xml version="1.0"?>
<resource name="log" limited="yes">
<item weight="500" score="10">
<construction skill="forestry" minskill="1"/>
</item>
<resourcelimit>
<item weight="500" score="10">
<construction skill="forestry" minskill="1"/>
</item>
<modifier building="sawmill" type="skill" value="1"/>
<modifier building="sawmill" type="material" value="0.5"/>
</resourcelimit>
</resource>

View File

@ -1,10 +1,8 @@
<?xml version="1.0"?>
<resource name="mallorn" limited="yes">
<item weight="500" score="30">
<construction skill="forestry" minskill="2"/>
</item>
<resourcelimit>
<item weight="500" score="30">
<construction skill="forestry" minskill="2"/>
</item>
<modifier building="sawmill" type="skill" value="1"/>
<modifier building="sawmill" type="material" value="0.5"/>
</resourcelimit>
</resource>

View File

@ -1,11 +1,9 @@
<?xml version="1.0"?>
<resource name="stone" limited="yes" material="yes">
<item weight="6000" score="10" big="yes">
<construction skill="quarrying" minskill="1"/>
</item>
<resourcelimit>
<item weight="6000" score="10" big="yes">
<construction skill="quarrying" minskill="1"/>
</item>
<modifier building="quarry" type="skill" value="1"/>
<modifier building="quarry" type="material" value="0.5"/>
<modifier race="troll" type="material" value="0.75"/>
</resourcelimit>
</resource>

View File

@ -1,10 +1,8 @@
<?xml version="1.0"?>
<resource name="iron" limited="yes" material="yes">
<item weight="500" score="10">
<construction skill="mining" minskill="1"/>
</item>
<resourcelimit>
<item weight="500" score="10">
<construction skill="mining" minskill="1"/>
</item>
<modifier building="mine" type="skill" value="1"/>
<modifier building="mine" type="material" value="0.5"/>
</resourcelimit>
</resource>

View File

@ -1,10 +1,8 @@
<?xml version="1.0"?>
<resource name="stone" limited="yes" material="yes">
<item weight="6000" score="10" big="yes">
<construction skill="quarrying" minskill="1"/>
</item>
<resourcelimit>
<item weight="6000" score="10" big="yes">
<construction skill="quarrying" minskill="1"/>
</item>
<modifier building="quarry" type="skill" value="1"/>
<modifier building="quarry" type="material" value="0.5"/>
</resourcelimit>
</resource>

View File

@ -983,65 +983,56 @@ static int parse_resources(xmlDocPtr doc)
if (xml_bvalue(node, "limited", false)) {
rtype->flags |= RTF_LIMITED;
}
/* reading eressea/resources/resource/resourcelimit */
/* reading eressea/resources/resource/modifier */
xpath->node = node;
result = xmlXPathEvalExpression(BAD_CAST "resourcelimit", xpath);
assert(result->nodesetval->nodeNr <= 1);
if (result->nodesetval->nodeNr != 0) {
xmlNodePtr limit = result->nodesetval->nodeTab[0];
result = xmlXPathEvalExpression(BAD_CAST "modifier", xpath);
if (result->nodesetval != NULL && result->nodesetval->nodeNr > 0) {
rtype->modifiers =
calloc(result->nodesetval->nodeNr + 1, sizeof(resource_mod));
for (k = 0; k != result->nodesetval->nodeNr; ++k) {
xmlNodePtr node = result->nodesetval->nodeTab[k];
building_type *btype = NULL;
const race *rc = NULL;
xpath->node = limit;
xmlXPathFreeObject(result);
result = xmlXPathEvalExpression(BAD_CAST "modifier", xpath);
if (result->nodesetval != NULL) {
rtype->modifiers =
calloc(result->nodesetval->nodeNr + 1, sizeof(resource_mod));
for (k = 0; k != result->nodesetval->nodeNr; ++k) {
xmlNodePtr node = result->nodesetval->nodeTab[k];
building_type *btype = NULL;
const race *rc = NULL;
propValue = xmlGetProp(node, BAD_CAST "race");
if (propValue != NULL) {
rc = rc_find((const char *)propValue);
if (rc == NULL)
rc = rc_get_or_create((const char *)propValue);
xmlFree(propValue);
}
rtype->modifiers[k].race = rc;
propValue = xmlGetProp(node, BAD_CAST "building");
if (propValue != NULL) {
btype = bt_get_or_create((const char *)propValue);
xmlFree(propValue);
}
rtype->modifiers[k].btype = btype;
propValue = xmlGetProp(node, BAD_CAST "type");
assert(propValue != NULL);
if (strcmp((const char *)propValue, "skill") == 0) {
rtype->modifiers[k].value.i = xml_ivalue(node, "value", 0);
rtype->modifiers[k].flags = RMF_SKILL;
}
else if (strcmp((const char *)propValue, "material") == 0) {
rtype->modifiers[k].value = xml_fraction(node, "value");
rtype->modifiers[k].flags = RMF_SAVEMATERIAL;
}
else if (strcmp((const char *)propValue, "require") == 0) {
xmlChar *propBldg = xmlGetProp(node, BAD_CAST "building");
if (propBldg != NULL) {
btype = bt_get_or_create((const char *)propBldg);
rtype->modifiers[k].btype = btype;
rtype->modifiers[k].flags = RMF_REQUIREDBUILDING;
xmlFree(propBldg);
}
}
else {
log_error("unknown type '%s' for resourcelimit-modifier '%s'\n", (const char *)propValue, rtype->_name);
}
propValue = xmlGetProp(node, BAD_CAST "race");
if (propValue != NULL) {
rc = rc_find((const char *)propValue);
if (rc == NULL)
rc = rc_get_or_create((const char *)propValue);
xmlFree(propValue);
}
rtype->modifiers[k].race = rc;
propValue = xmlGetProp(node, BAD_CAST "building");
if (propValue != NULL) {
btype = bt_get_or_create((const char *)propValue);
xmlFree(propValue);
}
rtype->modifiers[k].btype = btype;
propValue = xmlGetProp(node, BAD_CAST "type");
assert(propValue != NULL);
if (strcmp((const char *)propValue, "skill") == 0) {
rtype->modifiers[k].value.i = xml_ivalue(node, "value", 0);
rtype->modifiers[k].flags = RMF_SKILL;
}
else if (strcmp((const char *)propValue, "material") == 0) {
rtype->modifiers[k].value = xml_fraction(node, "value");
rtype->modifiers[k].flags = RMF_SAVEMATERIAL;
}
else if (strcmp((const char *)propValue, "require") == 0) {
xmlChar *propBldg = xmlGetProp(node, BAD_CAST "building");
if (propBldg != NULL) {
btype = bt_get_or_create((const char *)propBldg);
rtype->modifiers[k].btype = btype;
rtype->modifiers[k].flags = RMF_REQUIREDBUILDING;
xmlFree(propBldg);
}
}
else {
log_error("unknown type '%s' for resourcelimit-modifier '%s'\n", (const char *)propValue, rtype->_name);
}
xmlFree(propValue);
}
}
xmlXPathFreeObject(result);