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 *));
-/* 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. */
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);
-/* 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. */
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());
}
}
}
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)) {
-/* 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. */
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.
-/* 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. */
/* 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
}
mongone(was);
}
- otmp->corpsenm = wastyp;
+ set_corpsenm(otmp, wastyp);
while(was->minvent) {
obj = was->minvent;
obj->owornmask = 0;
-/* 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. */
}
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);
-/* 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. */
/* 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
}