crash casued by spell conversion.

remove unit from faction, not only region!
also remove spammy warning that has no value.
This commit is contained in:
Enno Rehling 2017-06-04 14:12:23 +02:00
parent 1687e31d5f
commit 5b807e2057
3 changed files with 4 additions and 2 deletions

View File

@ -1707,6 +1707,7 @@ int read_game(gamedata *data) {
if (data->version < NORCSPELL_VERSION && u_race(u) == rc_spell) { if (data->version < NORCSPELL_VERSION && u_race(u) == rc_spell) {
set_observer(r, u->faction, get_level(u, SK_PERCEPTION), u->age); set_observer(r, u->faction, get_level(u, SK_PERCEPTION), u->age);
u_setfaction(u, NULL);
free_unit(u); free_unit(u);
} }
else { else {

View File

@ -1400,10 +1400,12 @@ int invisible(const unit * target, const unit * viewer)
/** remove the unit from memory. /** remove the unit from memory.
* this frees all memory that's only accessible through the unit, * this frees all memory that's only accessible through the unit,
* and you should already have called uunhash and removed the unit from the * and you should already have called uunhash and removed the unit from the
* region. * region and faction.
*/ */
void free_unit(unit * u) void free_unit(unit * u)
{ {
assert(!u->region);
assert(!u->faction);
free(u->_name); free(u->_name);
free(u->display); free(u->display);
free_order(u->thisorder); free_order(u->thisorder);

View File

@ -3010,7 +3010,6 @@ int cast_spell(struct castorder *co)
fun = get_spellcast(sp->sname); fun = get_spellcast(sp->sname);
if (!fun) { if (!fun) {
log_warning("no spell function for %s, try callback", sp->sname);
return callbacks.cast_spell(co, fname); return callbacks.cast_spell(co, fname);
} }
return fun(co); return fun(co);