fix #K3627 - impossible placing long worm at <0,0>
When migrating, a long worm is removed from the map to take off the tail, then its head is put back to be treated like other monsters. If that occurred when being forced to re-migrate during failure to arrive from a prior migration, it wouldn't have valid coordinates and the place_monster attempt produced an impossible warning. (Other types of monsters don't get removed and put back so didn't trigger the problem.) The routine to format a monster when the data is suspect mistakenly thought it was dealing with a long worm tail because the monster didn't match level.monsters[0][0], so the warning inaccurately reported the problem as "placing long worm tail".
This commit is contained in:
@@ -2186,7 +2186,7 @@ minimal_monnam(struct monst *mon, boolean ckloc)
|
||||
Sprintf(outbuf, "[Invalid mon->data %s >= %s]",
|
||||
fmt_ptr((genericptr_t) mon->data),
|
||||
fmt_ptr((genericptr_t) &mons[NUMMONS]));
|
||||
} else if (ckloc && ptr == &mons[PM_LONG_WORM]
|
||||
} else if (ckloc && ptr == &mons[PM_LONG_WORM] && mon->mx
|
||||
&& g.level.monsters[mon->mx][mon->my] != mon) {
|
||||
Sprintf(outbuf, "%s <%d,%d>",
|
||||
pmname(&mons[PM_LONG_WORM_TAIL], Mgender(mon)),
|
||||
|
||||
@@ -609,8 +609,10 @@ mon_leave(struct monst *mtmp)
|
||||
more segments than can fit in that field gets truncated */
|
||||
num_segs = min(cnt, MAX_NUM_WORMS - 1);
|
||||
wormgone(mtmp);
|
||||
/* put the head back */
|
||||
place_monster(mtmp, mx, my);
|
||||
/* put the head back; note: mtmp might not be on the map if this
|
||||
is happening during a failed attempt to migrate to this level */
|
||||
if (mx)
|
||||
place_monster(mtmp, mx, my);
|
||||
}
|
||||
|
||||
return num_segs;
|
||||
|
||||
@@ -3293,6 +3293,12 @@ m_into_limbo(struct monst *mtmp)
|
||||
static void
|
||||
migrate_mon(struct monst *mtmp, xchar target_lev, xchar xyloc)
|
||||
{
|
||||
if (!mtmp->mx) {
|
||||
/* this was a failed arrival attempt from a prior migration;
|
||||
force mtmp to temporarily have a valid location when starting
|
||||
its new migration */
|
||||
mtmp->mx = u.ux, mtmp->my = u.uy;
|
||||
}
|
||||
unstuck(mtmp);
|
||||
mdrop_special_objs(mtmp);
|
||||
migrate_to_level(mtmp, target_lev, xyloc, (coord *) 0);
|
||||
|
||||
Reference in New Issue
Block a user