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.
This commit is contained in:
PatR
2022-03-22 10:48:23 -07:00
parent ade53925a6
commit 385a9a7fde
8 changed files with 17 additions and 12 deletions
+2
View File
@@ -1097,6 +1097,8 @@ changes to stair internals resulted in summoned Kops blockcading the stairs up
rather than intended stairs down rather than intended stairs down
dumplog's list of "major events" showed all logged events, not just major ones 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 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 curses: 'msg_window' option wasn't functional for curses unless the binary
also included tty support also included tty support
+1 -1
View File
@@ -360,7 +360,7 @@ moveloop_core(void)
inventory may have changed in, e.g., nh_timeout(); we do inventory may have changed in, e.g., nh_timeout(); we do
need two checks here so that the player gets feedback need two checks here so that the player gets feedback
immediately if their own action encumbered them */ immediately if their own action encumbered them */
encumber_msg(); (void) encumber_msg();
#ifdef STATUS_HILITES #ifdef STATUS_HILITES
if (iflags.hilite_delta) if (iflags.hilite_delta)
+1 -2
View File
@@ -34,7 +34,7 @@ ballrelease(boolean showmsg)
/* [this used to test 'if (uwep != uball)' but that always passes /* [this used to test 'if (uwep != uball)' but that always passes
after the setuwep() above] */ after the setuwep() above] */
freeinv(uball); /* remove from inventory but don't place on floor */ 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")); otense(otmp, "fall"));
freeinv(otmp); freeinv(otmp);
hitfloor(otmp, FALSE); hitfloor(otmp, FALSE);
encumber_msg(); /* drop[xyz]() probably ought to to this... */
} }
} }
} }
+1
View File
@@ -734,6 +734,7 @@ dropz(struct obj *obj, boolean with_impact)
map_object(obj, 0); map_object(obj, 0);
newsym(u.ux, u.uy); /* remap location under self */ 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; /* when swallowed, move dropped object from OBJ_FREE to u.ustuck's inventory;
+1
View File
@@ -245,6 +245,7 @@ throw_obj(struct obj *obj, int shotlimit)
} }
freeinv(otmp); freeinv(otmp);
throwit(otmp, wep_mask, twoweap, oldslot); throwit(otmp, wep_mask, twoweap, oldslot);
(void) encumber_msg();
} }
g.m_shot.n = g.m_shot.i = 0; g.m_shot.n = g.m_shot.i = 0;
g.m_shot.o = STRANGE_OBJECT; g.m_shot.o = STRANGE_OBJECT;
+1 -1
View File
@@ -1065,7 +1065,7 @@ hold_another_object(struct obj *obj, const char *drop_fmt,
prinv(hold_msg, obj, oquan); prinv(hold_msg, obj, oquan);
/* obj made it into inventory and is staying there */ /* obj made it into inventory and is staying there */
update_inventory(); update_inventory();
encumber_msg(); (void) encumber_msg();
} }
} }
return obj; return obj;
+7 -6
View File
@@ -480,6 +480,7 @@ steal(struct monst* mtmp, char* objnambuf)
urgent_pline("%s%s stole %s.", named ? "She" : Monnam(mtmp), urgent_pline("%s%s stole %s.", named ? "She" : Monnam(mtmp),
(was_punished && !Punished) ? " removed your chain and" : "", (was_punished && !Punished) ? " removed your chain and" : "",
doname(otmp)); doname(otmp));
(void) encumber_msg();
could_petrify = (otmp->otyp == CORPSE could_petrify = (otmp->otyp == CORPSE
&& touch_petrifies(&mons[otmp->corpsenm])); && touch_petrifies(&mons[otmp->corpsenm]));
(void) mpickobj(mtmp, otmp); /* may free otmp */ (void) mpickobj(mtmp, otmp); /* may free otmp */
@@ -622,6 +623,7 @@ stealamulet(struct monst* mtmp)
pline("%s steals %s!", Monnam(mtmp), buf); pline("%s steals %s!", Monnam(mtmp), buf);
if (can_teleport(mtmp->data) && !tele_restrict(mtmp)) if (can_teleport(mtmp->data) && !tele_restrict(mtmp))
(void) rloc(mtmp, RLOC_MSG); (void) rloc(mtmp, RLOC_MSG);
(void) encumber_msg();
} }
} }
@@ -644,12 +646,10 @@ maybe_absorb_item(
if (obj->unpaid) if (obj->unpaid)
subfrombill(obj, shop_keeper(*u.ushops)); subfrombill(obj, shop_keeper(*u.ushops));
if (cansee(mon->mx, mon->my)) { if (cansee(mon->mx, mon->my)) {
const char *MonName = Monnam(mon); /* Some_Monnam() avoids "It pulls ... and absorbs it!"
if hero can see the location but not the monster */
/* mon might be invisible; avoid "It pulls ... and absorbs it!" */ pline("%s pulls %s away from you and absorbs %s!",
if (!strcmp(MonName, "It")) Some_Monnam(mon), /* Monnam() or "Something" */
MonName = "Something";
pline("%s pulls %s away from you and absorbs %s!", MonName,
yname(obj), (obj->quan > 1L) ? "them" : "it"); yname(obj), (obj->quan > 1L) ? "them" : "it");
} else { } else {
const char *hand_s = body_part(HAND); const char *hand_s = body_part(HAND);
@@ -660,6 +660,7 @@ maybe_absorb_item(
otense(obj, "are"), hand_s); otense(obj, "are"), hand_s);
} }
freeinv(obj); freeinv(obj);
(void) encumber_msg();
} else { } else {
/* not carried; presumably thrown or kicked */ /* not carried; presumably thrown or kicked */
if (canspotmon(mon)) if (canspotmon(mon))
+3 -2
View File
@@ -844,6 +844,7 @@ untwoweapon(void)
return; return;
} }
/* enchant wielded weapon */
int int
chwepon(struct obj *otmp, int amount) chwepon(struct obj *otmp, int amount)
{ {
@@ -897,7 +898,7 @@ chwepon(struct obj *otmp, int amount)
if (otyp != STRANGE_OBJECT) if (otyp != STRANGE_OBJECT)
makeknown(otyp); makeknown(otyp);
if (multiple) if (multiple)
encumber_msg(); (void) encumber_msg();
return 1; return 1;
} else if (uwep->otyp == CRYSKNIFE && amount < 0) { } else if (uwep->otyp == CRYSKNIFE && amount < 0) {
multiple = (uwep->quan > 1L); multiple = (uwep->quan > 1L);
@@ -914,7 +915,7 @@ chwepon(struct obj *otmp, int amount)
if (otyp != STRANGE_OBJECT && otmp->bknown) if (otyp != STRANGE_OBJECT && otmp->bknown)
makeknown(otyp); makeknown(otyp);
if (multiple) if (multiple)
encumber_msg(); (void) encumber_msg();
return 1; return 1;
} }