]> granicus.if.org Git - nethack/commitdiff
R888 - panic while quaffing a potion of levitation
authorcohrs <cohrs>
Sat, 13 Jul 2002 23:06:22 +0000 (23:06 +0000)
committercohrs <cohrs>
Sat, 13 Jul 2002 23:06:22 +0000 (23:06 +0000)
Now that the in_use flag is set for potions being quaffed, use the in_use
flag in general in destroy_item to avoid destroying the in use object, on
the assumption that the caller will call useup when finished.  There are a
few places that set then unset in_use, but these don't currently result in
a call to destroy_item.  The current_wand hack was not removed, since its
logic appears to allow destroy_item to still destroy the item.

doc/fixes34.1
src/zap.c

index b536a8b42ccc4d76b0276863d99f30414a10bcc8..d3a87a745feff6b4598acf8ef92dd53e734ce8b6 100644 (file)
@@ -159,6 +159,8 @@ blessed gain level when already at level 30 won't reduce experience points
 keep counting spell skill exercise even after expert status is reached
 when a fountain dries up or a throne vanishes, make sure it really happens
 allow player to name polymorph potion if nothing seems to happen
+avoid crash when drinking a potion causes the hero to float up over a fire
+       trap, for example, which might try to destroy the in-use potion
 
 
 Platform- and/or Interface-Specific Fixes
index 1d2c62eaf07264e76fc5104213ee9b77de3c80c1..ee72775506c16185a7c1bc1e38a124069a684f20 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -3758,6 +3758,7 @@ register int osym, dmgtyp;
            obj2 = obj->nobj;
            if(obj->oclass != osym) continue; /* test only objs of type osym */
            if(obj->oartifact) continue; /* don't destroy artifacts */
+           if(obj->in_use && obj->quan == 1) continue; /* not available */
            xresist = skip = 0;
 #ifdef GCC_WARN
            dmg = dindx = 0;
@@ -3829,6 +3830,7 @@ register int osym, dmgtyp;
                    break;
            }
            if(!skip) {
+               if (obj->in_use) --quan; /* one will be used up elsewhere */
                for(i = cnt = 0L; i < quan; i++)
                    if(!rn2(3)) cnt++;