Fix freeing monsters not on map
Sometimes we free the monster data, but the monster is not on the map - usually this happens if the map is full of monsters and a new one is migrated on the level. Make m_detach check the monster x coordinate, so it knows not to touch the map if the monster isn't on it.
This commit is contained in:
15
src/mon.c
15
src/mon.c
@@ -1745,6 +1745,8 @@ m_detach(mtmp, mptr)
|
||||
struct monst *mtmp;
|
||||
struct permonst *mptr; /* reflects mtmp->data _prior_ to mtmp's death */
|
||||
{
|
||||
boolean onmap = (mtmp->mx > -1);
|
||||
|
||||
if (mtmp == context.polearm.hitmon)
|
||||
context.polearm.hitmon = 0;
|
||||
if (mtmp->mleashed)
|
||||
@@ -1753,14 +1755,21 @@ struct permonst *mptr; /* reflects mtmp->data _prior_ to mtmp's death */
|
||||
mtmp->mtrapped = 0;
|
||||
mtmp->mhp = 0; /* simplify some tests: force mhp to 0 */
|
||||
relobj(mtmp, 0, FALSE);
|
||||
remove_monster(mtmp->mx, mtmp->my);
|
||||
if (onmap) {
|
||||
if (mtmp->wormno)
|
||||
remove_worm(mtmp);
|
||||
else
|
||||
remove_monster(mtmp->mx, mtmp->my);
|
||||
}
|
||||
if (emits_light(mptr))
|
||||
del_light_source(LS_MONSTER, monst_to_any(mtmp));
|
||||
if (mtmp->m_ap_type)
|
||||
seemimic(mtmp);
|
||||
newsym(mtmp->mx, mtmp->my);
|
||||
if (onmap)
|
||||
newsym(mtmp->mx, mtmp->my);
|
||||
unstuck(mtmp);
|
||||
fill_pit(mtmp->mx, mtmp->my);
|
||||
if (onmap)
|
||||
fill_pit(mtmp->mx, mtmp->my);
|
||||
|
||||
if (mtmp->isshk)
|
||||
shkgone(mtmp);
|
||||
|
||||
Reference in New Issue
Block a user