displacer monster vs long worm

Reported directly to devteam:  monster vs monster location swapping
didn't handle single-segment long worms properly.  Multi-segment
worms are disallowed but a worm with no visible segments (which
actually has 1 segment at the head's location) are allowed and the
segment wasn't being moved with the core monster and could trigger
warnings if sanity checking is enabled.  The next time that the
worm moved, it got itself back in synch.

I couldn't reproduce the warning but mdisplacem() clearly assumed
that a long worm reporting 0 segments didn't have any so wasn't
attempting to handle the hidden one.
This commit is contained in:
PatR
2021-10-03 14:15:02 -07:00
parent 5a652b0478
commit c3e5aaf8ba
2 changed files with 15 additions and 2 deletions

View File

@@ -243,13 +243,22 @@ mdisplacem(register struct monst *magr, register struct monst *mdef,
}
remove_monster(fx, fy); /* pick up from orig position */
remove_monster(tx, ty);
if (mdef->wormno)
remove_worm(mdef);
else
remove_monster(tx, ty);
place_monster(magr, tx, ty); /* put down at target spot */
place_monster(mdef, fx, fy);
if (mdef->wormno) /* now put down tail */
place_worm_tail_randomly(mdef, fx, fy);
/* either creature might move into or out of a poison gas cloud */
update_monster_region(magr);
update_monster_region(mdef);
if (g.vis && !quietly)
pline("%s moves %s out of %s way!", Monnam(magr), mon_nam(mdef),
is_rider(pa) ? "the" : mhis(magr));
newsym(fx, fy); /* see it */
newsym(fx, fy); /* see it */
newsym(tx, ty); /* all happen */
flush_screen(0); /* make sure it shows up */