fix missing limit-flags.

This commit is contained in:
Enno Rehling 2017-02-26 13:47:22 +01:00
parent 0738090f28
commit c3b0b9e8b3
7 changed files with 6 additions and 21 deletions

View File

@ -4,8 +4,4 @@
<construction skill="training" minskill="1"/> <construction skill="training" minskill="1"/>
<function name="give" value="givehorses"/> <function name="give" value="givehorses"/>
</item> </item>
<resourcelimit>
<function name="produce" value="lua_produceresource"/>
<function name="limit" value="lua_limitresource"/>
</resourcelimit>
</resource> </resource>

View File

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

View File

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

View File

@ -3,8 +3,4 @@
<item weight="10" score="100"> <item weight="10" score="100">
<construction skill="herbalism" minskill="4"/> <construction skill="herbalism" minskill="4"/>
</item> </item>
<resourcelimit>
<function name="produce" value="lua_produceresource"/>
<function name="limit" value="lua_limitresource"/>
</resourcelimit>
</resource> </resource>

View File

@ -3,8 +3,4 @@
<item weight="10" score="50"> <item weight="10" score="50">
<construction skill="herbalism" minskill="3"/> <construction skill="herbalism" minskill="3"/>
</item> </item>
<resourcelimit>
<function name="produce" value="lua_produceresource"/>
<function name="limit" value="lua_limitresource"/>
</resourcelimit>
</resource> </resource>

View File

@ -930,7 +930,6 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want)
* Materialverbrauch hat: */ * Materialverbrauch hat: */
assert(itype != NULL && (itype->construction == NULL assert(itype != NULL && (itype->construction == NULL
|| itype->construction->materials == NULL)); || itype->construction->materials == NULL));
assert(rdata != NULL);
if (!rtype->raw) { if (!rtype->raw) {
int avail = limit_resource(r, rtype); int avail = limit_resource(r, rtype);
@ -945,7 +944,7 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want)
return; return;
} }
if (rdata->modifiers) { if (rdata && rdata->modifiers) {
message *msg = get_modifiers(u, rdata->modifiers, &save_mod, &skill_mod); message *msg = get_modifiers(u, rdata->modifiers, &save_mod, &skill_mod);
if (msg) { if (msg) {
ADDMSG(&u->faction->msgs, msg); ADDMSG(&u->faction->msgs, msg);

View File

@ -980,6 +980,9 @@ static int parse_resources(xmlDocPtr doc)
rmt_create(rtype); rmt_create(rtype);
} }
if (xml_bvalue(node, "limited", false)) {
rtype->flags |= RTF_LIMITED;
}
/* reading eressea/resources/resource/resourcelimit */ /* reading eressea/resources/resource/resourcelimit */
xpath->node = node; xpath->node = node;
result = xmlXPathEvalExpression(BAD_CAST "resourcelimit", xpath); result = xmlXPathEvalExpression(BAD_CAST "resourcelimit", xpath);
@ -988,7 +991,6 @@ static int parse_resources(xmlDocPtr doc)
resource_limit *rdata = rtype->limit = calloc(1, sizeof(resource_limit)); resource_limit *rdata = rtype->limit = calloc(1, sizeof(resource_limit));
xmlNodePtr limit = result->nodesetval->nodeTab[0]; xmlNodePtr limit = result->nodesetval->nodeTab[0];
rtype->flags |= RTF_LIMITED;
xpath->node = limit; xpath->node = limit;
xmlXPathFreeObject(result); xmlXPathFreeObject(result);