vault guard bug: dropping minvent at <0,0> (trunk only)

From the newsgroup:  after killing a vault guard on a level where
every object had been removed or was held by the hero, object detection
gave feedback about finding something but was unable to show anything.
It was finding the dead guard's inventory at <0,0>, a part of the map
which never gets shown.  A dying guard is sent to that location instead
of being killed and deleted, because the data for his temporary corridor
to/from the vault is kept in the egd structure attached to him.  That's
somewhat obscure but works; dying guards just need to drop inventory
before being transfered there rather than after.

     Depending upon how they're killed, it's possible that the umpteen
places in the code that loop over fmon might have been processing them
as if still in play.  This sets their mhp to 0 so such loops will ignore
them, and teaches dmonsfree() not to release them.  Once the temporary
corridor has been removed, their isgd flag is cleared and they become
ordinary dead monsters and get deleted from the fmon list the next time
it's purged.

     This also lets you throw gold to/at the guard when he tells you to
drop it.  He already would catch it, but now he won't treat the throw as
an attack.  Any gold he carries will eventually disappear when he does,
so dropping it remains a better option for the player.
This commit is contained in:
nethack.rankin
2011-10-09 02:13:01 +00:00
parent 23cace2251
commit bd172eb167
5 changed files with 88 additions and 69 deletions

View File

@@ -1261,17 +1261,17 @@ register int x,y;
void
dmonsfree()
{
struct monst **mtmp;
struct monst **mtmp, *freetmp;
int count = 0;
for (mtmp = &fmon; *mtmp;) {
if ((*mtmp)->mhp <= 0) {
struct monst *freetmp = *mtmp;
*mtmp = (*mtmp)->nmon;
freetmp = *mtmp;
if (freetmp->mhp <= 0 && !freetmp->isgd) {
*mtmp = freetmp->nmon;
dealloc_monst(freetmp);
count++;
} else
mtmp = &(*mtmp)->nmon;
mtmp = &(freetmp->nmon);
}
if (count != iflags.purge_monsters)
@@ -1534,11 +1534,6 @@ register struct monst *mtmp;
struct permonst *mptr;
int tmp;
if(mtmp->isgd) {
/* if we're going to abort the death, it *must* be before
* the m_detach or there will be relmon problems later */
if(!grddead(mtmp)) return;
}
lifesaved_monster(mtmp);
if (mtmp->mhp > 0) return;
@@ -1588,6 +1583,11 @@ register struct monst *mtmp;
}
}
/* dead vault guard is actually kept at coordinate <0,0> until
his temporary corridor to/from the vault has been removed;
need to do this after life-saving and before m_detach() */
if (mtmp->isgd && !grddead(mtmp)) return;
#ifdef STEED
/* Player is thrown from his steed when it dies */
if (mtmp == u.usteed)