fix burned by burning/drowned in a drowning

From a bug report:  you could end up with
gravestone/logfile result of "burned by burning" or "drowned in a drowning".
If you get life-saved when drowning in water or burning in lava, the game
tries to teleport you to safety.  If the teleport fails for some reason--
such as lack of unoccupied non-water or non-lava locations--you drown or
burn again.  But life-saving was resetting the killer reason and the repeat
drowning/burning wasn't setting it up again, so the default got used and
produced a silly result.
This commit is contained in:
nethack.rankin
2006-09-29 02:54:17 +00:00
parent 556226f695
commit d526b4f32f

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)trap.c 3.5 2006/08/05 */ /* SCCS Id: @(#)trap.c 3.5 2006/09/28 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -3032,7 +3032,7 @@ boolean *lostsome;
boolean boolean
drown() drown()
{ {
boolean inpool_ok = FALSE, crawl_ok; boolean inpool_ok = FALSE, crawl_ok, pool_of_water;
int i, x, y; int i, x, y;
/* happily wading in the same contiguous pool */ /* happily wading in the same contiguous pool */
@@ -3154,15 +3154,17 @@ drown()
} }
u.uinwater = 1; u.uinwater = 1;
You("drown."); You("drown.");
killer.format = KILLED_BY_AN; pool_of_water = levl[u.ux][u.uy].typ == POOL || Is_medusa_level(&u.uz);
Strcpy(killer.name, for (;;) {
(levl[u.ux][u.uy].typ == POOL || Is_medusa_level(&u.uz)) ? /* killer format and name are reconstructed every iteration
"pool of water" : "moat"); because lifesaving resets them */
done(DROWNING); killer.format = KILLED_BY_AN;
/* oops, we're still alive. better get out of the water. */ Strcpy(killer.name, pool_of_water ? "pool of water" : "moat");
while (!safe_teleds(TRUE)) { done(DROWNING);
pline("You're still drowning."); /* oops, we're still alive. better get out of the water. */
done(DROWNING); if (safe_teleds(TRUE)) break; /* successful life-save */
/* nowhere safe to land; repeat drowning loop... */
pline("You're still drowning.");
} }
if (u.uinwater) { if (u.uinwater) {
u.uinwater = 0; u.uinwater = 0;
@@ -4235,7 +4237,7 @@ lava_effects()
{ {
register struct obj *obj, *obj2; register struct obj *obj, *obj2;
int dmg = d(6, 6); /* only applicable for water walking */ int dmg = d(6, 6); /* only applicable for water walking */
boolean usurvive; boolean usurvive, boil_away;
usurvive = Fire_resistance || (Wwalking && dmg < u.uhp); usurvive = Fire_resistance || (Wwalking && dmg < u.uhp);
/* a timely interrupt might manage to salvage your life /* a timely interrupt might manage to salvage your life
@@ -4299,16 +4301,20 @@ lava_effects()
iflags.in_lava_effects--; iflags.in_lava_effects--;
/* s/he died... */ /* s/he died... */
u.uhp = -1; boil_away = (u.umonnum == PM_WATER_ELEMENTAL ||
killer.format = KILLED_BY; u.umonnum == PM_STEAM_VORTEX ||
Strcpy(killer.name, lava_killer); u.umonnum == PM_FOG_CLOUD);
You("%s...", for (;;) {
(u.umonnum == PM_WATER_ELEMENTAL) ? u.uhp = -1;
"boil away" : "burn to a crisp"); /* killer format and name are reconstructed every iteration
done(BURNING); because lifesaving resets them */
while (!safe_teleds(TRUE)) { killer.format = KILLED_BY;
pline("You're still burning."); Strcpy(killer.name, lava_killer);
done(BURNING); You("%s...", boil_away ? "boil away" : "burn to a crisp");
done(BURNING);
if (safe_teleds(TRUE)) break; /* successful life-save */
/* nowhere safe to land; repeat burning loop */
pline("You're still burning.");
} }
You("find yourself back on solid %s.", surface(u.ux, u.uy)); You("find yourself back on solid %s.", surface(u.ux, u.uy));
return(TRUE); return(TRUE);