water vs acid

Fix the bug From a bug report.alt.org server, where killing a monster by closing the
castle drawbridge resulted in a panic after the dead monster's possessions
were dropped into the moat and a potion of acid exploded in the process.
water_damage() deleted the object but had no way to tell flooreffects()
that it was gone, so flooreffects() couldn't tell its own caller not to
place and stack the object.  After that, a chunk of freed memory became
part of the floor objects chain and eventually triggered a panic which
tried to make a save file but whose reason didn't get logged properly.
This commit is contained in:
nethack.rankin
2006-05-11 03:26:55 +00:00
parent 45b59990cd
commit a73d997034
7 changed files with 43 additions and 24 deletions

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)mon.c 3.5 2006/04/14 */
/* SCCS Id: @(#)mon.c 3.5 2006/05/08 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -398,7 +398,7 @@ register struct monst *mtmp;
if (mtmp->data == &mons[PM_GREMLIN] && (inpool || infountain) && rn2(3)) {
if (split_mon(mtmp, (struct monst *)0))
dryup(mtmp->mx, mtmp->my, FALSE);
if (inpool) water_damage(mtmp->minvent, FALSE, FALSE);
if (inpool) water_damage(&mtmp->minvent, FALSE, FALSE);
return (0);
} else if (mtmp->data == &mons[PM_IRON_GOLEM] && inpool && !rn2(5)) {
int dam = d(2,6);
@@ -410,7 +410,7 @@ register struct monst *mtmp;
mondead(mtmp);
if (mtmp->mhp < 1) return (1);
}
water_damage(mtmp->minvent, FALSE, FALSE);
water_damage(&mtmp->minvent, FALSE, FALSE);
return (0);
}
@@ -463,8 +463,8 @@ register struct monst *mtmp;
}
mondead(mtmp);
if (mtmp->mhp > 0) {
water_damage(&mtmp->minvent, FALSE, FALSE);
(void) rloc(mtmp, FALSE);
water_damage(mtmp->minvent, FALSE, FALSE);
return 0;
}
return (1);