MCPcopy Create free account
hub / github.com/NetHack/NetHack / light_sources_sanity_check

Function light_sources_sanity_check

src/light.c:605–630  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

603}
604
605void
606light_sources_sanity_check(void)
607{
608 light_source *ls;
609 struct monst *mtmp;
610 struct obj *otmp;
611 unsigned int auint;
612
613 for (ls = gl.light_base; ls; ls = ls->next) {
614 if (!ls->id.a_monst)
615 panic("insane light source: no id!");
616 if (ls->type == LS_OBJECT) {
617 otmp = ls->id.a_obj;
618 auint = otmp->o_id;
619 if (find_oid(auint) != otmp)
620 panic("insane light source: can't find obj #%u!", auint);
621 } else if (ls->type == LS_MONSTER) {
622 mtmp = (struct monst *) ls->id.a_monst;
623 auint = mtmp->m_id;
624 if (find_mid(auint, FM_EVERYWHERE) != mtmp)
625 panic("insane light source: can't find mon #%u!", auint);
626 } else {
627 panic("insane light source: bad ls type %d", ls->type);
628 }
629 }
630}
631
632/* Write a light source structure to disk. */
633staticfn void

Callers 1

sanity_checkFunction · 0.85

Calls 3

find_oidFunction · 0.85
find_midFunction · 0.85
panicFunction · 0.50

Tested by

no test coverage detected