| 70 | } |
| 71 | |
| 72 | staticfn void |
| 73 | sanity_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)) |
no test coverage detected