deal with invalid border types (wisps are getting deleted from Eressea) and disabled spells (again, wisps).

This commit is contained in:
Enno Rehling 2012-05-12 13:16:07 -07:00
parent 88acf39638
commit 08fc39cca7
2 changed files with 53 additions and 44 deletions

View file

@ -676,7 +676,8 @@ int read_borders(struct storage *store)
if (result < 0)
return result;
}
if (!to || !from) {
if (!type->name || !to || !from) {
log_warning(("erase invalid border '%s' between '%s' and '%s'\n", type->__name, regionname(from, 0), regionname(to, 0)));
erase_border(b);
}
}

View file

@ -1497,6 +1497,7 @@ static int parse_spells(xmlDocPtr doc)
int k;
spell_component *component;
spell *sp;
int valid = 1;
static int modes[] = { 0, PRECOMBATSPELL, COMBATSPELL, POSTCOMBATSPELL };
/* spellname */
@ -1559,6 +1560,7 @@ static int parse_spells(xmlDocPtr doc)
cast = get_function(sp->sname);
if (!cast) {
log_error(("no spell cast function registered for '%s'\n", sp->sname));
valid = 0;
}
strlcpy(zText+7, sp->sname, sizeof(zText)-7);
fumble = get_function(zText);
@ -1568,19 +1570,20 @@ static int parse_spells(xmlDocPtr doc)
pf_generic fun;
parse_function(node, &fun, &propValue);
if (fun == NULL) {
log_error(("unknown function name '%s' for spell '%s'\n",
(const char *)propValue, sp->sname));
xmlFree(propValue);
continue;
}
assert(propValue != NULL);
if (strcmp((const char *)propValue, "cast") == 0) {
if (fun) {
cast = fun;
} else if (strcmp((const char *)propValue, "fumble") == 0) {
valid = 1;
} else {
log_error(("unknown function name '%s' for spell '%s'\n",
(const char *)propValue, sp->sname));
valid = 0;
}
} else if (fun && strcmp((const char *)propValue, "fumble") == 0) {
fumble = fun;
} else {
log_error(("unknown function type '%s' for spell %s\n",
log_error(("unknown function type '%s' for spell '%s'\n",
(const char *)propValue, sp->sname));
}
xmlFree(propValue);
@ -1591,6 +1594,7 @@ static int parse_spells(xmlDocPtr doc)
xmlXPathFreeObject(result);
}
if (valid) {
/* reading eressea/spells/spell/resource */
xpath->node = node;
result = xmlXPathEvalExpression(BAD_CAST "resource", xpath);
@ -1629,9 +1633,13 @@ static int parse_spells(xmlDocPtr doc)
component++;
}
xmlXPathFreeObject(result);
}
if (valid) {
register_spell(sp);
}
}
}
xmlXPathFreeObject(spells);