]> granicus.if.org Git - nethack/commitdiff
#H85: create_object() bugs
authornethack.allison <nethack.allison>
Tue, 9 May 2006 01:31:55 +0000 (01:31 +0000)
committernethack.allison <nethack.allison>
Tue, 9 May 2006 01:31:55 +0000 (01:31 +0000)
From a bug report.c was first creating  a corpse
complete with revive timer if it was a troll, or without
a timer if it was a lizard or lichen corpse. Then it might
change the corpse type, leaving strange corpse
types that revived, or that lasted forever.

doc/fixes34.4
src/sp_lev.c

index e6433291e56163c0d3f3c5b7e66aadbf0c8d0a79..e2c7f5d724ee4bc38a6b89edc41244c47d1489e8 100644 (file)
@@ -215,6 +215,8 @@ properly handle destruction of equipment carried by monsters hit by
        disintegration breath; life-saving retained conferred properties of
        formerly worn items (loss of steed's saddle caused much confusion)
 don't exercize or abuse wisdom when rumors get used for random graffiti
+create_object() created lizard corpses without timers and troll corpses with
+       their revive timers, then changed the corpsenm field
 
 
 Platform- and/or Interface-Specific Fixes
index b9add6cac59937dead3dfdf830a5701aa97f1851..149c7118c4b3c94a5bd3e48902e0184c52c0f4b1 100644 (file)
@@ -981,8 +981,22 @@ 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);
        }