Add sanity checking for light sources
This commit is contained in:
@@ -971,6 +971,7 @@ E struct monst *FDECL(find_mid, (unsigned, unsigned));
|
||||
E void FDECL(save_light_sources, (int, int, int));
|
||||
E void FDECL(restore_light_sources, (int));
|
||||
E void FDECL(relink_light_sources, (BOOLEAN_P));
|
||||
E void NDECL(light_sources_sanity_check);
|
||||
E void FDECL(obj_move_light_source, (struct obj *, struct obj *));
|
||||
E boolean NDECL(any_light_source);
|
||||
E void FDECL(snuff_light_source, (int, int));
|
||||
|
||||
@@ -3069,6 +3069,7 @@ sanity_check()
|
||||
obj_sanity_check();
|
||||
timer_sanity_check();
|
||||
mon_sanity_check();
|
||||
light_sources_sanity_check();
|
||||
}
|
||||
|
||||
#ifdef DEBUG_MIGRATING_MONS
|
||||
|
||||
25
src/light.c
25
src/light.c
@@ -383,6 +383,31 @@ boolean write_it;
|
||||
return count;
|
||||
}
|
||||
|
||||
void
|
||||
light_sources_sanity_check()
|
||||
{
|
||||
light_source *ls;
|
||||
unsigned int auint;
|
||||
|
||||
for (ls = light_base; ls; ls = ls->next) {
|
||||
if (!ls->id.a_monst)
|
||||
panic("insane light source: no id!");
|
||||
if (ls->type == LS_OBJECT) {
|
||||
struct obj *otmp = (struct obj *) ls->id.a_obj;
|
||||
auint = otmp->o_id;
|
||||
if (find_oid(auint) != otmp)
|
||||
panic("insane light source: can't find obj #%u!", auint);
|
||||
} else if (ls->type == LS_MONSTER) {
|
||||
struct monst *mtmp = (struct monst *) ls->id.a_monst;
|
||||
auint = mtmp->m_id;
|
||||
if (find_mid(auint, FM_EVERYWHERE) != mtmp)
|
||||
panic("insane light source: can't find mon #%u!", auint);
|
||||
} else {
|
||||
panic("insane light source: bad ls type %d", ls->type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Write a light source structure to disk. */
|
||||
STATIC_OVL void
|
||||
write_ls(fd, ls)
|
||||
|
||||
Reference in New Issue
Block a user