crushed to death by a gas spore's explosion

From the newsgroup, remarking on an usual cause of death seen at NAO.
Surviving a gas spore's explosion (via hit points, not from life-saving)
left "gas spore's explosion" as stale killer.name.  Being killed by
opening a drawbridge (but not by closing or breaking one) only assigned
killer.name if it didn't already have a value, so the stale reason got
used:  crushed to death by a gas spore's explosion.

This fixes it two ways:  clear the stale value after surviving the
explosion, and assign a specific reason when opening the drawbridge.

This also removes stale reason for death set up by various drawbridge
activity.  For the usual case, the hero only survives by life-saving
which does its own clearing of killer.name.  But there might have been
cases where it was being set for the hero when operating on a monster,
so no life-saving involved.  The drawbridge code is not the easiest
code to navigate....
This commit is contained in:
PatR
2017-08-21 15:50:36 -07:00
parent eadecb1baf
commit 0ad33783f0
4 changed files with 31 additions and 24 deletions
+3
View File
@@ -414,6 +414,9 @@ the "bonesid" written into bones files when they're created so that they can
be validated when loaded was incorrect for bones in the quest branch be validated when loaded was incorrect for bones in the quest branch
("QBar.2" ended up being "ar.2", "QKni.4" ended up as "ni.4", and so ("QBar.2" ended up being "ar.2", "QKni.4" ended up as "ni.4", and so
forth) but worked anyway, because validation used same incorrect value forth) but worked anyway, because validation used same incorrect value
surviving a gas spore's explosion would leave that explosion as a stale reason
for death which might show up strangely ("crushed to death by a gas
spore's explosion" when killed by an opening drawbridge)
Fixes to Post-3.6.0 Problems that Were Exposed Via git Repository Fixes to Post-3.6.0 Problems that Were Exposed Via git Repository
+21 -21
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 dbridge.c $NHDT-Date: 1449269914 2015/12/04 22:58:34 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.35 $ */ /* NetHack 3.6 dbridge.c $NHDT-Date: 1503355815 2017/08/21 22:50:15 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.39 $ */
/* Copyright (c) 1989 by Jean-Christophe Collet */ /* Copyright (c) 1989 by Jean-Christophe Collet */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -230,7 +230,6 @@ int *x, *y;
* dir is the direction. * dir is the direction.
* flag must be put to TRUE if we want the drawbridge to be opened. * flag must be put to TRUE if we want the drawbridge to be opened.
*/ */
boolean boolean
create_drawbridge(x, y, dir, flag) create_drawbridge(x, y, dir, flag)
int x, y, dir; int x, y, dir;
@@ -375,7 +374,6 @@ struct entity *etmp;
* Generates capitalized entity name, makes 2nd -> 3rd person conversion on * Generates capitalized entity name, makes 2nd -> 3rd person conversion on
* verb, where necessary. * verb, where necessary.
*/ */
STATIC_OVL const char * STATIC_OVL const char *
E_phrase(etmp, verb) E_phrase(etmp, verb)
struct entity *etmp; struct entity *etmp;
@@ -397,7 +395,6 @@ const char *verb;
/* /*
* Simple-minded "can it be here?" routine * Simple-minded "can it be here?" routine
*/ */
STATIC_OVL boolean STATIC_OVL boolean
e_survives_at(etmp, x, y) e_survives_at(etmp, x, y)
struct entity *etmp; struct entity *etmp;
@@ -486,7 +483,6 @@ int xkill_flags, how;
/* /*
* These are never directly affected by a bridge or portcullis. * These are never directly affected by a bridge or portcullis.
*/ */
STATIC_OVL boolean STATIC_OVL boolean
automiss(etmp) automiss(etmp)
struct entity *etmp; struct entity *etmp;
@@ -498,7 +494,6 @@ struct entity *etmp;
/* /*
* Does falling drawbridge or portcullis miss etmp? * Does falling drawbridge or portcullis miss etmp?
*/ */
STATIC_OVL boolean STATIC_OVL boolean
e_missed(etmp, chunks) e_missed(etmp, chunks)
struct entity *etmp; struct entity *etmp;
@@ -536,7 +531,6 @@ boolean chunks;
/* /*
* Can etmp jump from death? * Can etmp jump from death?
*/ */
STATIC_OVL boolean STATIC_OVL boolean
e_jumps(etmp) e_jumps(etmp)
struct entity *etmp; struct entity *etmp;
@@ -604,6 +598,11 @@ struct entity *etmp;
} }
} else { } else {
if (crm->typ == DRAWBRIDGE_DOWN) { if (crm->typ == DRAWBRIDGE_DOWN) {
if (is_u(etmp)) {
killer.format = NO_KILLER_PREFIX;
Strcpy(killer.name,
"crushed to death underneath a drawbridge");
}
pline("%s crushed underneath the drawbridge.", pline("%s crushed underneath the drawbridge.",
E_phrase(etmp, "are")); /* no jump */ E_phrase(etmp, "are")); /* no jump */
e_died(etmp, e_died(etmp,
@@ -639,11 +638,10 @@ struct entity *etmp;
/* /*
* Here's where we try to do relocation. Assumes that etmp is not * Here's where we try to do relocation. Assumes that etmp is not
* arriving * arriving at the portcullis square while the drawbridge is
* at the portcullis square while the drawbridge is falling, since this * falling, since this square would be inaccessible (i.e. etmp
* square * started on drawbridge square) or unnecessary (i.e. etmp started
* would be inaccessible (i.e. etmp started on drawbridge square) or * here) in such a situation.
* unnecessary (i.e. etmp started here) in such a situation.
*/ */
debugpline0("Doing relocation."); debugpline0("Doing relocation.");
newx = oldx; newx = oldx;
@@ -654,12 +652,10 @@ struct entity *etmp;
debugpline0("Checking new square for occupancy."); debugpline0("Checking new square for occupancy.");
if (relocates && (e_at(newx, newy))) { if (relocates && (e_at(newx, newy))) {
/* /*
* Standoff problem: one or both entities must die, and/or both * Standoff problem: one or both entities must die, and/or
* switch * both switch places. Avoid infinite recursion by checking
* places. Avoid infinite recursion by checking first whether the * first whether the other entity is staying put. Clean up if
* other * we happen to move/die in recursion.
* entity is staying put. Clean up if we happen to move/die in
* recursion.
*/ */
struct entity *other; struct entity *other;
@@ -763,10 +759,12 @@ struct entity *etmp;
} }
} }
/* clear stale reason for death before returning */
#define nokiller() (killer.name[0] = '\0', killer.format = 0)
/* /*
* Close the drawbridge located at x,y * Close the drawbridge located at x,y
*/ */
void void
close_drawbridge(x, y) close_drawbridge(x, y)
int x, y; int x, y;
@@ -823,12 +821,12 @@ int x, y;
newsym(x, y); newsym(x, y);
newsym(x2, y2); newsym(x2, y2);
block_point(x2, y2); /* vision */ block_point(x2, y2); /* vision */
nokiller();
} }
/* /*
* Open the drawbridge located at x,y * Open the drawbridge located at x,y
*/ */
void void
open_drawbridge(x, y) open_drawbridge(x, y)
int x, y; int x, y;
@@ -870,12 +868,12 @@ int x, y;
unblock_point(x2, y2); /* vision */ unblock_point(x2, y2); /* vision */
if (Is_stronghold(&u.uz)) if (Is_stronghold(&u.uz))
u.uevent.uopened_dbridge = TRUE; u.uevent.uopened_dbridge = TRUE;
nokiller();
} }
/* /*
* Let's destroy the drawbridge located at x,y * Let's destroy the drawbridge located at x,y
*/ */
void void
destroy_drawbridge(x, y) destroy_drawbridge(x, y)
int x, y; int x, y;
@@ -898,6 +896,7 @@ int x, y;
|| (lev1->drawbridgemask & DB_UNDER) == DB_LAVA) { || (lev1->drawbridgemask & DB_UNDER) == DB_LAVA) {
struct obj *otmp2; struct obj *otmp2;
boolean lava = (lev1->drawbridgemask & DB_UNDER) == DB_LAVA; boolean lava = (lev1->drawbridgemask & DB_UNDER) == DB_LAVA;
if (lev1->typ == DRAWBRIDGE_UP) { if (lev1->typ == DRAWBRIDGE_UP) {
if (cansee(x2, y2)) if (cansee(x2, y2))
pline_The("portcullis of the drawbridge falls into the %s!", pline_The("portcullis of the drawbridge falls into the %s!",
@@ -999,6 +998,7 @@ int x, y;
do_entity(etmp1); do_entity(etmp1);
} }
} }
nokiller();
} }
/*dbridge.c*/ /*dbridge.c*/
+4 -2
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 explode.c $NHDT-Date: 1496103440 2017/05/30 00:17:20 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.49 $ */ /* NetHack 3.6 explode.c $NHDT-Date: 1503355817 2017/08/21 22:50:17 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.50 $ */
/* Copyright (C) 1990 by Ken Arromdee */ /* Copyright (C) 1990 by Ken Arromdee */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -90,7 +90,9 @@ int expltype;
if (olet == MON_EXPLODE) { if (olet == MON_EXPLODE) {
str = killer.name; str = killer.name;
do_hallu = Hallucination && strstri(str, "'s explosion"); do_hallu = (Hallucination
&& (strstri(str, "'s explosion")
|| strstri(str, "s' explosion")));
adtyp = AD_PHYS; adtyp = AD_PHYS;
} else } else
switch (abs(type) % 10) { switch (abs(type) % 10) {
+3 -1
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 mon.c $NHDT-Date: 1502753408 2017/08/14 23:30:08 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.242 $ */ /* NetHack 3.6 mon.c $NHDT-Date: 1503355818 2017/08/21 22:50:18 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.243 $ */
/* 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. */
@@ -1994,6 +1994,8 @@ boolean was_swallowed; /* digestion */
Sprintf(killer.name, "%s explosion", s_suffix(mdat->mname)); Sprintf(killer.name, "%s explosion", s_suffix(mdat->mname));
killer.format = KILLED_BY_AN; killer.format = KILLED_BY_AN;
explode(mon->mx, mon->my, -1, tmp, MON_EXPLODE, EXPL_NOXIOUS); explode(mon->mx, mon->my, -1, tmp, MON_EXPLODE, EXPL_NOXIOUS);
killer.name[0] = '\0';
killer.format = 0;
return FALSE; return FALSE;
} }
} }