Fix dmonsfree warning caused by knockback

When a monster being attacked was knocked back into a level
teleport trap, the attacker could still hit the defender.
If the second hit then killed the defender, this could result
in dmonsfree warning.
This commit is contained in:
Pasi Kallinen
2023-05-07 22:02:01 +03:00
parent 3ffb69bf2f
commit 9ca1c5fb56
3 changed files with 6 additions and 1 deletions

View File

@@ -559,6 +559,9 @@ mattackm(register struct monst *magr, register struct monst *mdef)
/* return if aggressor can no longer attack */
if (helpless(magr))
return res[i];
/* eg. defender was knocked into a level teleport trap */
if (mon_offmap(mdef))
return res[i];
if (res[i] & M_ATTK_HIT)
struck = 1; /* at least one hit */
} /* for (;i < NATTK;) loop */

View File

@@ -989,7 +989,7 @@ movemon_singlemon(struct monst *mtmp)
return FALSE;
/* monster isn't on this map anymore */
if ((mtmp->mstate & (MON_DETACH|MON_MIGRATING|MON_LIMBO|MON_OFFMAP)) != 0)
if (mon_offmap(mtmp))
return FALSE;
/* Find a monster that we have not treated yet. */