From b5ed7c562d20b892e77f29af6e41ae6c67ed0123 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 2 Aug 2015 22:08:35 +0200 Subject: [PATCH] wait until curse->magician has been resolve()'s before calling effskill() to find f->max_spelllevel. --- src/kernel/save.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/kernel/save.c b/src/kernel/save.c index 3751bea91..114126b0c 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1600,7 +1600,6 @@ int readgame(const char *filename, int backup) while (--p >= 0) { unit *u = read_unit(&gdata); - sc_mage *mage; if (gdata.version < JSON_REPORT_VERSION) { if (u->_name && fval(u->faction, FFL_NPC)) { @@ -1615,21 +1614,6 @@ int readgame(const char *filename, int backup) up = &u->next; update_interval(u->faction, u->region); - mage = get_mage(u); - if (mage) { - faction *f = u->faction; - int skl = effskill(u, SK_MAGIC); - if (!fval(f, FFL_NPC) && f->magiegebiet == M_GRAY) { - log_error("faction %s had magic=gray, fixing (%s)\n", factionname(f), magic_school[mage->magietyp]); - f->magiegebiet = mage->magietyp; - } - if (f->max_spelllevel < skl) { - f->max_spelllevel = skl; - } - if (mage->spellcount < 0) { - mage->spellcount = 0; - } - } } } log_printf(stdout, "\n"); @@ -1653,6 +1637,7 @@ int readgame(const char *filename, int backup) for (f = factions; f; f = f->next) { if (f->flags & FFL_NPC) { f->alive = 1; + f->magiegebiet = M_GRAY; if (f->no == 0) { int no = 666; while (findfaction(no)) @@ -1663,8 +1648,23 @@ int readgame(const char *filename, int backup) } else { for (u = f->units; u; u = u->nextF) { + sc_mage *mage = get_mage(u); + if (mage) { + faction *f = u->faction; + int skl = effskill(u, SK_MAGIC); + if (f->magiegebiet == M_GRAY) { + log_error("faction %s had magic=gray, fixing (%s)\n", factionname(f), magic_school[mage->magietyp]); + f->magiegebiet = mage->magietyp; + } + if (f->max_spelllevel < skl) { + f->max_spelllevel = skl; + } + if (mage->spellcount < 0) { + mage->spellcount = 0; + } + } if (u->number > 0) { - f->alive = 1; + f->alive = true; break; } }