]> granicus.if.org Git - nethack/commitdiff
fix #H9298 - corpse mismatch
authorPatR <rankin@nethack.org>
Sat, 12 Oct 2019 09:31:47 +0000 (02:31 -0700)
committerPatR <rankin@nethack.org>
Sat, 12 Oct 2019 09:31:47 +0000 (02:31 -0700)
Corpses for dying monsters were being created with the wrong type,
caused by incorrect block nesting for 'if (ptr)' from commit
ad302fb8a99a5795c4d206870ea6573349b2d92a (Oct 10).

doc/fixes36.3
src/mkobj.c

index 2fdd04027fa365a9938186aa7b23fe211c1aae63..a2467729c995173175bff199dd0ec87dae87b171 100644 (file)
@@ -1,4 +1,4 @@
-$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.128 $ $NHDT-Date: 1570652307 2019/10/09 20:18:27 $
+$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.132 $ $NHDT-Date: 1570872701 2019/10/12 09:31:41 $
 
 This fixes36.3 file is here to capture information about updates in the 3.6.x
 lineage following the release of 3.6.2 in May 2019. Please note, however,
@@ -201,6 +201,7 @@ monster throwing from stack of missiles (darts, daggers, spears) would cause
        crash if it wasn't wielding a weapon (bug in multi-shot shooting fix)
 surviving death while polymorphed would yield "You are a <foo>" without
        terminating period
+'mksobj failure' commit resulted in wrong corpse types for dying monsters
 curses: sometimes the message window would show a blank line after a prompt
 curses: the change to show map in columns 1..79 instead of 2..80 made the
        highlight for '@' show up in the wrong place if clipped map had been
index a92deceb67817505f074e8503ae860710297f123..6975ca966811c4a1688ad9bcf8a057c146344886 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 mkobj.c $NHDT-Date: 1570754586 2019/10/11 00:43:06 $  $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.154 $ */
+/* NetHack 3.6 mkobj.c $NHDT-Date: 1570872702 2019/10/12 09:31:42 $  $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.155 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Derek S. Ray, 2015. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -1540,18 +1540,20 @@ unsigned corpstatflags;
         otmp = mksobj_at(objtype, x, y, init, FALSE);
     }
 
-    /* when 'mtmp' is non-null make a corpse or statue of that monster,
-       otherwise keep the random type chosen by mksobj() */
+    /* when 'mtmp' is non-null save the monster's details with the
+       corpse or statue; it will also force the 'ptr' override below */
     if (mtmp) {
-        int old_corpsenm = otmp->corpsenm;
-
         /* save_mtraits updates otmp->oextra->omonst in place */
         (void) save_mtraits(otmp, mtmp);
 
-        /* when 'ptr' is non-null use the type specified by our caller,
-           otherwise use the monster's species for the corpse */
         if (!ptr)
             ptr = mtmp->data;
+    }
+
+    /* when 'ptr' is non-null it comes from our caller or from 'mtmp';
+       override mkobjs()'s initialization of a random monster type */
+    if (ptr) {
+        int old_corpsenm = otmp->corpsenm;
 
         otmp->corpsenm = monsndx(ptr);
         otmp->owt = weight(otmp);