From 2e41c4972c1eba59e4fe7b1a8f4bffb5f58aba17 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 13 Feb 2016 15:48:48 +0100 Subject: [PATCH] read_spellbook, use gamedata.version github issue #479 --- src/kernel/save.c | 12 ++++++------ src/kernel/save.h | 2 +- src/magic.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/kernel/save.c b/src/kernel/save.c index e4159998c..2495da02a 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1129,14 +1129,14 @@ int get_spell_level_faction(const spell * sp, void * cbdata) 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 (;;) { spell *sp = 0; char spname[64]; int level = 0; - READ_TOK(store, spname, sizeof(spname)); + READ_TOK(data->store, spname, sizeof(spname)); if (strcmp(spname, "end") == 0) break; 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); } } - if (global.data_version >= SPELLBOOK_VERSION) { - READ_INT(store, &level); + if (data->version >= SPELLBOOK_VERSION) { + READ_INT(data->store, &level); } if (sp) { spellbook * sb = *bookp; @@ -1157,7 +1157,7 @@ void read_spellbook(spellbook **bookp, struct storage *store, int(*get_level)(co *bookp = create_spellbook(0); 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); } } @@ -1375,7 +1375,7 @@ faction *readfaction(struct gamedata * data) read_groups(data, f); f->spellbook = 0; 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; } diff --git a/src/kernel/save.h b/src/kernel/save.h index 3b3dee3ae..a606b8ad4 100644 --- a/src/kernel/save.h +++ b/src/kernel/save.h @@ -50,7 +50,7 @@ extern "C" { void read_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_attribs(struct storage *store, struct attrib *alist, const void *owner); diff --git a/src/magic.c b/src/magic.c index b2cda2e18..38e4157c6 100644 --- a/src/magic.c +++ b/src/magic.c @@ -294,10 +294,10 @@ static int read_mage(attrib * a, void *owner, struct gamedata *data) } } 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 { - read_spellbook(0, store, 0, mage); + read_spellbook(0, data, 0, mage); } return AT_READ_OK; }