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

Function mon_obj_sanity

src/mkobj.c:3203–3246  ·  view source on GitHub ↗

sanity check for objects carried by all monsters in specified list */

Source from the content-addressed store, hash-verified

3201
3202/* sanity check for objects carried by all monsters in specified list */
3203staticfn void
3204mon_obj_sanity(struct monst *monlist, const char *mesg)
3205{
3206 struct monst *mon;
3207 struct obj *obj, *mwep;
3208
3209 for (mon = monlist; mon; mon = mon->nmon) {
3210 if (DEADMONSTER(mon))
3211 continue;
3212 mwep = MON_WEP(mon); /* mon->mw */
3213 if (mwep) {
3214 if (!mcarried(mwep))
3215 insane_object(mwep, mfmt1, mesg, mon);
3216 if (mwep->ocarry != mon)
3217 insane_object(mwep, mfmt2, mesg, mon);
3218 }
3219 for (obj = mon->minvent; obj; obj = obj->nobj) {
3220 if (obj->where != OBJ_MINVENT)
3221 insane_object(obj, mfmt1, mesg, mon);
3222 if (obj->ocarry != mon)
3223 insane_object(obj, mfmt2, mesg, mon);
3224 if (obj->globby)
3225 check_glob(obj, mesg);
3226 check_contained(obj, mesg);
3227 if (obj->unpaid || obj->no_charge)
3228 shop_obj_sanity(obj, mesg);
3229 if (obj->in_use || obj->bypass || obj->nomerge
3230 || (obj->otyp == BOULDER && obj->next_boulder))
3231 insane_obj_bits(obj, mon);
3232 if (obj == mwep)
3233 mwep = (struct obj *) 0;
3234 }
3235 if (mwep) {
3236 /* this is a monster check rather than an object check, but doing
3237 it here avoids making an extra pass through mon's minvent;
3238 if the full pass through that list hasn't reset mwep to Null,
3239 then mwep isn't in that list where it should be */
3240 impossible("monst (%s: %u) wielding %s (%u) not in %s inventory",
3241 pmname(mon->data, Mgender(mon)), mon->m_id,
3242 safe_typename(mwep->otyp), mwep->o_id, mhis(mon));
3243
3244 }
3245 }
3246}
3247
3248staticfn void
3249insane_obj_bits(struct obj *obj, struct monst *mon)

Callers 1

obj_sanity_checkFunction · 0.85

Calls 9

insane_objectFunction · 0.85
check_globFunction · 0.85
check_containedFunction · 0.85
shop_obj_sanityFunction · 0.85
insane_obj_bitsFunction · 0.85
pmnameFunction · 0.85
MgenderFunction · 0.85
safe_typenameFunction · 0.85
impossibleFunction · 0.70

Tested by

no test coverage detected