Add monster data sanity checking
This commit is contained in:
@@ -1280,6 +1280,7 @@ E int FDECL(cmap_to_type, (int));
|
|||||||
|
|
||||||
/* ### mon.c ### */
|
/* ### mon.c ### */
|
||||||
|
|
||||||
|
E void NDECL(mon_sanity_check);
|
||||||
E int FDECL(undead_to_corpse, (int));
|
E int FDECL(undead_to_corpse, (int));
|
||||||
E int FDECL(genus, (int, int));
|
E int FDECL(genus, (int, int));
|
||||||
E int FDECL(pm_to_cham, (int));
|
E int FDECL(pm_to_cham, (int));
|
||||||
|
|||||||
@@ -3067,6 +3067,7 @@ sanity_check()
|
|||||||
{
|
{
|
||||||
obj_sanity_check();
|
obj_sanity_check();
|
||||||
timer_sanity_check();
|
timer_sanity_check();
|
||||||
|
mon_sanity_check();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_MIGRATING_MONS
|
#ifdef DEBUG_MIGRATING_MONS
|
||||||
|
|||||||
@@ -39,6 +39,40 @@ const char *warnings[] = {
|
|||||||
};
|
};
|
||||||
#endif /* 0 */
|
#endif /* 0 */
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
sanity_check_single_mon(mtmp, msg)
|
||||||
|
struct monst *mtmp;
|
||||||
|
const char *msg;
|
||||||
|
{
|
||||||
|
if (DEADMONSTER(mtmp)) return;
|
||||||
|
if ((mtmp->data < &mons[LOW_PM]) || (mtmp->data >= &mons[NUMMONS]))
|
||||||
|
impossible("illegal mon data (%s)", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
mon_sanity_check()
|
||||||
|
{
|
||||||
|
int x,y;
|
||||||
|
struct monst *mtmp = fmon;
|
||||||
|
|
||||||
|
while (mtmp) {
|
||||||
|
sanity_check_single_mon(mtmp, "fmon");
|
||||||
|
mtmp = mtmp->nmon;
|
||||||
|
}
|
||||||
|
for (x = 0; x < COLNO; x++)
|
||||||
|
for (y = 0; y < ROWNO; y++)
|
||||||
|
if ((mtmp = m_at(x,y)) != 0)
|
||||||
|
sanity_check_single_mon(mtmp, "m_at");
|
||||||
|
|
||||||
|
mtmp = migrating_mons;
|
||||||
|
while (mtmp) {
|
||||||
|
sanity_check_single_mon(mtmp, "migr");
|
||||||
|
mtmp = mtmp->nmon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* convert the monster index of an undead to its living counterpart */
|
/* convert the monster index of an undead to its living counterpart */
|
||||||
int
|
int
|
||||||
undead_to_corpse(mndx)
|
undead_to_corpse(mndx)
|
||||||
|
|||||||
Reference in New Issue
Block a user