]> granicus.if.org Git - nethack/commitdiff
hangups with temp gold in inventory
authorcohrs <cohrs>
Tue, 21 May 2002 05:04:09 +0000 (05:04 +0000)
committercohrs <cohrs>
Tue, 21 May 2002 05:04:09 +0000 (05:04 +0000)
- Implement Michael's suggestion of marking temp gold put in inventory
so it can be cleaned up during restore.

doc/fixes34.1
src/do.c
src/invent.c
src/pickup.c
src/restore.c
src/trap.c

index fe15ecbf7aa0a15d70696401295edddfb6ef956a..c41a31dedf7877072f581b20e069f42fc23c5aa3 100644 (file)
@@ -109,6 +109,7 @@ when polymorphed, player killing a paper or straw golem via fire damage
        would kill the golem twice, resulting in an impossible error
 usually stop mimicing if you polymorph while using #monster mimic capability
 under !GOLDOBJ, gold shouldn't disappear if you try to throw it at yourself
+under !GOLDOBJ, remove temp gold from inventory during restore
 
 
 Platform- and/or Interface-Specific Fixes
index 63f4a1b909b2d584f4e6c1159d09c59c2cc637c7..cb14c445610f96b3d057faa900817c420a521314 100644 (file)
--- a/src/do.c
+++ b/src/do.c
@@ -614,6 +614,7 @@ int retry;
        /* Hack: gold is not in the inventory, so make a gold object
           and put it at the head of the inventory list. */
        u_gold = mkgoldobj(u.ugold);    /* removes from u.ugold */
+       u_gold->in_use = TRUE;
        u.ugold = u_gold->quan;         /* put the gold back */
        assigninvlet(u_gold);           /* might end up as NOINVSYM */
        u_gold->nobj = invent;
@@ -686,6 +687,7 @@ int retry;
        /* didn't drop [all of] it */
        u_gold = invent;
        invent = u_gold->nobj;
+       u_gold->in_use = FALSE;
        dealloc_obj(u_gold);
        update_inventory();
     }
index d4006c44632f89e9de56a75f2ecd2c98a41fa0bd..66d1c720bb878ad6fbd43012a97d4396b1e2702e 100644 (file)
@@ -480,6 +480,7 @@ struct obj *obj;
        if (obj->oclass == GOLD_CLASS) {
 #ifndef GOLDOBJ
                u.ugold -= obj->quan;
+               obj->in_use = FALSE;
 #endif
                flags.botl = 1;
                return;
index 4d6c6b614f910c84493608d2ac8cfa1b3518305e..0dfa6fa7ffa6bb3b993b2a89c5709fd55fe3e45e 100644 (file)
@@ -2084,6 +2084,7 @@ ask_again2:
                 * and put it at the head of the inventory list.
                 */
                u_gold = mkgoldobj(u.ugold);    /* removes from u.ugold */
+               u_gold->in_use = TRUE;
                u.ugold = u_gold->quan;         /* put the gold back */
                assigninvlet(u_gold);           /* might end up as NOINVSYM */
                u_gold->nobj = invent;
@@ -2118,6 +2119,7 @@ ask_again2:
            /* didn't stash [all of] it */
            u_gold = invent;
            invent = u_gold->nobj;
+           u_gold->in_use = FALSE;
            dealloc_obj(u_gold);
        }
 #endif
