E void FDECL(save_worm, (int, int));
E void FDECL(rest_worm, (int));
E void FDECL(place_wsegs, (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));
E int FDECL(size_wseg, (struct monst *));
else if (level.monsters[x][y] != mtmp)
impossible("mon (%s) at <%d,%d> is not there!",
fmt_ptr((genericptr_t) mtmp), x, y);
+ else if (mtmp->wormno)
+ sanity_check_worm(mtmp);
}
for (x = 0; x < COLNO; x++)
}
}
+void
+sanity_check_worm(worm)
+struct monst *worm;
+{
+ struct wseg *curr;
+
+ if (!worm)
+ panic("no worm!");
+ if (!worm->wormno)
+ panic("not a worm?!");
+
+ curr = wtails[worm->wormno];
+
+ while (curr != wheads[worm->wormno]) {
+ if (!isok(curr->wx, curr->wy))
+ panic("worm seg not isok");
+ if (level.monsters[curr->wx][curr->wy] != worm)
+ panic("worm not at seg location");
+ curr = curr->nseg;
+ }
+}
+
/*
* remove_worm()
*