make race::attack use spellref, too.

This commit is contained in:
Enno Rehling 2017-01-28 19:52:28 +01:00
parent 6d15767a18
commit 11c0330de1
4 changed files with 14 additions and 6 deletions

View file

@ -1858,10 +1858,13 @@ static void do_combatspell(troop at)
static void do_extra_spell(troop at, const att * a) 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) { if (!sp) {
log_error("spell '%s' has no function.\n", sp->sname); 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 { else {
assert(a->level > 0); assert(a->level > 0);

View file

@ -182,7 +182,12 @@ void racelist_insert(struct race_list **rl, const struct race *r)
void free_races(void) { void free_races(void) {
while (races) { while (races) {
int i;
race * rc = races->next; 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); spellref_free(races->precombatspell);
free_params(&races->parameters); free_params(&races->parameters);
free(xrefs); free(xrefs);

View file

@ -105,7 +105,7 @@ extern "C" {
int type; int type;
union { union {
const char *dice; const char *dice;
const struct spell *sp; struct spellref *sp;
} data; } data;
int flags; int flags;
int level; int level;

View file

@ -1889,11 +1889,11 @@ static int parse_races(xmlDocPtr doc)
xmlFree(propValue); xmlFree(propValue);
} }
else { else {
attack->data.sp = xml_spell(node, "spell"); attack->data.sp = xml_spellref(node, "spell");
if (attack->data.sp) { if (attack->data.sp) {
attack->level = xml_ivalue(node, "level", 0); attack->level = xml_ivalue(node, "level", 0);
if (attack->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);
} }
} }
} }