forked from github/server
make race::attack use spellref, too.
This commit is contained in:
parent
6d15767a18
commit
11c0330de1
4 changed files with 14 additions and 6 deletions
|
@ -1858,10 +1858,13 @@ static void do_combatspell(troop at)
|
|||
|
||||
static void do_extra_spell(troop at, const att * a)
|
||||
{
|
||||
const spell *sp = a->data.sp;
|
||||
const spell *sp = spellref_get(a->data.sp);
|
||||
|
||||
if (sp->cast == NULL) {
|
||||
log_error("spell '%s' has no function.\n", sp->sname);
|
||||
if (!sp) {
|
||||
log_error("no such spell: '%s'", a->data.sp->name);
|
||||
}
|
||||
else if (sp->cast == NULL) {
|
||||
log_error("spell '%s' has no function.", sp->sname);
|
||||
}
|
||||
else {
|
||||
assert(a->level > 0);
|
||||
|
|
|
@ -182,7 +182,12 @@ void racelist_insert(struct race_list **rl, const struct race *r)
|
|||
|
||||
void free_races(void) {
|
||||
while (races) {
|
||||
int i;
|
||||
race * rc = races->next;
|
||||
|
||||
for (i = 0; races->attack[i].type!=AT_NONE; ++i) {
|
||||
spellref_free(races->attack[i].data.sp);
|
||||
}
|
||||
spellref_free(races->precombatspell);
|
||||
free_params(&races->parameters);
|
||||
free(xrefs);
|
||||
|
|
|
@ -105,7 +105,7 @@ extern "C" {
|
|||
int type;
|
||||
union {
|
||||
const char *dice;
|
||||
const struct spell *sp;
|
||||
struct spellref *sp;
|
||||
} data;
|
||||
int flags;
|
||||
int level;
|
||||
|
|
|
@ -1889,11 +1889,11 @@ static int parse_races(xmlDocPtr doc)
|
|||
xmlFree(propValue);
|
||||
}
|
||||
else {
|
||||
attack->data.sp = xml_spell(node, "spell");
|
||||
attack->data.sp = xml_spellref(node, "spell");
|
||||
if (attack->data.sp) {
|
||||
attack->level = xml_ivalue(node, "level", 0);
|
||||
if (attack->level <= 0) {
|
||||
log_error("magical attack '%s' for race '%s' needs a level: %d\n", attack->data.sp->sname, rc->_name, attack->level);
|
||||
log_error("magical attack '%s' for race '%s' needs a level: %d\n", attack->data.sp->name, rc->_name, attack->level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue