* Causes the heavier object to absorb the lighter object in * most cases, but if one object is OBJ_FREE and the other is * on the floor, the floor object goes first. Note that when * a globby monster dies, its corpse (new glob) will be created * on the floor; when a glob is dropped, thrown, or kicked it * will be free at the time obj_meld() gets called. * * Wrapper for obj_absorb() so that
| 3765 | * cleanly (since we don't know which we want to stay around). |
| 3766 | */ |
| 3767 | struct obj * |
| 3768 | obj_meld(struct obj **obj1, struct obj **obj2) |
| 3769 | { |
| 3770 | struct obj *otmp1, *otmp2, *result = 0; |
| 3771 | int ox, oy; /* coordinates for the glob that goes away */ |
| 3772 | |
| 3773 | if (obj1 && obj2) { |
| 3774 | otmp1 = *obj1; |
| 3775 | otmp2 = *obj2; |
| 3776 | if (otmp1 && otmp2 && otmp1 != otmp2) { |
| 3777 | ox = oy = 0; |
| 3778 | /* |
| 3779 | * FIXME? |
| 3780 | * If one of the objects is free because it's being dropped, |
| 3781 | * we should really finish a full drop and then absorb/meld |
| 3782 | * if it survives the flooreffects(). Then lighter-melds-into- |
| 3783 | * heavier will be true even when heavier is the one dropped. |
| 3784 | * |
| 3785 | * [Also, what about when one of the globs is on the shore |
| 3786 | * and we drop the other into adjacent pool or vice versa?] |
| 3787 | */ |
| 3788 | if (!(otmp2->where == OBJ_FLOOR && otmp1->where == OBJ_FREE) |
| 3789 | && (otmp1->owt > otmp2->owt |
| 3790 | || (otmp1->owt == otmp2->owt && rn2(2)))) { |
| 3791 | if (otmp2->where == OBJ_FLOOR) |
| 3792 | ox = otmp2->ox, oy = otmp2->oy; |
| 3793 | result = obj_absorb(obj1, obj2); |
| 3794 | } else { |
| 3795 | if (otmp1->where == OBJ_FLOOR) |
| 3796 | ox = otmp1->ox, oy = otmp1->oy; |
| 3797 | result = obj_absorb(obj2, obj1); |
| 3798 | } |
| 3799 | /* callers really ought to take care of this; glob melding is |
| 3800 | a bookkeeping issue rather than a display one */ |
| 3801 | if (ox) { |
| 3802 | if (cansee(ox, oy)) |
| 3803 | newsym(ox, oy); |
| 3804 | /* and this; a hides-under monster might be hiding under |
| 3805 | the glob that went away; if there's nothing else there |
| 3806 | to hide under, force it out of hiding */ |
| 3807 | maybe_unhide_at(ox, oy); |
| 3808 | } |
| 3809 | } |
| 3810 | } else { |
| 3811 | impossible("obj_meld: not called with two actual objects"); |
| 3812 | } |
| 3813 | return result; |
| 3814 | } |
| 3815 | |
| 3816 | /* give a message if hero notices two globs merging [used to be in pline.c] */ |
| 3817 | void |
no test coverage detected