Fix some object weight problems
There were few places where the object weight was not updated: - container when the contents were broken by impact - starting to eat but getting stopped by rotten food - using lua, container when putting an object inside it - when a single egg of a larger stack hatched
This commit is contained in:
@@ -411,7 +411,7 @@ container_impact_dmg(
|
||||
struct monst *shkp;
|
||||
struct obj *otmp, *otmp2;
|
||||
long loss = 0L;
|
||||
boolean costly, insider, frominv;
|
||||
boolean costly, insider, frominv, wchange = FALSE;
|
||||
|
||||
/* only consider normal containers */
|
||||
if (!Is_container(obj) || !Has_contents(obj) || Is_mbag(obj))
|
||||
@@ -462,8 +462,11 @@ container_impact_dmg(
|
||||
}
|
||||
/* contents of this container are no longer known */
|
||||
obj->cknown = 0;
|
||||
wchange = TRUE;
|
||||
}
|
||||
}
|
||||
if (wchange)
|
||||
obj->owt = weight(obj);
|
||||
if (costly && loss) {
|
||||
if (!insider) {
|
||||
You("caused %ld %s worth of damage!", loss, currency(loss));
|
||||
|
||||
@@ -2950,6 +2950,8 @@ doeat(void)
|
||||
|
||||
if (!dont_start)
|
||||
start_eating(otmp, already_partly_eaten);
|
||||
else
|
||||
otmp->owt = weight(otmp);
|
||||
return ECMD_TIME;
|
||||
}
|
||||
|
||||
|
||||
@@ -129,6 +129,7 @@ l_obj_add_to_container(lua_State *L)
|
||||
lo->obj = otmp;
|
||||
lo->obj->lua_ref_cnt += refs;
|
||||
}
|
||||
lobox->obj->owt = weight(lobox->obj);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1118,6 +1118,7 @@ hatch_egg(anything *arg, long timeout)
|
||||
/* still some eggs left */
|
||||
/* Instead of ordinary egg timeout use a short one */
|
||||
attach_egg_hatch_timeout(egg, (long) rnd(12));
|
||||
egg->owt = weight(egg);
|
||||
} else if (carried(egg)) {
|
||||
useup(egg);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user