* 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. */
| 2645 | * Otherwise 0 is returned. |
| 2646 | */ |
| 2647 | int |
| 2648 | add_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. |
no test coverage detected