Add sanity checking for long worms
This commit is contained in:
@@ -2761,6 +2761,7 @@ E void FDECL(detect_wsegs, (struct monst *, BOOLEAN_P));
|
|||||||
E void FDECL(save_worm, (int, int));
|
E void FDECL(save_worm, (int, int));
|
||||||
E void FDECL(rest_worm, (int));
|
E void FDECL(rest_worm, (int));
|
||||||
E void FDECL(place_wsegs, (struct monst *));
|
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(remove_worm, (struct monst *));
|
||||||
E void FDECL(place_worm_tail_randomly, (struct monst *, XCHAR_P, XCHAR_P));
|
E void FDECL(place_worm_tail_randomly, (struct monst *, XCHAR_P, XCHAR_P));
|
||||||
E int FDECL(size_wseg, (struct monst *));
|
E int FDECL(size_wseg, (struct monst *));
|
||||||
|
|||||||
@@ -93,6 +93,8 @@ mon_sanity_check()
|
|||||||
else if (level.monsters[x][y] != mtmp)
|
else if (level.monsters[x][y] != mtmp)
|
||||||
impossible("mon (%s) at <%d,%d> is not there!",
|
impossible("mon (%s) at <%d,%d> is not there!",
|
||||||
fmt_ptr((genericptr_t) mtmp), x, y);
|
fmt_ptr((genericptr_t) mtmp), x, y);
|
||||||
|
else if (mtmp->wormno)
|
||||||
|
sanity_check_worm(mtmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (x = 0; x < COLNO; x++)
|
for (x = 0; x < COLNO; x++)
|
||||||
|
|||||||
22
src/worm.c
22
src/worm.c
@@ -569,6 +569,28 @@ struct monst *worm;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
* remove_worm()
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user