]> granicus.if.org Git - nethack/commitdiff
encumbrance checks
authorPatR <rankin@nethack.org>
Tue, 22 Mar 2022 17:48:23 +0000 (10:48 -0700)
committerPatR <rankin@nethack.org>
Tue, 22 Mar 2022 17:48:23 +0000 (10:48 -0700)
I polymorphed into something wimpy and became overloaded or even
overtaxed so I dropped everything.  The status line still showed
overloaded or overtaxed until my next move.  That didn't happen in
3.6.x or 3.4.3 but I didn't pursue trying to figure out what caused
this misbehavior.

I wanted to add an encumber_msg() call to freeinv() but that would
cause message sequencing issues.  Instead, add a call to it in a
few places where items are leaving hero's inventory, particularly
for the chain of calls for dropping stuff.  I've left it off in a
bunch of other potential places.

Also add a few missing (void) casts where the return value of
existing encumber_msg() calls is being ignored.

doc/fixes3-7-0.txt
src/allmain.c
src/ball.c
src/do.c
src/dothrow.c
src/invent.c
src/steal.c
src/wield.c

index 15ba3c0efe4cf1550c06916354ad561eb91cd31b..4c5b143beb7ae073255e7e94d9f01c16511b1924 100644 (file)
@@ -1097,6 +1097,8 @@ changes to stair internals resulted in summoned Kops blockcading the stairs up
        rather than intended stairs down
 dumplog's list of "major events" showed all logged events, not just major ones
 pickup via menu ignored player-specified count when picking up gold
+changes in encumbrance sometimes went unreported, leaving stale status line
+       info until hero's next move
 
 curses: 'msg_window' option wasn't functional for curses unless the binary
        also included tty support
index c0fda578b10f7af1d6e81b63101059c8a93f6f63..d13d86160cad195813957cd539203d0000387e45 100644 (file)
@@ -360,7 +360,7 @@ moveloop_core(void)
            inventory may have changed in, e.g., nh_timeout(); we do
            need two checks here so that the player gets feedback
            immediately if their own action encumbered them */
-        encumber_msg();
+        (void) encumber_msg();
 
 #ifdef STATUS_HILITES
         if (iflags.hilite_delta)
index 457efd9fdb8a91d215b2bdf3192be7a0547d761d..9b6b3eeb521f0c3344a9e2f9b0bf586530834d8b 100644 (file)
@@ -34,7 +34,7 @@ ballrelease(boolean showmsg)
         /* [this used to test 'if (uwep != uball)' but that always passes
            after the setuwep() above] */
         freeinv(uball); /* remove from inventory but don't place on floor */
-        encumber_msg();
+        (void) encumber_msg();
     }
 }
 
@@ -975,7 +975,6 @@ litter(void)
                     otense(otmp, "fall"));
                 freeinv(otmp);
                 hitfloor(otmp, FALSE);
-                encumber_msg(); /* drop[xyz]() probably ought to to this... */
             }
         }
     }
index 58ce0286bfa3dd4b1a709935dfcccbacef606e47..04525b8ea65dd61eb17c407d442102df0fd20ea7 100644 (file)
--- a/src/do.c
+++ b/src/do.c
@@ -734,6 +734,7 @@ dropz(struct obj *obj, boolean with_impact)
             map_object(obj, 0);
         newsym(u.ux, u.uy); /* remap location under self */
     }
+    (void) encumber_msg();
 }
 
 /* when swallowed, move dropped object from OBJ_FREE to u.ustuck's inventory;
index a1aac0ea2936c53edfeef884d27df378edd880ca..e92b297030ac27744896e3cdc27c03a5b9e8af18 100644 (file)
@@ -245,6 +245,7 @@ throw_obj(struct obj *obj, int shotlimit)
         }
         freeinv(otmp);
         throwit(otmp, wep_mask, twoweap, oldslot);
+        (void) encumber_msg();
     }
     g.m_shot.n = g.m_shot.i = 0;
     g.m_shot.o = STRANGE_OBJECT;
index ac82b220623852dd5b14a94936f66d12441f06bf..559a13fcfee1989db6eb818d4f2ef30ae088a916 100644 (file)
@@ -1065,7 +1065,7 @@ hold_another_object(struct obj *obj, const char *drop_fmt,
                 prinv(hold_msg, obj, oquan);
             /* obj made it into inventory and is staying there */
             update_inventory();
-            encumber_msg();
+            (void) encumber_msg();
         }
     }
     return obj;
index cb0d94873510281db9038f27a8eeb79bd4385d80..e13bd3842676d8f9552453482aefc1c69ee9bec3 100644 (file)
@@ -480,6 +480,7 @@ steal(struct monst* mtmp, char* objnambuf)
     urgent_pline("%s%s stole %s.", named ? "She" : Monnam(mtmp),
                  (was_punished && !Punished) ? " removed your chain and" : "",
                  doname(otmp));
+    (void) encumber_msg();
     could_petrify = (otmp->otyp == CORPSE
                      && touch_petrifies(&mons[otmp->corpsenm]));
     (void) mpickobj(mtmp, otmp); /* may free otmp */
@@ -622,6 +623,7 @@ stealamulet(struct monst* mtmp)
         pline("%s steals %s!", Monnam(mtmp), buf);
         if (can_teleport(mtmp->data) && !tele_restrict(mtmp))
             (void) rloc(mtmp, RLOC_MSG);
+        (void) encumber_msg();
     }
 }
 
@@ -644,12 +646,10 @@ maybe_absorb_item(
         if (obj->unpaid)
             subfrombill(obj, shop_keeper(*u.ushops));
         if (cansee(mon->mx, mon->my)) {
-            const char *MonName = Monnam(mon);
-
-            /* mon might be invisible; avoid "It pulls ... and absorbs it!" */
-            if (!strcmp(MonName, "It"))
-                MonName = "Something";
-            pline("%s pulls %s away from you and absorbs %s!", MonName,
+            /* Some_Monnam() avoids "It pulls ... and absorbs it!"
+               if hero can see the location but not the monster */
+            pline("%s pulls %s away from you and absorbs %s!",
+                  Some_Monnam(mon), /* Monnam() or "Something" */
                   yname(obj), (obj->quan > 1L) ? "them" : "it");
         } else {
             const char *hand_s = body_part(HAND);
@@ -660,6 +660,7 @@ maybe_absorb_item(
                   otense(obj, "are"), hand_s);
         }
         freeinv(obj);
+        (void) encumber_msg();
     } else {
         /* not carried; presumably thrown or kicked */
         if (canspotmon(mon))
index 4a7eb83228dc7e4cfd746c1c20080ab1628af8ca..3c021b39966849bcb86cadd8146dbf71b89cd89f 100644 (file)
@@ -844,6 +844,7 @@ untwoweapon(void)
     return;
 }
 
+/* enchant wielded weapon */
 int
 chwepon(struct obj *otmp, int amount)
 {
@@ -897,7 +898,7 @@ chwepon(struct obj *otmp, int amount)
         if (otyp != STRANGE_OBJECT)
             makeknown(otyp);
         if (multiple)
-            encumber_msg();
+            (void) encumber_msg();
         return 1;
     } else if (uwep->otyp == CRYSKNIFE && amount < 0) {
         multiple = (uwep->quan > 1L);
@@ -914,7 +915,7 @@ chwepon(struct obj *otmp, int amount)
         if (otyp != STRANGE_OBJECT && otmp->bknown)
             makeknown(otyp);
         if (multiple)
-            encumber_msg();
+            (void) encumber_msg();
         return 1;
     }