more weight tweaks
Update some potential weight issues. Eggs won't hatch when in containers so they weren't affected but add some bulletproofing. Corpse revival from inside containers was already ok too, so effectively there's no change except for making container_weight() be global instead of local to mkobj.c.
This commit is contained in:
@@ -1639,6 +1639,7 @@ extern int add_to_minv(struct monst *, struct obj *) NONNULLARG12;
|
||||
extern struct obj *add_to_container(struct obj *, struct obj *) NONNULLARG12;
|
||||
extern void add_to_migration(struct obj *) NONNULLARG1;
|
||||
extern void add_to_buried(struct obj *) NONNULLARG1;
|
||||
extern void container_weight(struct obj *) NONNULLARG1;
|
||||
extern void dealloc_obj(struct obj *) NONNULLARG1;
|
||||
extern void obj_ice_effects(coordxy, coordxy, boolean);
|
||||
extern long peek_at_iced_corpse_age(struct obj *) NONNULLARG1;
|
||||
|
||||
18
src/mkobj.c
18
src/mkobj.c
@@ -13,7 +13,6 @@ static void mksobj_init(struct obj *, boolean);
|
||||
static int item_on_ice(struct obj *);
|
||||
static void shrinking_glob_gone(struct obj *);
|
||||
static void obj_timer_checks(struct obj *, coordxy, coordxy, int);
|
||||
static void container_weight(struct obj *) NONNULLARG1;
|
||||
static struct obj *save_mtraits(struct obj *, struct monst *);
|
||||
static void objlist_sanity(struct obj *, int, const char *);
|
||||
static void shop_obj_sanity(struct obj *, const char *);
|
||||
@@ -2645,17 +2644,14 @@ add_to_buried(struct obj *obj)
|
||||
gl.level.buriedobjlist = obj;
|
||||
}
|
||||
|
||||
/* Recalculate the weight of this container and all of _its_ containers. */
|
||||
static void
|
||||
container_weight(struct obj *container)
|
||||
/* recalculate weight of object, which doesn't have to be a container
|
||||
itself; if it is contained, recursively handle _its_ container(s) */
|
||||
void
|
||||
container_weight(struct obj *object)
|
||||
{
|
||||
container->owt = weight(container);
|
||||
if (container->where == OBJ_CONTAINED)
|
||||
container_weight(container->ocontainer);
|
||||
/*
|
||||
else if (container->where == OBJ_INVENT)
|
||||
recalculate load delay here ???
|
||||
*/
|
||||
object->owt = weight(object);
|
||||
if (object->where == OBJ_CONTAINED)
|
||||
container_weight(object->ocontainer);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -986,7 +986,9 @@ hatch_egg(anything *arg, long timeout)
|
||||
yours = (egg->spe || (!flags.female && carried(egg) && !rn2(2)));
|
||||
silent = (timeout != gm.moves); /* hatched while away */
|
||||
|
||||
/* only can hatch when in INVENT, FLOOR, MINVENT */
|
||||
/* only can hatch when in INVENT, FLOOR, MINVENT;
|
||||
get_obj_location() will fail for MIGRATING, also for CONTAINED
|
||||
and BURIED when the flags for those aren't included in the call */
|
||||
if (get_obj_location(egg, &x, &y, 0)) {
|
||||
hatchcount = rnd((int) egg->quan);
|
||||
cansee_hatchspot = cansee(x, y) && !silent;
|
||||
@@ -995,7 +997,7 @@ hatch_egg(anything *arg, long timeout)
|
||||
for (i = hatchcount; i > 0; i--) {
|
||||
if (!enexto(&cc, x, y, &mons[mnum])
|
||||
|| !(mon = makemon(&mons[mnum], cc.x, cc.y,
|
||||
NO_MINVENT|MM_NOMSG)))
|
||||
NO_MINVENT | MM_NOMSG)))
|
||||
break;
|
||||
/* tame if your own egg hatches while you're on the
|
||||
same dungeon level, or any dragon egg which hatches
|
||||
@@ -1115,10 +1117,14 @@ hatch_egg(anything *arg, long timeout)
|
||||
learn_egg_type(mnum);
|
||||
|
||||
if (egg->quan > 0) {
|
||||
/* still some eggs left */
|
||||
/* Instead of ordinary egg timeout use a short one */
|
||||
/* still some eggs left; we didn't split the stack, just
|
||||
subtracted from quantity so weight needs to be updated;
|
||||
for remainder of stack, add a new, short hatch timer */
|
||||
attach_egg_hatch_timeout(egg, (long) rnd(12));
|
||||
egg->owt = weight(egg);
|
||||
/* container_weight(arg) updates arg->owt, and if contained,
|
||||
its enclosing container arg->ocontainer (recursively)
|
||||
[egg won't be contained due to conditions imposed above] */
|
||||
container_weight(egg);
|
||||
} else if (carried(egg)) {
|
||||
useup(egg);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user