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:
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.
|
||||
|
||||
Reference in New Issue
Block a user