MCPcopy Create free account
hub / github.com/NetHack/NetHack / add_to_minv

Function add_to_minv

src/mkobj.c:2647–2665  ·  view source on GitHub ↗

* Add obj to mon's inventory. If obj is able to merge with something already * in the inventory, then the passed obj is deleted and 1 is returned. * Otherwise 0 is returned. */

Source from the content-addressed store, hash-verified

2645 * Otherwise 0 is returned.
2646 */
2647int
2648add_to_minv(struct monst *mon, struct obj *obj)
2649{
2650 struct obj *otmp;
2651
2652 if (obj->where != OBJ_FREE)
2653 panic("add_to_minv: obj where=%d, not free", obj->where);
2654
2655 /* merge if possible */
2656 for (otmp = mon->minvent; otmp; otmp = otmp->nobj)
2657 if (merged(&otmp, &obj))
2658 return 1; /* obj merged and then free'd */
2659 /* else insert; don't bother forcing it to end of chain */
2660 obj->where = OBJ_MINVENT;
2661 obj->ocarry = mon;
2662 obj->nobj = mon->minvent;
2663 mon->minvent = obj;
2664 return 0; /* obj on mon's inventory chain */
2665}
2666
2667/*
2668 * Add obj to container, make sure obj is "free". Returns (merged) obj.

Callers 15

give_to_nearby_monFunction · 0.85
drop_upon_deathFunction · 0.85
stealgoldFunction · 0.85
mpickobjFunction · 0.85
mhitm_ad_sgldFunction · 0.85
mhitm_ad_seduFunction · 0.85
clonewizFunction · 0.85
throw_goldFunction · 0.85
reverse_lootFunction · 0.85
gd_pick_corridor_goldFunction · 0.85
mpickgoldFunction · 0.85
mkmonmoneyFunction · 0.85

Calls 2

mergedFunction · 0.85
panicFunction · 0.50

Tested by

no test coverage detected