fix #K1139 - corpse removed from ice box by monst

Rot and revive timers are turned off when a corpse gets put inside
an ice box.  They get turned back on when taken out of the ice box
by the hero but were being left off if taken out by a monster.
That resulted in corpses of arbitrary type behaving like lizard
corpses and never rotting away.

This fixes that.  It also changes troll corpse behavior.  Once put
in an ice box, a troll corpse will not get a new revive timer when
taken out, just an ordinary rot timer.
This commit is contained in:
PatR
2020-05-30 13:33:16 -07:00
parent 0fed5a06db
commit e9f53ab7f6
6 changed files with 24 additions and 18 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 mkobj.c $NHDT-Date: 1585361051 2020/03/28 02:04:11 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.176 $ */
/* NetHack 3.6 mkobj.c $NHDT-Date: 1590870787 2020/05/30 20:33:07 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.179 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1148,6 +1148,11 @@ struct obj *body;
long corpse_age; /* age of corpse */
int rot_adjust;
short action;
boolean no_revival;
/* if a troll corpse was frozen, it won't get a revive timer */
no_revival = (body->norevive != 0);
body->norevive = 0; /* always clear corpse's 'frozen' flag */
/* lizards and lichen don't rot or revive */
if (body->corpsenm == PM_LIZARD || body->corpsenm == PM_LICHEN)
@@ -1172,8 +1177,9 @@ struct obj *body;
if (!rn2(3))
break;
} else if (mons[body->corpsenm].mlet == S_TROLL && !body->norevive) {
} else if (mons[body->corpsenm].mlet == S_TROLL && !no_revival) {
long age;
for (age = 2; age <= TAINT_AGE; age++)
if (!rn2(TROLL_REVIVE_CHANCE)) { /* troll revives */
action = REVIVE_MON;
@@ -1182,8 +1188,6 @@ struct obj *body;
}
}
if (body->norevive)
body->norevive = 0;
(void) start_timer(when, TIMER_OBJECT, action, obj_to_any(body));
}

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 muse.c $NHDT-Date: 1581726278 2020/02/15 00:24:38 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.120 $ */
/* NetHack 3.6 muse.c $NHDT-Date: 1590870788 2020/05/30 20:33:08 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.127 $ */
/* Copyright (C) 1990 by Ken Arromdee */
/* NetHack may be freely redistributed. See license for details. */
@@ -1958,6 +1958,8 @@ boolean vismon;
pline("%s removes %s.", upstart(mpronounbuf),
doname(xobj));
}
if (container->otyp == ICE_BOX)
removed_from_icebox(xobj); /* resume rotting for corpse */
/* obj_extract_self(xobj); -- already done above */
(void) mpickobj(mon, xobj);
res = 2;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 pickup.c $NHDT-Date: 1583515468 2020/03/06 17:24:28 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.263 $ */
/* NetHack 3.6 pickup.c $NHDT-Date: 1590870789 2020/05/30 20:33:09 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.269 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
@@ -36,7 +36,6 @@ static void FDECL(do_boh_explosion, (struct obj *, BOOLEAN_P));
static long FDECL(boh_loss, (struct obj *, int));
static int FDECL(in_container, (struct obj *));
static int FDECL(out_container, (struct obj *));
static void FDECL(removed_from_icebox, (struct obj *));
static long FDECL(mbag_item_gone, (int, struct obj *, BOOLEAN_P));
static void FDECL(explain_container_prompt, (BOOLEAN_P));
static int FDECL(traditional_loot, (BOOLEAN_P));
@@ -2353,12 +2352,8 @@ register struct obj *obj;
obj->age = g.monstermoves - obj->age; /* actual age */
/* stop any corpse timeouts when frozen */
if (obj->otyp == CORPSE && obj->timed) {
long rot_alarm = stop_timer(ROT_CORPSE, obj_to_any(obj));
(void) stop_timer(ROT_CORPSE, obj_to_any(obj));
(void) stop_timer(REVIVE_MON, obj_to_any(obj));
/* mark a non-reviving corpse as such */
if (rot_alarm)
obj->norevive = 1;
}
} else if (Is_mbag(g.current_container) && mbag_explodes(obj, 0)) {
/* explicitly mention what item is triggering the explosion */
@@ -2487,14 +2482,17 @@ register struct obj *obj;
}
/* taking a corpse out of an ice box needs a couple of adjustments */
static void
void
removed_from_icebox(obj)
struct obj *obj;
{
if (!age_is_relative(obj)) {
obj->age = g.monstermoves - obj->age; /* actual age */
if (obj->otyp == CORPSE)
if (obj->otyp == CORPSE) {
/* start a rot-away timer but not a troll's revive timer */
obj->norevive = 1;
start_corpse_timeout(obj);
}
}
}