| 3620 | } |
| 3621 | |
| 3622 | void |
| 3623 | splitbill(struct obj *obj, struct obj *otmp) |
| 3624 | { |
| 3625 | /* otmp has been split off from obj */ |
| 3626 | struct bill_x *bp; |
| 3627 | long tmp; |
| 3628 | struct monst *shkp = shop_keeper(*u.ushops); |
| 3629 | |
| 3630 | if (!shkp || !inhishop(shkp)) { |
| 3631 | impossible("splitbill: no resident shopkeeper??"); |
| 3632 | return; |
| 3633 | } |
| 3634 | bp = onbill(obj, shkp, FALSE); |
| 3635 | if (!bp) { |
| 3636 | impossible("splitbill: not on bill?"); |
| 3637 | return; |
| 3638 | } |
| 3639 | if (bp->bquan < otmp->quan) { |
| 3640 | impossible("Negative quantity on bill??"); |
| 3641 | } |
| 3642 | if (bp->bquan == otmp->quan) { |
| 3643 | impossible("Zero quantity on bill??"); |
| 3644 | } |
| 3645 | bp->bquan -= otmp->quan; |
| 3646 | |
| 3647 | if (ESHK(shkp)->billct == BILLSZ) { |
| 3648 | otmp->unpaid = 0; |
| 3649 | } else { |
| 3650 | tmp = bp->price; |
| 3651 | bp = &(ESHK(shkp)->bill_p[ESHK(shkp)->billct]); |
| 3652 | bp->bo_id = otmp->o_id; |
| 3653 | bp->bquan = otmp->quan; |
| 3654 | bp->useup = FALSE; |
| 3655 | bp->price = tmp; |
| 3656 | ESHK(shkp)->billct++; |
| 3657 | } |
| 3658 | } |
| 3659 | |
| 3660 | staticfn void |
| 3661 | sub_one_frombill(struct obj *obj, struct monst *shkp) |
no test coverage detected