read_spellbook, use gamedata.version

github issue #479
This commit is contained in:
Enno Rehling 2016-02-13 15:48:48 +01:00
parent 21aee8ece8
commit 2e41c4972c
3 changed files with 9 additions and 9 deletions

View File

@ -1129,14 +1129,14 @@ int get_spell_level_faction(const spell * sp, void * cbdata)
return 0; return 0;
} }
void read_spellbook(spellbook **bookp, struct storage *store, int(*get_level)(const spell * sp, void *), void * cbdata) void read_spellbook(spellbook **bookp, gamedata *data, int(*get_level)(const spell * sp, void *), void * cbdata)
{ {
for (;;) { for (;;) {
spell *sp = 0; spell *sp = 0;
char spname[64]; char spname[64];
int level = 0; int level = 0;
READ_TOK(store, spname, sizeof(spname)); READ_TOK(data->store, spname, sizeof(spname));
if (strcmp(spname, "end") == 0) if (strcmp(spname, "end") == 0)
break; break;
if (bookp) { if (bookp) {
@ -1145,8 +1145,8 @@ void read_spellbook(spellbook **bookp, struct storage *store, int(*get_level)(co
log_error("read_spells: could not find spell '%s'\n", spname); log_error("read_spells: could not find spell '%s'\n", spname);
} }
} }
if (global.data_version >= SPELLBOOK_VERSION) { if (data->version >= SPELLBOOK_VERSION) {
READ_INT(store, &level); READ_INT(data->store, &level);
} }
if (sp) { if (sp) {
spellbook * sb = *bookp; spellbook * sb = *bookp;
@ -1157,7 +1157,7 @@ void read_spellbook(spellbook **bookp, struct storage *store, int(*get_level)(co
*bookp = create_spellbook(0); *bookp = create_spellbook(0);
sb = *bookp; sb = *bookp;
} }
if (level > 0 && (global.data_version >= SPELLBOOK_VERSION || !spellbook_get(sb, sp))) { if (level > 0 && (data->version >= SPELLBOOK_VERSION || !spellbook_get(sb, sp))) {
spellbook_add(sb, sp, level); spellbook_add(sb, sp, level);
} }
} }
@ -1375,7 +1375,7 @@ faction *readfaction(struct gamedata * data)
read_groups(data, f); read_groups(data, f);
f->spellbook = 0; f->spellbook = 0;
if (data->version >= REGIONOWNER_VERSION) { if (data->version >= REGIONOWNER_VERSION) {
read_spellbook(FactionSpells() ? &f->spellbook : 0, data->store, get_spell_level_faction, (void *)f); read_spellbook(FactionSpells() ? &f->spellbook : 0, data, get_spell_level_faction, (void *)f);
} }
return f; return f;
} }

View File

@ -50,7 +50,7 @@ extern "C" {
void read_items(struct storage *store, struct item **it); void read_items(struct storage *store, struct item **it);
void write_items(struct storage *store, struct item *it); void write_items(struct storage *store, struct item *it);
void read_spellbook(struct spellbook **bookp, struct storage *store, int(*get_level)(const struct spell * sp, void *), void * cbdata); void read_spellbook(struct spellbook **bookp, struct gamedata *data, int(*get_level)(const struct spell * sp, void *), void * cbdata);
void write_spellbook(const struct spellbook *book, struct storage *store); void write_spellbook(const struct spellbook *book, struct storage *store);
void write_attribs(struct storage *store, struct attrib *alist, const void *owner); void write_attribs(struct storage *store, struct attrib *alist, const void *owner);

View File

@ -294,10 +294,10 @@ static int read_mage(attrib * a, void *owner, struct gamedata *data)
} }
} }
if (mage->magietyp == M_GRAY) { if (mage->magietyp == M_GRAY) {
read_spellbook(&mage->spellbook, store, get_spell_level_mage, mage); read_spellbook(&mage->spellbook, data, get_spell_level_mage, mage);
} }
else { else {
read_spellbook(0, store, 0, mage); read_spellbook(0, data, 0, mage);
} }
return AT_READ_OK; return AT_READ_OK;
} }