forked from github/server
only read spellbooks when they are specialized (familiars, monsters, E3 factions)
This commit is contained in:
parent
8619bd74a8
commit
da345f0cea
|
@ -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;
|
return AT_READ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1204,39 +1204,41 @@ static ally **addally(const faction * f, ally ** sfp, int aid, int state)
|
||||||
return &sf->next;
|
return &sf->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct spellbook *read_spellbook(struct storage *store)
|
void read_spellbook(spellbook **bookp, struct storage *store)
|
||||||
{
|
{
|
||||||
spellbook * book = 0;
|
|
||||||
int level;
|
int level;
|
||||||
for (level=0;;++level) {
|
for (level=0;;++level) {
|
||||||
spell *sp;
|
spell *sp = 0;
|
||||||
char spname[64];
|
char spname[64];
|
||||||
|
|
||||||
if (store->version < SPELLNAME_VERSION) {
|
if (store->version < SPELLNAME_VERSION) {
|
||||||
int i = store->r_int(store);
|
int i = store->r_int(store);
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
break;
|
break;
|
||||||
sp = find_spellbyid((unsigned int) i);
|
if (bookp) {
|
||||||
|
sp = find_spellbyid((unsigned int) i);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
store->r_tok_buf(store, spname, sizeof(spname));
|
store->r_tok_buf(store, spname, sizeof(spname));
|
||||||
if (strcmp(spname, "end") == 0)
|
if (strcmp(spname, "end") == 0)
|
||||||
break;
|
break;
|
||||||
sp = find_spell(spname);
|
if (bookp) {
|
||||||
if (!sp) {
|
sp = find_spell(spname);
|
||||||
log_error("read_spells: could not find spell '%s'\n", spname);
|
if (!sp) {
|
||||||
|
log_error("read_spells: could not find spell '%s'\n", spname);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (store->version >= SPELLBOOK_VERSION) {
|
if (store->version >= SPELLBOOK_VERSION) {
|
||||||
level = store->r_int(store);
|
level = store->r_int(store);
|
||||||
}
|
}
|
||||||
if (sp) {
|
if (sp) {
|
||||||
if (!book) {
|
if (!*bookp) {
|
||||||
book = create_spellbook(0);
|
*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)
|
void write_spellbook(const struct spellbook *book, struct storage *store)
|
||||||
|
@ -1393,7 +1395,7 @@ faction *readfaction(struct storage * store)
|
||||||
read_groups(store, f);
|
read_groups(store, f);
|
||||||
f->spellbook = 0;
|
f->spellbook = 0;
|
||||||
if (store->version >= REGIONOWNER_VERSION) {
|
if (store->version >= REGIONOWNER_VERSION) {
|
||||||
f->spellbook = read_spellbook(store);
|
read_spellbook(FactionSpells() ? &f->spellbook : 0, store);
|
||||||
}
|
}
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ extern "C" {
|
||||||
extern void read_items(struct storage *store, struct item **it);
|
extern void read_items(struct storage *store, struct item **it);
|
||||||
extern void write_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_spellbook(const struct spellbook *book, struct storage *store);
|
||||||
|
|
||||||
extern void write_unit(struct storage *store, const struct unit *u);
|
extern void write_unit(struct storage *store, const struct unit *u);
|
||||||
|
|
|
@ -1957,8 +1957,8 @@ static int parse_races(xmlDocPtr doc)
|
||||||
attack->data.sp = xml_spell(node, "spell");
|
attack->data.sp = xml_spell(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' needs a level: %d\n", attack->data.sp->sname, attack->level);
|
log_error("magical attack '%s' for race '%s' needs a level: %d\n", attack->data.sp->sname, rc->_name[0], attack->level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue