scan a list of objects to see whether another object will merge with one of them; used in pickup.c when all 52 inventory slots are in use, to figure out whether another object could still be picked up */
| 772 | one of them; used in pickup.c when all 52 inventory slots are in use, |
| 773 | to figure out whether another object could still be picked up */ |
| 774 | struct obj * |
| 775 | merge_choice(struct obj *objlist, struct obj *obj) |
| 776 | { |
| 777 | struct monst *shkp; |
| 778 | unsigned save_nocharge; |
| 779 | |
| 780 | if (!objlist) /* might be checking 'obj' against empty inventory */ |
| 781 | return (struct obj *) 0; |
| 782 | if (obj->otyp == SCR_SCARE_MONSTER) /* punt on these */ |
| 783 | return (struct obj *) 0; |
| 784 | /* if this is an item on the shop floor, the attributes it will |
| 785 | have when carried are different from what they are now; prevent |
| 786 | that from eliciting an incorrect result from mergable() */ |
| 787 | save_nocharge = obj->no_charge; |
| 788 | if (objlist == gi.invent && obj->where == OBJ_FLOOR |
| 789 | && (shkp = shop_keeper(inside_shop(obj->ox, obj->oy))) != 0) { |
| 790 | if (obj->no_charge) |
| 791 | obj->no_charge = 0; |
| 792 | /* A billable object won't have its `unpaid' bit set, so would |
| 793 | erroneously seem to be a candidate to merge with a similar |
| 794 | ordinary object. That's no good, because once it's really |
| 795 | picked up, it won't merge after all. It might merge with |
| 796 | another unpaid object, but we can't check that here (depends |
| 797 | too much upon shk's bill) and if it doesn't merge it would |
| 798 | end up in the '#' overflow inventory slot, so reject it now. */ |
| 799 | else if (inhishop(shkp)) |
| 800 | return (struct obj *) 0; |
| 801 | } |
| 802 | do { |
| 803 | /*assert(objlist != NULL);*/ |
| 804 | if (mergable(objlist, obj)) |
| 805 | break; |
| 806 | objlist = objlist->nobj; |
| 807 | } while (objlist); |
| 808 | obj->no_charge = save_nocharge; |
| 809 | return objlist; |
| 810 | } |
| 811 | |
| 812 | /* merge obj with otmp and delete obj if types agree */ |
| 813 | int |
no test coverage detected