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

View 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)

View 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... */
}
}
}

View File

@@ -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;

View 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;

View 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;

View 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))

View 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;
}