Clean up a rare corner case with mnearto().
With this fix, if the second mnearto fails, we don't accidentally strand othermon at (0,0).
This commit is contained in:
@@ -2289,7 +2289,7 @@ boolean move_other; /* make sure mtmp gets to x, y! so move m_at(x, y) */
|
|||||||
coord mm;
|
coord mm;
|
||||||
|
|
||||||
if ((mtmp->mx == x) && (mtmp->my == y))
|
if ((mtmp->mx == x) && (mtmp->my == y))
|
||||||
return (FALSE);
|
return FALSE;
|
||||||
|
|
||||||
if (move_other && (othermon = m_at(x, y))) {
|
if (move_other && (othermon = m_at(x, y))) {
|
||||||
if (othermon->wormno)
|
if (othermon->wormno)
|
||||||
@@ -2307,7 +2307,7 @@ boolean move_other; /* make sure mtmp gets to x, y! so move m_at(x, y) */
|
|||||||
* no end of trouble.
|
* no end of trouble.
|
||||||
*/
|
*/
|
||||||
if (!enexto(&mm, newx, newy, mtmp->data))
|
if (!enexto(&mm, newx, newy, mtmp->data))
|
||||||
return (FALSE);
|
return FALSE;
|
||||||
newx = mm.x;
|
newx = mm.x;
|
||||||
newy = mm.y;
|
newy = mm.y;
|
||||||
}
|
}
|
||||||
@@ -2315,13 +2315,19 @@ boolean move_other; /* make sure mtmp gets to x, y! so move m_at(x, y) */
|
|||||||
rloc_to(mtmp, newx, newy);
|
rloc_to(mtmp, newx, newy);
|
||||||
|
|
||||||
if (move_other && othermon) {
|
if (move_other && othermon) {
|
||||||
|
xchar oldx = othermon->mx, oldy = othermon->my;
|
||||||
othermon->mx = othermon->my = 0;
|
othermon->mx = othermon->my = 0;
|
||||||
(void) mnearto(othermon, x, y, FALSE);
|
if (!mnearto(othermon, x, y, FALSE)) {
|
||||||
|
othermon->mx = oldx;
|
||||||
|
othermon->my = oldy;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if ((othermon->mx != x) || (othermon->my != y))
|
if ((othermon->mx != x) || (othermon->my != y))
|
||||||
return (TRUE);
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (FALSE);
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* monster responds to player action; not the same as a passive attack */
|
/* monster responds to player action; not the same as a passive attack */
|
||||||
|
|||||||
Reference in New Issue
Block a user