montraits vs monst->mstate

The new test in m_detach(mon) to check whether mon was already detached
is being tripped for trolls who died, revived, and died again.  Clear
out the MON_DETACH bit when saving montraits.
This commit is contained in:
PatR
2022-07-16 06:36:45 -07:00
parent cb036d11e2
commit fcbeed21cc
2 changed files with 3 additions and 0 deletions

View File

@@ -1018,6 +1018,8 @@ makemap_unmakemon(struct monst *mtmp, boolean migratory)
so that dmonsfree() bookkeeping for number of dead or removed
monsters won't get out of sync; it is not on the map but
mongone() -> m_detach() -> mon_leaving_level() copes with that */
mtmp->mstate |= MON_OFFMAP;
mtmp->mstate &= ~(MON_MIGRATING | MON_LIMBO);
mtmp->nmon = fmon;
fmon = mtmp;
}

View File

@@ -1982,6 +1982,7 @@ save_mtraits(struct obj *obj, struct monst *mtmp)
mtmp2->mhp = mtmp2->mhpmax;
if (mtmp2->mhp < 1)
mtmp2->mhp = 0;
mtmp2->mstate &= ~MON_DETACH;
}
return obj;
}