]> granicus.if.org Git - nethack/commitdiff
fix #H2010 - quaffing wielded potion of polymorph
authornethack.rankin <nethack.rankin>
Sat, 22 Aug 2009 01:14:48 +0000 (01:14 +0000)
committernethack.rankin <nethack.rankin>
Sat, 22 Aug 2009 01:14:48 +0000 (01:14 +0000)
     From a bug report, drinking a potion of
polymorph which is wielded would trigger an "object lost" panic if hero
took on a form that was forced to drop its weapon.  Once weapon/potion
got dropped, subsequent useup() of the potion was no longer operating on
an inventory object.

     Unwield the potion at start of drinking, so that dropping doesn't
come into play.  (If we ever introduce a monster form incapable of
holding inventory so drops everything, this will have to be revisited.)

doc/fixes34.4
src/potion.c

index 83d7a4ee18ef26a3100b774f0f3ff2e1bda309c1..396d34dd5473be3b3609f44286a756d303c57b4a 100644 (file)
@@ -384,6 +384,8 @@ hero poly'd into mimic and hiding as an object via #monster didn't unhide
        when polymorphing into non-mimic
 message "You hit the  with all your might." could be issued if a boulder
        went away while it was being dug/broken with a pick-axe
+prevent "object lost" panic if/when drinking a wielded potion of polymorph
+       causes hero's new form to drop weapon
 
 
 Platform- and/or Interface-Specific Fixes
index bcfac72fb0f7efdb398978a211478f0144cfa939..e3130b2f30899db2f564ec07cd300d2df8c80b0e 100644 (file)
@@ -1,5 +1,4 @@
 /* NetHack 3.5 potion.c        $Date$  $Revision$ */
-/*     SCCS Id: @(#)potion.c   3.5     2009/01/22      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -423,6 +422,21 @@ dodrink()
 
        otmp = getobj(beverages, "drink");
        if(!otmp) return(0);
+
+       /* quan > 1 used to be left to useup(), but we need to force
+          the current potion to be unworn, and don't want to do
+          that for the entire stack when starting with more than 1.
+          [Drinking a wielded potion of polymorph can trigger a shape
+          change which causes hero's weapon to be dropped.  In 3.4.x,
+          that led to an "object lost" panic since subsequent useup()
+          was no longer dealing with an inventory item.  Unwearing
+          the current potion is intended to keep it in inventory.] */
+       if (otmp->quan > 1L) {
+           otmp = splitobj(otmp, 1L);
+           otmp->owornmask = 0L;       /* rest of original stuck unaffected */
+       } else if (otmp->owornmask) {
+           remove_worn_item(otmp, FALSE);
+       }
        otmp->in_use = TRUE;            /* you've opened the stopper */
 
        potion_descr = OBJ_DESCR(objects[otmp->otyp]);