index 6c9edb31fe36f6160cbb9514390e1f7b98fdc2c7..5522aa04232cbb8e1fb3278978bfdcdae5712b99 100644 (file)
@@ -106,6 +106,17 @@ boolean quietly;
 
        for (otmp = invent; otmp; otmp = otmp2) {
            otmp2 = otmp->nobj;
+#ifndef GOLDOBJ
+           if (otmp->oclass == GOLD_CLASS) {
+               /* in_use gold is created by some menu operations */
+               if (!otmp->in_use) {
+                   impossible("inven_inuse: !in_use gold in inventory");
+               }
+               extract_nobj(otmp, &invent);
+               otmp->in_use = FALSE;
+               dealloc_obj(otmp);
+           } else
+#endif /* GOLDOBJ */
            if (otmp->in_use) {
                if (!quietly) pline("Finishing off %s...", xname(otmp));
                useup(otmp);
index 7ccbc1652b7670ffcbdb286becde347175df3ac1..e7d229fb1e7500988162f07c0d46a9ff9cf46a9c 100644 (file)
@@ -2494,64 +2494,64 @@ boolean *lostsome;
 {
        int invc = inv_cnt();
 
-
        while (near_capacity() > (Punished ? UNENCUMBERED : SLT_ENCUMBER)) {
-               register struct obj *obj, *otmp = (struct obj *)0;
-               register int i;
+           register struct obj *obj, *otmp = (struct obj *)0;
+           register int i;
 
-               /* Pick a random object */
-               if (invc > 0) {
-                       i = rn2(invc);
+           /* Pick a random object */
+           if (invc > 0) {
+               i = rn2(invc);
                for (obj = invent; obj; obj = obj->nobj) {
-                       /*
-                        * Undroppables are: body armor, boots, gloves,
-                        * amulets, and rings because of the time and effort
-                        * in removing them + loadstone and other cursed stuff
-                        * for obvious reasons.
-                        */
-                       if (!((obj->otyp == LOADSTONE && obj->cursed) ||
-                             obj == uamul || obj == uleft || obj == uright ||
-                             obj == ublindf || obj == uarm || obj == uarmc ||
-                             obj == uarmg || obj == uarmf ||
+                   /*
+                    * Undroppables are: body armor, boots, gloves,
+                    * amulets, and rings because of the time and effort
+                    * in removing them + loadstone and other cursed stuff
+                    * for obvious reasons.
+                    */
+                   if (!((obj->otyp == LOADSTONE && obj->cursed) ||
+                         obj == uamul || obj == uleft || obj == uright ||
+                         obj == ublindf || obj == uarm || obj == uarmc ||
+                         obj == uarmg || obj == uarmf ||
 #ifdef TOURIST
-                             obj == uarmu ||
+                         obj == uarmu ||
 #endif
-                             (obj->cursed && (obj == uarmh || obj == uarms)) ||
-                             welded(obj)))
-                               otmp = obj;
-                       /* reached the mark and found some stuff to drop? */
-                       if (--i < 0 && otmp) break;
+                         (obj->cursed && (obj == uarmh || obj == uarms)) ||
+                         welded(obj)))
+                       otmp = obj;
+                   /* reached the mark and found some stuff to drop? */
+                   if (--i < 0 && otmp) break;
 
-                       /* else continue */
-               }
+                   /* else continue */
                }
+           }
 #ifndef GOLDOBJ
-               if (!otmp) {
-                       /* Nothing available left to drop; try gold */
-                       if (u.ugold) {
-                               pline("In desperation, you drop your purse.");
-                               /* Hack: gold is not in the inventory, so make a gold object
-                                * and put it at the head of the inventory list.
-                                */
-                               obj = mkgoldobj(u.ugold);    /* removes from u.ugold */
-                               u.ugold = obj->quan;         /* put the gold back */
-                               assigninvlet(obj);           /* might end up as NOINVSYM */
-                               obj->nobj = invent;
-                               invent = obj;
-                               *lostsome = TRUE;
-                               dropx(obj);
-                               continue;                    /* Try again */
-                       }
-                       /* We can't even drop gold! */
-                       return (FALSE);
+           if (!otmp) {
+               /* Nothing available left to drop; try gold */
+               if (u.ugold) {
+                   pline("In desperation, you drop your purse.");
+                   /* Hack: gold is not in the inventory, so make a gold object
+                    * and put it at the head of the inventory list.
+                    */
+                   obj = mkgoldobj(u.ugold);    /* removes from u.ugold */
+                   obj->in_use = TRUE;
+                   u.ugold = obj->quan;         /* put the gold back */
+                   assigninvlet(obj);           /* might end up as NOINVSYM */
+                   obj->nobj = invent;
+                   invent = obj;
+                   *lostsome = TRUE;
+                   dropx(obj);
+                   continue;                    /* Try again */
                }
+               /* We can't even drop gold! */
+               return (FALSE);
+           }
 #else
-               if (!otmp) return (FALSE); /* nothing to drop! */       
+           if (!otmp) return (FALSE); /* nothing to drop! */   
 #endif
-               if (otmp->owornmask) remove_worn_item(otmp, FALSE);
-               *lostsome = TRUE;
-               dropx(otmp);
-               invc--;
+           if (otmp->owornmask) remove_worn_item(otmp, FALSE);
+           *lostsome = TRUE;
+           dropx(otmp);
+           invc--;
        }
        return(TRUE);
 }