From: PatR Date: Tue, 22 Mar 2022 17:48:23 +0000 (-0700) Subject: encumbrance checks X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=385a9a7fde2079d606d7ff49343e6369668535e9;p=nethack encumbrance checks 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. --- diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 15ba3c0ef..4c5b143be 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -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 diff --git a/src/allmain.c b/src/allmain.c index c0fda578b..d13d86160 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -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) diff --git a/src/ball.c b/src/ball.c index 457efd9fd..9b6b3eeb5 100644 --- a/src/ball.c +++ b/src/ball.c @@ -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... */ } } } diff --git a/src/do.c b/src/do.c index 58ce0286b..04525b8ea 100644 --- 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; diff --git a/src/dothrow.c b/src/dothrow.c index a1aac0ea2..e92b29703 100644 --- a/src/dothrow.c +++ b/src/dothrow.c @@ -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; diff --git a/src/invent.c b/src/invent.c index ac82b2206..559a13fcf 100644 --- a/src/invent.c +++ b/src/invent.c @@ -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; diff --git a/src/steal.c b/src/steal.c index cb0d94873..e13bd3842 100644 --- a/src/steal.c +++ b/src/steal.c @@ -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)) diff --git a/src/wield.c b/src/wield.c index 4a7eb8322..3c021b399 100644 --- a/src/wield.c +++ b/src/wield.c @@ -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; }