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

Function sanity_check_single_mon

src/mon.c:72–255  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72staticfn void
73sanity_check_single_mon(
74 struct monst *mtmp,
75 boolean chk_geno,
76 const char *msg)
77{
78 struct permonst *mptr = mtmp->data;
79 coordxy mx = mtmp->mx, my = mtmp->my;
80
81 if (!mptr || mptr < &mons[LOW_PM] || mptr > &mons[HIGH_PM]) {
82 /* most sanity checks issue warnings if they detect a problem,
83 but this would be too extreme to keep going */
84 panic("illegal mon data %s; mnum=%d (%s)",
85 fmt_ptr((genericptr_t) mptr), mtmp->mnum, msg);
86 /*NOTREACHED*/
87 } else {
88 int mndx = monsndx(mptr);
89
90 if (mtmp->mnum != mndx) {
91 impossible("monster mnum=%d, monsndx=%d (%s)",
92 mtmp->mnum, mndx, msg);
93 mtmp->mnum = mndx;
94 }
95 /* check before DEADMONSTER() because dead monsters should still
96 have sane mhpmax */
97 if (mtmp->mhpmax < 1
98 /* Gremlins don't obey the (mhpmax >= m_lev) rule so disable
99 * this check, at least for the time being. We could skip it
100 * when the cloned flag is set, but the original gremlin would
101 * still be an issue.
102 || mtmp->mhpmax < (int) mtmp->m_lev
103 */
104 || mtmp->mhp > mtmp->mhpmax)
105 impossible("%s: level %d %s #%u [%s] has %d cur HP, %d max HP",
106 msg, (int) mtmp->m_lev, mptr->pmnames[NEUTRAL],
107 mtmp->m_id, fmt_ptr((genericptr_t) mtmp),
108 mtmp->mhp, mtmp->mhpmax);
109 if (DEADMONSTER(mtmp)) {
110#if 0
111 /* bad if not fmon list or if not vault guard */
112 if (strcmp(msg, "fmon") || !mtmp->isgd)
113 impossible("dead monster on %s; %s at <%d,%d>",
114 msg, mptr->pmnames[NEUTRAL], mx, my);
115#endif
116 return;
117 }
118 if (chk_geno && (svm.mvitals[mndx].mvflags & G_GENOD) != 0)
119 impossible("genocided %s in play (%s)",
120 pmname(mptr, Mgender(mtmp)), msg);
121 if (mtmp->mtame && !mtmp->mpeaceful)
122 impossible("tame %s is not peaceful (%s)",
123 pmname(mptr, Mgender(mtmp)), msg);
124 }
125 if (mtmp->isshk && !has_eshk(mtmp))
126 impossible("shk without eshk (%s)", msg);
127 if (mtmp->ispriest && !has_epri(mtmp))
128 impossible("priest without epri (%s)", msg);
129 if (mtmp->isgd && !has_egd(mtmp))

Callers 1

mon_sanity_checkFunction · 0.85

Calls 15

fmt_ptrFunction · 0.85
pmnameFunction · 0.85
MgenderFunction · 0.85
pet_sanity_checkFunction · 0.85
m_carryingFunction · 0.85
which_armorFunction · 0.85
t_atFunction · 0.85
isokFunction · 0.85
is_poolFunction · 0.85
has_ceilingFunction · 0.85
accessibleFunction · 0.85
levltyp_to_nameFunction · 0.85

Tested by

no test coverage detected