* 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 */
| 612 | * in the same location as worm segments |
| 613 | */ |
| 614 | void |
| 615 | place_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) */ |
| 638 | void |
no test coverage detected