set_corpsenm()
Provide a common routine that always does the right thing with respect to timers and weight when altering obj->corpsenm, and use it throughout the code.
This commit is contained in:
@@ -1146,6 +1146,7 @@ E struct obj *FDECL(mk_tt_object, (int,int,int));
|
||||
E struct obj *FDECL(mk_named_object,
|
||||
(int,struct permonst *,int,int,const char *));
|
||||
E struct obj *FDECL(rnd_treefruit_at, (int, int));
|
||||
E void FDECL(set_corpsenm, (struct obj *, int));
|
||||
E void FDECL(start_corpse_timeout, (struct obj *));
|
||||
E void FDECL(bless, (struct obj *));
|
||||
E void FDECL(unbless, (struct obj *));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)mhitm.c 3.5 2005/12/02 */
|
||||
/* SCCS Id: @(#)mhitm.c 3.5 2006/05/09 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -761,8 +761,7 @@ mdamagem(magr, mdef, mattk)
|
||||
struct obj *virtualcorpse = mksobj(CORPSE, FALSE, FALSE);
|
||||
int nutrit;
|
||||
|
||||
virtualcorpse->corpsenm = num;
|
||||
virtualcorpse->owt = weight(virtualcorpse);
|
||||
set_corpsenm(virtualcorpse, num);
|
||||
nutrit = dog_nutrition(magr, virtualcorpse);
|
||||
dealloc_obj(virtualcorpse);
|
||||
|
||||
|
||||
10
src/mkmaze.c
10
src/mkmaze.c
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)mkmaze.c 3.5 2002/04/04 */
|
||||
/* SCCS Id: @(#)mkmaze.c 3.5 2006/05/09 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -421,8 +421,8 @@ fixup_special()
|
||||
otmp = mk_tt_object(STATUE, x, y);
|
||||
while (otmp && (poly_when_stoned(&mons[otmp->corpsenm]) ||
|
||||
pm_resistance(&mons[otmp->corpsenm],MR_STONE))) {
|
||||
otmp->corpsenm = rndmonnum();
|
||||
otmp->owt = weight(otmp);
|
||||
/* set_corpsenm() handles weight too */
|
||||
set_corpsenm(otmp, rndmonnum());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -435,8 +435,8 @@ fixup_special()
|
||||
if (otmp) {
|
||||
while (pm_resistance(&mons[otmp->corpsenm],MR_STONE)
|
||||
|| poly_when_stoned(&mons[otmp->corpsenm])) {
|
||||
otmp->corpsenm = rndmonnum();
|
||||
otmp->owt = weight(otmp);
|
||||
/* set_corpsenm() handles weight too */
|
||||
set_corpsenm(otmp, rndmonnum());
|
||||
}
|
||||
}
|
||||
} else if(Is_wiz1_level(&u.uz)) {
|
||||
|
||||
39
src/mkobj.c
39
src/mkobj.c
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)mkobj.c 3.5 2006/04/14 */
|
||||
/* SCCS Id: @(#)mkobj.c 3.5 2006/05/09 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -857,6 +857,43 @@ boolean artif;
|
||||
return(otmp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Several areas of the code made direct reassignments
|
||||
* to obj->corpsenm. Because some special handling is
|
||||
* required in certain cases, place that handling here
|
||||
* and call this routine in place of the direct assignment.
|
||||
*
|
||||
* If the object was a lizard or lichen corpse:
|
||||
* - ensure that you don't end up with some
|
||||
* other corpse type which has no rot-away timer.
|
||||
*
|
||||
* If the object was a troll corpse:
|
||||
* - ensure that you don't end up with some other
|
||||
* corpse type which resurrects from the dead.
|
||||
*
|
||||
* Re-calculate the weight of the object to suit the
|
||||
* new species.
|
||||
*
|
||||
*/
|
||||
void
|
||||
set_corpsenm(obj, id)
|
||||
struct obj *obj;
|
||||
int id;
|
||||
{
|
||||
|
||||
if (obj->timed) obj_stop_timers(obj); /* corpse or figurine */
|
||||
obj->corpsenm = id;
|
||||
if (obj->otyp == CORPSE) {
|
||||
start_corpse_timeout(obj);
|
||||
} else if (obj->otyp == FIGURINE) {
|
||||
if (obj->corpsenm != NON_PM
|
||||
&& !dead_species(obj->corpsenm,TRUE)
|
||||
&& (carried(obj) || mcarried(obj)))
|
||||
attach_fig_transform_timeout(obj);
|
||||
}
|
||||
obj->owt = weight(obj);
|
||||
}
|
||||
|
||||
/*
|
||||
* Start a corpse decay or revive timer.
|
||||
* This takes the age of the corpse into consideration as of 3.4.0.
|
||||
|
||||
24
src/sp_lev.c
24
src/sp_lev.c
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)sp_lev.c 3.5 2006/01/28 */
|
||||
/* SCCS Id: @(#)sp_lev.c 3.5 2006/05/09 */
|
||||
/* Copyright (c) 1989 by Jean-Christophe Collet */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -981,23 +981,9 @@ struct mkroom *croom;
|
||||
|
||||
/* corpsenm is "empty" if -1, random if -2, otherwise specific */
|
||||
if (o->corpsenm != NON_PM) {
|
||||
|
||||
/* Corpse was already created above, so the timers are
|
||||
* appropriate for otmp->corpsenm at the time of creation.
|
||||
* Since the next section is about to alter the type of
|
||||
* corpse directly, the timers must be removed, then re-added
|
||||
* afterwards.
|
||||
*
|
||||
* Failure to do so leads to inappropriate corpse types
|
||||
* behaving like a lizard or lichen corpse (no timer), or
|
||||
* behaving like a troll (revive timer).
|
||||
*/
|
||||
|
||||
if (otmp->otyp == CORPSE && otmp->timed) obj_stop_timers(otmp);
|
||||
if (o->corpsenm == NON_PM - 1) otmp->corpsenm = rndmonnum();
|
||||
else otmp->corpsenm = o->corpsenm;
|
||||
if (otmp->otyp == CORPSE) start_corpse_timeout(otmp);
|
||||
otmp->owt = weight(otmp);
|
||||
if (o->corpsenm == NON_PM - 1)
|
||||
set_corpsenm(otmp, rndmonnum());
|
||||
else set_corpsenm(otmp, o->corpsenm);
|
||||
}
|
||||
|
||||
/* assume we wouldn't be given an egg corpsenm unless it was
|
||||
@@ -1058,7 +1044,7 @@ struct mkroom *croom;
|
||||
}
|
||||
mongone(was);
|
||||
}
|
||||
otmp->corpsenm = wastyp;
|
||||
set_corpsenm(otmp, wastyp);
|
||||
while(was->minvent) {
|
||||
obj = was->minvent;
|
||||
obj->owornmask = 0;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)topten.c 3.5 2000/01/21 */
|
||||
/* SCCS Id: @(#)topten.c 3.5 2006/05/09 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -943,12 +943,9 @@ pickentry:
|
||||
}
|
||||
otmp = (struct obj *) 0;
|
||||
} else {
|
||||
/* reset timer in case corpse started out as lizard or troll */
|
||||
if (otmp->otyp == CORPSE) obj_stop_timers(otmp);
|
||||
otmp->corpsenm = classmon(tt->plrole, (tt->plgend[0] == 'F'));
|
||||
otmp->owt = weight(otmp);
|
||||
set_corpsenm(otmp,
|
||||
classmon(tt->plrole, (tt->plgend[0] == 'F')));
|
||||
otmp = oname(otmp, tt->name);
|
||||
if (otmp->otyp == CORPSE) start_corpse_timeout(otmp);
|
||||
}
|
||||
|
||||
(void) fclose(rfile);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)zap.c 3.5 2006/04/17 */
|
||||
/* SCCS Id: @(#)zap.c 3.5 2006/05/09 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -1283,7 +1283,7 @@ poly_obj(obj, id)
|
||||
/* Actually more things use corpsenm but they polymorph differently */
|
||||
#define USES_CORPSENM(typ) ((typ)==CORPSE || (typ)==STATUE || (typ)==FIGURINE)
|
||||
if (USES_CORPSENM(obj->otyp) && USES_CORPSENM(id))
|
||||
otmp->corpsenm = obj->corpsenm;
|
||||
set_corpsenm(otmp, obj->corpsenm);
|
||||
#undef USES_CORPSENM
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user