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.
This commit is contained in:
12
src/eat.c
12
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)",
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user