E void FDECL(detect_wsegs, (struct monst *, BOOLEAN_P));
E void FDECL(save_worm, (int, int));
E void FDECL(rest_worm, (int));
-E void FDECL(place_wsegs, (struct monst *));
+E void FDECL(place_wsegs, (struct monst *, struct monst *));
E void FDECL(sanity_check_worm, (struct monst *));
E void FDECL(remove_worm, (struct monst *));
E void FDECL(place_worm_tail_randomly, (struct monst *, XCHAR_P, XCHAR_P));
if (mtmp != u.usteed) /* don't place steed onto the map */
place_monster(mtmp2, mtmp2->mx, mtmp2->my);
if (mtmp2->wormno) /* update level.monsters[wseg->wx][wseg->wy] */
- place_wsegs(mtmp2); /* locations to mtmp2 not mtmp. */
+ place_wsegs(mtmp2, NULL); /* locations to mtmp2 not mtmp. */
if (emits_light(mtmp2->data)) {
/* since this is so rare, we don't have any `mon_move_light_source' */
new_light_source(mtmp2->mx, mtmp2->my, emits_light(mtmp2->data),
set_residency(mtmp, FALSE);
place_monster(mtmp, mtmp->mx, mtmp->my);
if (mtmp->wormno)
- place_wsegs(mtmp);
+ place_wsegs(mtmp, NULL);
/* regenerate monsters while on another level */
if (!u.uz.dlevel)
wgrowtime[new_wnum] = 0L; /* trying to call initworm(). */
/* Place the new monster at all the segment locations. */
- place_wsegs(new_worm);
+ place_wsegs(new_worm, worm);
if (context.mon_moving)
pline("%s is cut in half.", Monnam(worm));
* place_wsegs()
*
* Place the segments of the given worm. Called from restore.c
+ * If oldworm is not NULL, assumes the oldworm segments are on map
+ * in the same location as worm segments
*/
void
-place_wsegs(worm)
-struct monst *worm;
+place_wsegs(worm, oldworm)
+struct monst *worm, *oldworm;
{
struct wseg *curr = wtails[worm->wormno];
/* if (!mtmp->wormno) return; bullet proofing */
while (curr != wheads[worm->wormno]) {
- place_worm_seg(worm, curr->wx, curr->wy);
+ xchar x = curr->wx;
+ xchar y = curr->wy;
+
+ if (oldworm) {
+ if (m_at(x,y) == oldworm)
+ remove_monster(x, y);
+ else
+ impossible("placing worm seg <%i,%i> over another mon", x, y);
+ }
+ place_worm_seg(worm, x, y);
curr = curr->nseg;
}
}