From 5b807e2057ea0b59935005985e1781dbc085ff4e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 4 Jun 2017 14:12:23 +0200 Subject: [PATCH] crash casued by spell conversion. remove unit from faction, not only region! also remove spammy warning that has no value. --- src/kernel/save.c | 1 + src/kernel/unit.c | 4 +++- src/magic.c | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/kernel/save.c b/src/kernel/save.c index 7a9e12286..83a218622 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1707,6 +1707,7 @@ int read_game(gamedata *data) { if (data->version < NORCSPELL_VERSION && u_race(u) == rc_spell) { set_observer(r, u->faction, get_level(u, SK_PERCEPTION), u->age); + u_setfaction(u, NULL); free_unit(u); } else { diff --git a/src/kernel/unit.c b/src/kernel/unit.c index e6b8757ef..d5317ec72 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -1400,10 +1400,12 @@ int invisible(const unit * target, const unit * viewer) /** remove the unit from memory. * this frees all memory that's only accessible through the unit, * and you should already have called uunhash and removed the unit from the - * region. + * region and faction. */ void free_unit(unit * u) { + assert(!u->region); + assert(!u->faction); free(u->_name); free(u->display); free_order(u->thisorder); diff --git a/src/magic.c b/src/magic.c index 3cac1cb52..93c5009f5 100644 --- a/src/magic.c +++ b/src/magic.c @@ -3010,7 +3010,6 @@ int cast_spell(struct castorder *co) fun = get_spellcast(sp->sname); if (!fun) { - log_warning("no spell function for %s, try callback", sp->sname); return callbacks.cast_spell(co, fname); } return fun(co);