]> granicus.if.org Git - nethack/commitdiff
fix pull request #469 - multiple '$' invent slots
authorPatR <rankin@nethack.org>
Tue, 16 Mar 2021 19:29:22 +0000 (12:29 -0700)
committerPatR <rankin@nethack.org>
Tue, 16 Mar 2021 19:29:22 +0000 (12:29 -0700)
Assigning a partial stack of gold to quiver (Qnn$) resulted in
an extra '$' slot in inventory, one for the unquivered part and
another for the quivered part.

Throwing a non-quivered partial stack of gold at self (tnn$.)
also resulted in an extra '$' slot after throwing at self was
rejected.

For the first case, reject the quiver-subset-of-gold attempt.
For both cases, recombine the two stacks back to original amount.

Fixes #469

doc/fixes37.0
src/dothrow.c
src/wield.c

index 61bf23a2fb45a02a2d1c5ff86c10a64a96ca7fb7..c0271d18bb8d5d257777b6e3db0313bb61aa7e12 100644 (file)
@@ -413,6 +413,10 @@ remove superfluous "All" from "All foos are already nonexistent." when blessed
 mounted hero falling out of saddle shouldn't hit ground and take damage when
        levitating or flying (if done without steed's help)
 avoid "obj not free" panic if monster kills itself by reading scroll of earth
+attempting to throw a partial stack of gold at self was prevented but left
+       the partial stack in an extra $ inventory slot
+quivering a partial stack of gold succeeded and put the partial stack in an
+       extra $ inventory slot
 
 Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
 ------------------------------------------------------------------
index 8ded43e8236f58f4a10d09bd3f0689ad66eef396..ef2ba9a0deaefbb22c562c5f3fc53ac80fb4b25e 100644 (file)
@@ -102,8 +102,9 @@ throw_obj(struct obj *obj, int shotlimit)
     if (obj->oclass == COIN_CLASS && obj != uquiver)
         return throw_gold(obj);
 
-    if (!canletgo(obj, "throw"))
+    if (!canletgo(obj, "throw")) {
         return 0;
+    }
     if (obj->oartifact == ART_MJOLLNIR && obj != uwep) {
         pline("%s must be wielded before it can be thrown.", The(xname(obj)));
         return 0;
@@ -2160,6 +2161,11 @@ throw_gold(struct obj *obj)
 
     if (!u.dx && !u.dy && !u.dz) {
         You("cannot throw gold at yourself.");
+        /* If we tried to throw part of a stack, force it to merge back
+           together (same as in throw_obj).  Essential for gold. */
+        if (obj->o_id == g.context.objsplit.parent_oid
+            || obj->o_id == g.context.objsplit.child_oid)
+            (void) unsplitobj(obj);
         return 0;
     }
     freeinv(obj);
index c907564e9cf851f2b065bd0b3e95df59a01fa8c0..44bae5eac2e4b91e6f10d5def081c3542db30782 100644 (file)
@@ -499,6 +499,11 @@ dowieldquiver(void)
         if (uquiver && uquiver->o_id == g.context.objsplit.parent_oid) {
             unsplitobj(newquiver);
             goto already_quivered;
+        } else if (newquiver->oclass == COIN_CLASS) {
+            /* don't allow splitting a stack of coins into quiver */
+            You("can't ready only part of your gold.");
+            unsplitobj(newquiver);
+            return 0;
         }
         finish_splitting = TRUE;
     } else if (newquiver == uquiver) {