Fix splitting monster being killed twice

Fuzzer encountered "m_detach: monster already detached?"

A monster hit a black pudding that split. The clone was
created on top of a rolling boulder trap, which triggered,
the boulder hit the original black pudding, and killed it.
The dead pudding then retaliated (as the code didn't check
if it was dead) and a passive attack of the other monster
tried to kill the already dead pudding.

I think one of these checks would be enough, but adding the
DEADMONSTER check just in case.
This commit is contained in:
Pasi Kallinen
2023-10-21 19:41:17 +03:00
parent ff4f81af1b
commit 79496b079a
2 changed files with 3 additions and 1 deletions

View File

@@ -454,6 +454,8 @@ mattackm(
pline("%s divides as %s hits it!",
Monnam(mdef), mon_nam(magr));
(void) mintrap(mclone, NO_TRAP_FLAGS);
if (DEADMONSTER(magr))
res[i] |= M_ATTK_AGR_DIED;
}
}
} else

View File

@@ -1892,7 +1892,7 @@ m_move_aggress(struct monst *mtmp, coordxy x, coordxy y)
mstatus = mattackm(mtmp, mtmp2);
}
if (mstatus & M_ATTK_AGR_DIED) /* aggressor died */
if ((mstatus & M_ATTK_AGR_DIED) || DEADMONSTER(mtmp)) /* aggressor died */
return MMOVE_DIED;
if ((mstatus & (M_ATTK_HIT | M_ATTK_DEF_DIED)) == M_ATTK_HIT