From 1ae5297a936c9b31392c7303642eb05d1f7d6949 Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 5 Feb 2016 15:46:24 -0800 Subject: [PATCH] glob weight recalc weight() didn't know how to calculate a glob's weight. When one glob absorbs another, that isn't used, but when the hero eats part of a glob, it is, and the result was incorrect. --- src/eat.c | 12 ++++++------ src/mkobj.c | 7 ++++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/eat.c b/src/eat.c index 9601e1cdb..269fcaf28 100644 --- a/src/eat.c +++ b/src/eat.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 eat.c $NHDT-Date: 1454061992 2016/01/29 10:06:32 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.162 $ */ +/* NetHack 3.6 eat.c $NHDT-Date: 1454715969 2016/02/05 23:46:09 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.163 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -312,7 +312,7 @@ struct obj *otmp; costly_alteration(otmp, COST_BITE); otmp->oeaten = (otmp->otyp == CORPSE) ? mons[otmp->corpsenm].cnutrit : otmp->globby ? otmp->owt - : objects[otmp->otyp].oc_nutrition; + : (unsigned) objects[otmp->otyp].oc_nutrition; } if (carried(otmp)) { @@ -2558,7 +2558,7 @@ doeat() /* re-calc the nutrition */ basenutrit = (otmp->otyp == CORPSE) ? mons[otmp->corpsenm].cnutrit : otmp->globby ? otmp->owt - : objects[otmp->otyp].oc_nutrition; + : (unsigned) objects[otmp->otyp].oc_nutrition; debugpline3( "before rounddiv: victual.reqtime == %d, oeaten == %d, basenutrit == %d", @@ -3042,9 +3042,9 @@ struct obj *obj; long uneaten_amt, full_amount; uneaten_amt = (long) obj->oeaten; - full_amount = (obj->otyp == CORPSE) ? (long) mons[obj->corpsenm].cnutrit - : obj->globby ? obj->owt - : (long) objects[obj->otyp].oc_nutrition; + full_amount = (long) ((obj->otyp == CORPSE) ? mons[obj->corpsenm].cnutrit + : obj->globby ? obj->owt + : (unsigned) objects[obj->otyp].oc_nutrition); if (uneaten_amt > full_amount) { impossible( "partly eaten food (%ld) more nutritious than untouched food (%ld)", diff --git a/src/mkobj.c b/src/mkobj.c index ef0af3eec..6cb87e40b 100644 --- a/src/mkobj.c +++ b/src/mkobj.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mkobj.c $NHDT-Date: 1454061995 2016/01/29 10:06:35 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.117 $ */ +/* NetHack 3.6 mkobj.c $NHDT-Date: 1454715975 2016/02/05 23:46:15 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.119 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1342,6 +1342,11 @@ register struct obj *obj; { int wt = objects[obj->otyp].oc_weight; + /* glob absorpsion means that merging globs accumulates weight while + quantity stays 1, so update 'wt' to reflect that, unless owt is 0, + when we assume this is a brand new glob so use objects[].oc_weight */ + if (obj->globby && obj->owt > 0) + wt = obj->owt; if (SchroedingersBox(obj)) wt += mons[PM_HOUSECAT].cwt; if (Is_container(obj) || obj->otyp == STATUE) { -- 2.40.0