]> granicus.if.org Git - nethack/commitdiff
discard_minvent
authornethack.rankin <nethack.rankin>
Sun, 22 Apr 2007 02:38:47 +0000 (02:38 +0000)
committernethack.rankin <nethack.rankin>
Sun, 22 Apr 2007 02:38:47 +0000 (02:38 +0000)
     Genociding * to clear a level in wizard mode, or paying off a
shopkeeper to dismiss kops in any mode, could trigger the recently added
warning about deleting worn items in obfree().  mongone -> discard_minvent
wasn't bothering to unwear/unwield monster gear before deletion.

src/mkobj.c

index af7fe366dd2cfae53f6354bc1ee771a96709b466..ad2991ae0281492464370bf974bdc87f0cd4374c 100644 (file)
@@ -1565,10 +1565,20 @@ void
 discard_minvent(mtmp)
 struct monst *mtmp;
 {
-    struct obj *otmp;
+    struct obj *otmp, *mwep = MON_WEP(mtmp);
+    boolean keeping_mon = (mtmp->mhp > 0);
 
     while ((otmp = mtmp->minvent) != 0) {
+       /* this has now become very similar to m_useupall()... */
        obj_extract_self(otmp);
+       if (otmp->owornmask) {
+           if (keeping_mon) {
+               if (otmp == mwep) mwepgone(mtmp), mwep = 0;
+               mtmp->misc_worn_check &= ~otmp->owornmask;
+               update_mon_intrinsics(mtmp, otmp, FALSE, TRUE);
+           }
+           otmp->owornmask = 0L;       /* obfree() expects this */
+       }
        obfree(otmp, (struct obj *)0);  /* dealloc_obj() isn't sufficient */
     }
 }