MCPcopy Create free account
hub / github.com/NetHack/NetHack / place_wsegs

Function place_wsegs

src/worm.c:614–635  ·  view source on GitHub ↗

* place_wsegs() * * Place the segments of the given worm. Called from restore.c * and from replmon() in mon.c. * If oldworm is not NULL, assumes the oldworm segments are on map * in the same location as worm segments */

Source from the content-addressed store, hash-verified

612 * in the same location as worm segments
613 */
614void
615place_wsegs(struct monst *worm, struct monst *oldworm)
616{
617 struct wseg *curr = wtails[worm->wormno];
618
619 while (curr != wheads[worm->wormno]) {
620 coordxy x = curr->wx, y = curr->wy;
621 struct monst *mtmp = m_at(x, y);
622
623 if (oldworm && mtmp == oldworm)
624 remove_monster(x, y);
625 else if (mtmp)
626 impossible("placing worm seg <%d,%d> over another mon", x, y);
627 else if (oldworm)
628 impossible("replacing worm seg <%d,%d> on empty spot", x, y);
629
630 place_worm_seg(worm, x, y);
631 curr = curr->nseg;
632 }
633 /* head segment is co-located with worm itself so not placed on the map */
634 curr->wx = worm->mx, curr->wy = worm->my;
635}
636
637/* called from mon_sanity_check(mon.c) */
638void

Callers 3

cutwormFunction · 0.85
getlevFunction · 0.85
replmonFunction · 0.85

Calls 1

impossibleFunction · 0.70

Tested by

no test coverage detected