forked from github/server
log an error instead of asserting on spell components
This commit is contained in:
parent
68f04e66d1
commit
6a5a731262
|
@ -1414,7 +1414,8 @@ parse_spells(xmlDocPtr doc)
|
||||||
xmlNodePtr node = nodes->nodeTab[i];
|
xmlNodePtr node = nodes->nodeTab[i];
|
||||||
xmlChar * propValue;
|
xmlChar * propValue;
|
||||||
int k;
|
int k;
|
||||||
spell * sp = calloc(1, sizeof(spell));
|
spell_component * component;
|
||||||
|
spell * sp = (spell *)calloc(1, sizeof(spell));
|
||||||
static int modes[] = { 0, PRECOMBATSPELL, COMBATSPELL, POSTCOMBATSPELL };
|
static int modes[] = { 0, PRECOMBATSPELL, COMBATSPELL, POSTCOMBATSPELL };
|
||||||
|
|
||||||
/* spellname */
|
/* spellname */
|
||||||
|
@ -1496,27 +1497,34 @@ parse_spells(xmlDocPtr doc)
|
||||||
xpath->node = node;
|
xpath->node = node;
|
||||||
result = xmlXPathEvalExpression(BAD_CAST "resource", xpath);
|
result = xmlXPathEvalExpression(BAD_CAST "resource", xpath);
|
||||||
if (result->nodesetval->nodeNr) {
|
if (result->nodesetval->nodeNr) {
|
||||||
sp->components = malloc(sizeof(spell_component)*(result->nodesetval->nodeNr+1));
|
sp->components = (spell_component *)malloc(sizeof(spell_component)*(result->nodesetval->nodeNr+1));
|
||||||
sp->components[result->nodesetval->nodeNr].type = 0;
|
sp->components[result->nodesetval->nodeNr].type = 0;
|
||||||
}
|
}
|
||||||
for (k=0;k!=result->nodesetval->nodeNr;++k) {
|
for (component=sp->components,k=0;k!=result->nodesetval->nodeNr;++k) {
|
||||||
|
const resource_type * rtype;
|
||||||
xmlNodePtr node = result->nodesetval->nodeTab[k];
|
xmlNodePtr node = result->nodesetval->nodeTab[k];
|
||||||
propValue = xmlGetProp(node, BAD_CAST "name");
|
propValue = xmlGetProp(node, BAD_CAST "name");
|
||||||
assert(propValue);
|
assert(propValue);
|
||||||
sp->components[k].type = rt_find((const char *)propValue);
|
rtype = rt_find((const char *)propValue);
|
||||||
assert(sp->components[k].type);
|
if (!rtype) {
|
||||||
|
log_error(("spell %s uses unknown component %s.\n", sp->sname, (const char*)propValue));
|
||||||
xmlFree(propValue);
|
xmlFree(propValue);
|
||||||
sp->components[k].amount = xml_ivalue(node, "amount", 1);
|
continue;
|
||||||
sp->components[k].cost = SPC_FIX;
|
}
|
||||||
|
component->type = rtype;
|
||||||
|
xmlFree(propValue);
|
||||||
|
component->amount = xml_ivalue(node, "amount", 1);
|
||||||
|
component->cost = SPC_FIX;
|
||||||
propValue = xmlGetProp(node, BAD_CAST "cost");
|
propValue = xmlGetProp(node, BAD_CAST "cost");
|
||||||
if (propValue!=NULL) {
|
if (propValue!=NULL) {
|
||||||
if (strcmp((const char *)propValue, "linear")==0) {
|
if (strcmp((const char *)propValue, "linear")==0) {
|
||||||
sp->components[k].cost = SPC_LINEAR;
|
component->cost = SPC_LINEAR;
|
||||||
} else if (strcmp((const char *)propValue, "level")==0) {
|
} else if (strcmp((const char *)propValue, "level")==0) {
|
||||||
sp->components[k].cost = SPC_LEVEL;
|
component->cost = SPC_LEVEL;
|
||||||
}
|
}
|
||||||
xmlFree(propValue);
|
xmlFree(propValue);
|
||||||
}
|
}
|
||||||
|
component++;
|
||||||
}
|
}
|
||||||
xmlXPathFreeObject(result);
|
xmlXPathFreeObject(result);
|
||||||
register_spell(sp);
|
register_spell(sp);
|
||||||
|
|
Loading…
Reference in New Issue