diff --git a/src/kernel/magic.c b/src/kernel/magic.c index 5cc8bba0d..b5f7dbb70 100644 --- a/src/kernel/magic.c +++ b/src/kernel/magic.c @@ -290,7 +290,11 @@ static int read_mage(attrib * a, void *owner, struct storage *store) } } } - mage->spellbook = read_spellbook(store); + if (mage->magietyp==M_GRAY) { + read_spellbook(&mage->spellbook, store); + } else { + read_spellbook(0, store); + } return AT_READ_OK; } diff --git a/src/kernel/save.c b/src/kernel/save.c index 0de9d337c..3f1502478 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1204,39 +1204,41 @@ static ally **addally(const faction * f, ally ** sfp, int aid, int state) return &sf->next; } -struct spellbook *read_spellbook(struct storage *store) +void read_spellbook(spellbook **bookp, struct storage *store) { - spellbook * book = 0; int level; for (level=0;;++level) { - spell *sp; + spell *sp = 0; char spname[64]; if (store->version < SPELLNAME_VERSION) { int i = store->r_int(store); if (i < 0) break; - sp = find_spellbyid((unsigned int) i); + if (bookp) { + sp = find_spellbyid((unsigned int) i); + } } else { store->r_tok_buf(store, spname, sizeof(spname)); if (strcmp(spname, "end") == 0) break; - sp = find_spell(spname); - if (!sp) { - log_error("read_spells: could not find spell '%s'\n", spname); + if (bookp) { + sp = find_spell(spname); + if (!sp) { + log_error("read_spells: could not find spell '%s'\n", spname); + } } } if (store->version >= SPELLBOOK_VERSION) { level = store->r_int(store); } if (sp) { - if (!book) { - book = create_spellbook(0); + if (!*bookp) { + *bookp = create_spellbook(0); } - spellbook_add(book, sp, level); + spellbook_add(*bookp, sp, level); } } - return book; } void write_spellbook(const struct spellbook *book, struct storage *store) @@ -1393,7 +1395,7 @@ faction *readfaction(struct storage * store) read_groups(store, f); f->spellbook = 0; if (store->version >= REGIONOWNER_VERSION) { - f->spellbook = read_spellbook(store); + read_spellbook(FactionSpells() ? &f->spellbook : 0, store); } return f; } diff --git a/src/kernel/save.h b/src/kernel/save.h index 41f1c4893..58c7d5356 100644 --- a/src/kernel/save.h +++ b/src/kernel/save.h @@ -47,7 +47,7 @@ extern "C" { extern void read_items(struct storage *store, struct item **it); extern void write_items(struct storage *store, struct item *it); - extern struct spellbook *read_spellbook(struct storage *store); + extern void read_spellbook(struct spellbook **bookp, struct storage *store); extern void write_spellbook(const struct spellbook *book, struct storage *store); extern void write_unit(struct storage *store, const struct unit *u); diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 22d62b0d1..c87f7449a 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1957,8 +1957,8 @@ static int parse_races(xmlDocPtr doc) attack->data.sp = xml_spell(node, "spell"); if (attack->data.sp) { attack->level = xml_ivalue(node, "level", 0); - if (attack->level > 0) { - log_error("magical attack '%s' needs a level: %d\n", attack->data.sp->sname, attack->level); + if (attack->level <= 0) { + log_error("magical attack '%s' for race '%s' needs a level: %d\n", attack->data.sp->sname, rc->_name[0], attack->level); } } }