wait until curse->magician has been resolve()'s before calling effskill() to find f->max_spelllevel.

This commit is contained in:
Enno Rehling 2015-08-02 22:08:35 +02:00
parent 17f15b69ee
commit b5ed7c562d
1 changed files with 17 additions and 17 deletions

View File

@ -1600,7 +1600,6 @@ int readgame(const char *filename, int backup)
while (--p >= 0) { while (--p >= 0) {
unit *u = read_unit(&gdata); unit *u = read_unit(&gdata);
sc_mage *mage;
if (gdata.version < JSON_REPORT_VERSION) { if (gdata.version < JSON_REPORT_VERSION) {
if (u->_name && fval(u->faction, FFL_NPC)) { if (u->_name && fval(u->faction, FFL_NPC)) {
@ -1615,21 +1614,6 @@ int readgame(const char *filename, int backup)
up = &u->next; up = &u->next;
update_interval(u->faction, u->region); 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"); log_printf(stdout, "\n");
@ -1653,6 +1637,7 @@ int readgame(const char *filename, int backup)
for (f = factions; f; f = f->next) { for (f = factions; f; f = f->next) {
if (f->flags & FFL_NPC) { if (f->flags & FFL_NPC) {
f->alive = 1; f->alive = 1;
f->magiegebiet = M_GRAY;
if (f->no == 0) { if (f->no == 0) {
int no = 666; int no = 666;
while (findfaction(no)) while (findfaction(no))
@ -1663,8 +1648,23 @@ int readgame(const char *filename, int backup)
} }
else { else {
for (u = f->units; u; u = u->nextF) { 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) { if (u->number > 0) {
f->alive = 1; f->alive = true;
break; break;
} }
} }