Put monsters into limbo if they cannot be placed
Whenever mnearto tries to displace a monster from underneath another, and the displaced one cannot be placed anywhere, make it drop special objects and put it into migration, with the current level as the target. This should be a good enough stopgap measure - it's not going to happen unless the level is (nearly) full of monsters. And it seems to cure a near-impossible-to-track data corruption, with monster list pointing to garbage.
This commit is contained in:
10
src/mon.c
10
src/mon.c
@@ -2342,13 +2342,15 @@ boolean move_other; /* make sure mtmp gets to x, y! so move m_at(x, y) */
|
||||
xchar oldx = othermon->mx, oldy = othermon->my;
|
||||
|
||||
othermon->mx = othermon->my = 0;
|
||||
if (!mnearto(othermon, x, y, FALSE)) {
|
||||
(void) mnearto(othermon, x, y, FALSE);
|
||||
if (othermon->mx == 0 && othermon->my == 0) {
|
||||
/* reloc failed, dump monster into "limbo"
|
||||
(aka migrate to current level) */
|
||||
othermon->mx = oldx;
|
||||
othermon->my = oldy;
|
||||
return FALSE;
|
||||
mdrop_special_objs(othermon);
|
||||
migrate_to_level(othermon, ledger_no(&u.uz), MIGR_APPROX_XY, NULL);
|
||||
}
|
||||
if (othermon->mx != x || othermon->my != y)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
||||
Reference in New Issue
Block a user