glob nutrition should match owt reduction

reported directly to devteam as an impossible() call
within eaten_stat()

(internal tracking number 3216)
This commit is contained in:
nhmall
2026-08-18 10:24:35 -04:00
parent 4474d3cb2a
commit f6a592b7f9
2 changed files with 19 additions and 2 deletions
+2
View File
@@ -83,6 +83,8 @@ cmdstr[] buffer was not being initialized in handler_rebind_keys_add()
don't catch thrown objects while asleep
don't refer to pet as "Your pet" until after the taming process has finished
checkpoint fixes (pr #1660 by k21971)
upon return to a level, catch up on remaining nutrition value by the same
percentage as the catch up for the weight
Platform- and/or Interface-Specific Fixes
+17 -2
View File
@@ -1510,7 +1510,7 @@ shrink_glob(
shrink = FALSE, gone = FALSE, updinv = FALSE;
struct obj *contnr = (obj->where == OBJ_CONTAINED) ? obj->ocontainer : 0,
*topcontnr = 0;
unsigned old_top_owt = 0;
unsigned old_top_owt = 0, old_owt = obj->owt;
if (!obj->globby) {
impossible("shrink_glob for non-glob [%d: %s]?",
@@ -1539,12 +1539,25 @@ shrink_glob(
obj->owt = 0; /* not required; accurately reflects obj's state */
shrinking_glob_gone(obj);
} else {
/* shrank but not gone; reduce remaining weight */
/* shrank but not gone; reduce remaining weight
and food-content (if needed) */
obj->owt -= (unsigned) delta;
/* when contained, update container's weight (recursively if
nested); won't be in a container carried by hero (since
catching up for lost time never applies in that situation)
but might be in one on floor or one carried by a monster */
if (old_owt && obj->oeaten) {
unsigned percent_reduction = 100 - ((obj->owt * 100) / old_owt),
oeaten_reduction;
/* reduce remaining nutrition by same percentage */
oeaten_reduction = (percent_reduction * obj->oeaten + 50) / 100;
if (oeaten_reduction <= obj->oeaten)
obj->oeaten -= oeaten_reduction;
}
if (contnr)
container_weight(contnr);
/* resume regular shrinking */
@@ -1674,6 +1687,8 @@ shrinking_glob_gone(struct obj *obj)
{
xint16 owhere = obj->where;
/* obfree() should take care of eating_glob() food fixups */
if (owhere == OBJ_INVENT) {
if (obj->owornmask) {
remove_worn_item(obj, FALSE);