| 3751 | } |
| 3752 | |
| 3753 | long |
| 3754 | stolen_value( |
| 3755 | struct obj *obj, |
| 3756 | coordxy x, |
| 3757 | coordxy y, |
| 3758 | boolean peaceful, |
| 3759 | boolean silent) |
| 3760 | { |
| 3761 | long value = 0L, gvalue = 0L, billamt = 0L; |
| 3762 | char roomno; |
| 3763 | struct bill_x *bp; |
| 3764 | struct monst *shkp; |
| 3765 | boolean was_unpaid; |
| 3766 | long c_count = 0L, u_count = 0L; |
| 3767 | |
| 3768 | if ((shkp = find_objowner(obj, x, y)) != (struct monst *) 0) { |
| 3769 | roomno = ESHK(shkp)->shoproom; |
| 3770 | } else { |
| 3771 | roomno = *in_rooms(x, y, SHOPBASE); |
| 3772 | } |
| 3773 | |
| 3774 | /* gather information for message(s) prior to manipulating bill */ |
| 3775 | was_unpaid = obj->unpaid ? TRUE : FALSE; |
| 3776 | if (Has_contents(obj)) { |
| 3777 | c_count = count_contents(obj, TRUE, FALSE, TRUE, FALSE); |
| 3778 | u_count = count_contents(obj, TRUE, FALSE, FALSE, FALSE); |
| 3779 | } |
| 3780 | |
| 3781 | shkp = (struct monst *) 0; |
| 3782 | if (!billable(&shkp, obj, roomno, TRUE)) { |
| 3783 | /* things already on the bill yield a not-billable result, so |
| 3784 | we need to check bill before deciding that shk doesn't care */ |
| 3785 | if ((bp = onbill(obj, shkp, FALSE)) != 0) { |
| 3786 | assert(shkp != NULL); /* onbill() found shkp so it's not Null */ |
| 3787 | /* shk does care; take obj off bill to avoid double billing */ |
| 3788 | billamt = bp->bquan * bp->price; |
| 3789 | sub_one_frombill(obj, shkp); |
| 3790 | } |
| 3791 | if (!bp && !u_count) |
| 3792 | return 0L; |
| 3793 | } |
| 3794 | |
| 3795 | if (obj->oclass == COIN_CLASS) { |
| 3796 | gvalue += obj->quan; |
| 3797 | } else { |
| 3798 | if (billamt) |
| 3799 | value += billamt; |
| 3800 | else if (!obj->no_charge) |
| 3801 | value += get_pricing_units(obj) * get_cost(obj, shkp); |
| 3802 | |
| 3803 | if (Has_contents(obj)) { |
| 3804 | boolean ininv = |
| 3805 | (obj->where == OBJ_INVENT || obj->where == OBJ_FREE); |
| 3806 | |
| 3807 | value += stolen_container(obj, shkp, 0L, ininv); |
| 3808 | if (!ininv) |
| 3809 | gvalue += contained_gold(obj, TRUE); |
| 3810 | } |
no test coverage detected