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:
@@ -464,6 +464,7 @@ fail_mon_placement:
|
|||||||
}
|
}
|
||||||
(void) mkcorpstat(CORPSE, (struct monst *) 0, mtmp->data, xlocale,
|
(void) mkcorpstat(CORPSE, (struct monst *) 0, mtmp->data, xlocale,
|
||||||
ylocale, CORPSTAT_NONE);
|
ylocale, CORPSTAT_NONE);
|
||||||
|
mtmp->mx = mtmp->my = -1; /* for mongone, mon is not anywhere */
|
||||||
mongone(mtmp);
|
mongone(mtmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -418,7 +418,8 @@ struct mail_info *info;
|
|||||||
|
|
||||||
/* zip back to starting location */
|
/* zip back to starting location */
|
||||||
go_back:
|
go_back:
|
||||||
(void) md_rush(md, start.x, start.y);
|
if (!md_rush(md, start.x, start.y))
|
||||||
|
md->mx = md->my = -1; /* for mongone, md is not on map */
|
||||||
mongone(md);
|
mongone(md);
|
||||||
/* deliver some classes of messages even if no daemon ever shows up */
|
/* deliver some classes of messages even if no daemon ever shows up */
|
||||||
give_up:
|
give_up:
|
||||||
|
|||||||
@@ -1745,6 +1745,8 @@ m_detach(mtmp, mptr)
|
|||||||
struct monst *mtmp;
|
struct monst *mtmp;
|
||||||
struct permonst *mptr; /* reflects mtmp->data _prior_ to mtmp's death */
|
struct permonst *mptr; /* reflects mtmp->data _prior_ to mtmp's death */
|
||||||
{
|
{
|
||||||
|
boolean onmap = (mtmp->mx > -1);
|
||||||
|
|
||||||
if (mtmp == context.polearm.hitmon)
|
if (mtmp == context.polearm.hitmon)
|
||||||
context.polearm.hitmon = 0;
|
context.polearm.hitmon = 0;
|
||||||
if (mtmp->mleashed)
|
if (mtmp->mleashed)
|
||||||
@@ -1753,14 +1755,21 @@ struct permonst *mptr; /* reflects mtmp->data _prior_ to mtmp's death */
|
|||||||
mtmp->mtrapped = 0;
|
mtmp->mtrapped = 0;
|
||||||
mtmp->mhp = 0; /* simplify some tests: force mhp to 0 */
|
mtmp->mhp = 0; /* simplify some tests: force mhp to 0 */
|
||||||
relobj(mtmp, 0, FALSE);
|
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))
|
if (emits_light(mptr))
|
||||||
del_light_source(LS_MONSTER, monst_to_any(mtmp));
|
del_light_source(LS_MONSTER, monst_to_any(mtmp));
|
||||||
if (mtmp->m_ap_type)
|
if (mtmp->m_ap_type)
|
||||||
seemimic(mtmp);
|
seemimic(mtmp);
|
||||||
newsym(mtmp->mx, mtmp->my);
|
if (onmap)
|
||||||
|
newsym(mtmp->mx, mtmp->my);
|
||||||
unstuck(mtmp);
|
unstuck(mtmp);
|
||||||
fill_pit(mtmp->mx, mtmp->my);
|
if (onmap)
|
||||||
|
fill_pit(mtmp->mx, mtmp->my);
|
||||||
|
|
||||||
if (mtmp->isshk)
|
if (mtmp->isshk)
|
||||||
shkgone(mtmp);
|
shkgone(mtmp);
|
||||||
|
|||||||
Reference in New Issue
Block a user