MCPcopy Index your code
hub / github.com/NetHack/NetHack / add_to_container

Function add_to_container

src/mkobj.c:2675–2695  ·  view source on GitHub ↗

* Add obj to container, make sure obj is "free". Returns (merged) obj. * The input obj may be deleted in the process. * * Caveat: this does not update the container's weight [possibly to * prevent that from being recalculated repeatedly when adding multiple * items]. */

Source from the content-addressed store, hash-verified

2673 * items].
2674 */
2675struct obj *
2676add_to_container(struct obj *container, struct obj *obj)
2677{
2678 struct obj *otmp;
2679
2680 if (obj->where != OBJ_FREE)
2681 panic("add_to_container: obj where=%d, not free", obj->where);
2682 if (container->where != OBJ_INVENT && container->where != OBJ_MINVENT)
2683 obj_no_longer_held(obj);
2684
2685 /* merge if possible */
2686 for (otmp = container->cobj; otmp; otmp = otmp->nobj)
2687 if (merged(&otmp, &obj))
2688 return otmp;
2689
2690 obj->where = OBJ_CONTAINED;
2691 obj->ocontainer = container;
2692 obj->nobj = container->cobj;
2693 container->cobj = obj;
2694 return obj;
2695}
2696
2697void
2698add_to_migration(struct obj *obj)

Callers 15

fill_zooFunction · 0.85
drop_upon_deathFunction · 0.85
l_obj_add_to_containerFunction · 0.85
reverse_lootFunction · 0.85
in_containerFunction · 0.85
tipcontainerFunction · 0.85
monstoneFunction · 0.85
mkbox_cntsFunction · 0.85
mksobj_initFunction · 0.85
hornoplentyFunction · 0.85
mk_trap_statueFunction · 0.85
m_initinvFunction · 0.85

Calls 3

obj_no_longer_heldFunction · 0.85
mergedFunction · 0.85
panicFunction · 0.50

Tested by

no test coverage detected