Trap sanity checking

This commit is contained in:
Pasi Kallinen
2022-03-04 16:54:43 +02:00
parent 80e7fbe8ec
commit 62906e732e
3 changed files with 18 additions and 0 deletions
+1
View File
@@ -2736,6 +2736,7 @@ extern void sokoban_guilt(void);
extern const char * trapname(int, boolean); extern const char * trapname(int, boolean);
extern void ignite_items(struct obj *); extern void ignite_items(struct obj *);
extern void trap_ice_effects(xchar x, xchar y, boolean ice_is_melting); extern void trap_ice_effects(xchar x, xchar y, boolean ice_is_melting);
extern void trap_sanity_check(void);
/* ### u_init.c ### */ /* ### u_init.c ### */
+1
View File
@@ -3419,6 +3419,7 @@ sanity_check(void)
mon_sanity_check(); mon_sanity_check();
light_sources_sanity_check(); light_sources_sanity_check();
bc_sanity_check(); bc_sanity_check();
trap_sanity_check();
} }
#ifdef DEBUG_MIGRATING_MONS #ifdef DEBUG_MIGRATING_MONS
+16
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*/ /*trap.c*/