/* * Free obj from whatever list it is on in preperation of deleting it or * moving it elsewhere. This will perform all high-level consequences * involved with removing the item. E.g. if the object is in the hero's * inventory and confers heat resistance, the hero will lose it. * * Object positions: * OBJ_FREE not on any list * OBJ_FLOOR fobj, level.locations[][] chains (use remove_object) * OBJ_CONTAINED cobj chain of container object * OBJ_INVENT hero's invent chain (use freeinv) * OBJ_MINVENT monster's invent chain * OBJ_MIGRATING migrating chain * OBJ_BURIED level.buriedobjs chain * OBJ_ONBILL on billobjs chain */ void obj_extract_self(struct obj *obj) { switch (obj->where) { case OBJ_FREE: break; case OBJ_FLOOR: remove_object(obj); break; case OBJ_CONTAINED: extract_nobj(obj, &obj->ocontainer->cobj); container_weight(obj->ocontainer); break; case OBJ_INVENT: freeinv(obj); break; case OBJ_MINVENT: extract_nobj(obj, &obj->ocarry->minvent); break; case OBJ_MIGRATING: extract_nobj(obj, &migrating_objs); break; case OBJ_BURIED: extract_nobj(obj, &level.buriedobjlist); break; case OBJ_ONBILL: extract_nobj(obj, &billobjs); break; default: panic("obj_extract_self"); break; } }
/* Recalculate the weight of this container and all of _its_ containers. */ static void container_weight(struct obj *container) { container->owt = weight(container); if (container->where == OBJ_CONTAINED) container_weight(container->ocontainer); /* else if (container->where == OBJ_INVENT) recalculate load delay here ??? */ }