Trap sanity checking

This commit is contained in:
Pasi Kallinen
2022-03-04 16:54:26 +02:00
parent 80e7fbe8ec
commit 62906e732e
3 changed files with 18 additions and 0 deletions

View File

@@ -2736,6 +2736,7 @@ extern void sokoban_guilt(void);
extern const char * trapname(int, boolean);
extern void ignite_items(struct obj *);
extern void trap_ice_effects(xchar x, xchar y, boolean ice_is_melting);
extern void trap_sanity_check(void);
/* ### u_init.c ### */

View File

@@ -3419,6 +3419,7 @@ sanity_check(void)
mon_sanity_check();
light_sources_sanity_check();
bc_sanity_check();
trap_sanity_check();
}
#ifdef DEBUG_MIGRATING_MONS

View File

@@ -6125,4 +6125,20 @@ trap_ice_effects(xchar x, xchar y, boolean ice_is_melting)
}
}
}
/* sanity check traps */
void
trap_sanity_check(void)
{
struct trap *ttmp = g.ftrap;
while (ttmp) {
if (!isok(ttmp->tx, ttmp->ty))
impossible("trap sanity: location");
if (ttmp->ttyp < 0 || ttmp->ttyp >= TRAPNUM)
impossible("trap sanity: type");
ttmp = ttmp->ntrap;
}
}
/*trap.c*/