* The caller is about to make obj_absorbed go away. * * There's no way for you (or a shopkeeper) to prevent globs * from merging with each other on the floor due to the * inherent nature of globs so it irretrievably becomes part * of the floor glob mass. When one glob is absorbed by another * glob, the two become indistinguishable and the remaining * glob object grows in mass, the product o
| 5973 | * 4. player_owned glob merging into player_owned glob |
| 5974 | */ |
| 5975 | void |
| 5976 | globby_bill_fixup(struct obj *obj_absorber, struct obj *obj_absorbed) |
| 5977 | { |
| 5978 | int x = 0, y = 0; |
| 5979 | struct bill_x *bp, *bp_absorber = (struct bill_x *) 0; |
| 5980 | struct monst *shkp = 0; |
| 5981 | struct eshk *eshkp; |
| 5982 | long amount, per_unit_cost; |
| 5983 | boolean floor_absorber = (obj_absorber->where == OBJ_FLOOR); |
| 5984 | |
| 5985 | if (!obj_absorber->globby) |
| 5986 | impossible("globby_bill_fixup called for non-globby object"); |
| 5987 | |
| 5988 | if (floor_absorber) { |
| 5989 | x = obj_absorber->ox, y = obj_absorber->oy; |
| 5990 | } |
| 5991 | if (obj_absorber->unpaid) { |
| 5992 | /* look for a shopkeeper who owns this object */ |
| 5993 | for (shkp = next_shkp(fmon, TRUE); shkp; |
| 5994 | shkp = next_shkp(shkp->nmon, TRUE)) |
| 5995 | if (onbill(obj_absorber, shkp, TRUE)) |
| 5996 | break; |
| 5997 | } else if (obj_absorbed->unpaid) { |
| 5998 | if (obj_absorbed->where == OBJ_FREE |
| 5999 | && floor_absorber && costly_spot(x, y)) { |
| 6000 | shkp = shop_keeper(*in_rooms(x, y, SHOPBASE)); |
| 6001 | } |
| 6002 | } |
| 6003 | /* sanity check, in case obj is on bill but not marked 'unpaid' */ |
| 6004 | if (!shkp) |
| 6005 | shkp = shop_keeper(*u.ushops); |
| 6006 | if (!shkp) |
| 6007 | return; |
| 6008 | bp_absorber = onbill(obj_absorber, shkp, FALSE); |
| 6009 | bp = onbill(obj_absorbed, shkp, FALSE); |
| 6010 | eshkp = ESHK(shkp); |
| 6011 | per_unit_cost = set_cost(obj_absorbed, shkp); |
| 6012 | |
| 6013 | /************************************************************** |
| 6014 | * Scenario 1. Shop-owned glob absorbing into shop-owned glob |
| 6015 | **************************************************************/ |
| 6016 | if (bp && (!obj_absorber->no_charge |
| 6017 | || billable(&shkp, obj_absorber, eshkp->shoproom, FALSE))) { |
| 6018 | /* the glob being absorbed has a billing record */ |
| 6019 | amount = bp->price; |
| 6020 | eshkp->billct--; |
| 6021 | *bp = eshkp->bill_p[eshkp->billct]; |
| 6022 | clear_unpaid_obj(shkp, obj_absorbed); |
| 6023 | |
| 6024 | if (bp_absorber) { |
| 6025 | /* the absorber has a billing record */ |
| 6026 | bp_absorber->price += amount; |
| 6027 | } else { |
| 6028 | /* the absorber has no billing record */ |
| 6029 | ; |
| 6030 | } |
| 6031 | return; |
| 6032 | } |
no test coverage detected