| 5678 | } |
| 5679 | |
| 5680 | DISABLE_WARNING_FORMAT_NONLITERAL |
| 5681 | |
| 5682 | /* Charge the player for partial use of an unpaid object. |
| 5683 | * |
| 5684 | * Note that bill_dummy_object() should be used instead |
| 5685 | * when an object is completely used. |
| 5686 | */ |
| 5687 | void |
| 5688 | check_unpaid_usage(struct obj *otmp, boolean altusage) |
| 5689 | { |
| 5690 | struct monst *shkp; |
| 5691 | const char *fmt, *arg1, *arg2; |
| 5692 | char buf[BUFSZ]; |
| 5693 | long tmp; |
| 5694 | |
| 5695 | if (!otmp->unpaid || !*u.ushops |
| 5696 | || (otmp->spe <= 0 && objects[otmp->otyp].oc_charged)) |
| 5697 | return; |
| 5698 | shkp = shop_keeper(*u.ushops); |
| 5699 | if (!shkp || !inhishop(shkp)) |
| 5700 | return; |
| 5701 | if ((tmp = cost_per_charge(shkp, otmp, altusage)) == 0L) |
| 5702 | return; |
| 5703 | |
| 5704 | arg1 = arg2 = ""; |
| 5705 | if (otmp->oclass == SPBOOK_CLASS) { |
| 5706 | fmt = "%sYou owe%s %ld %s."; |
| 5707 | Sprintf(buf, "This is no free library, %s! ", cad(FALSE)); |
| 5708 | arg1 = rn2(2) ? buf : ""; |
| 5709 | arg2 = ESHK(shkp)->debit > 0L ? " an additional" : ""; |
| 5710 | } else if (otmp->otyp == POT_OIL) { |
| 5711 | fmt = "%s%sThat will cost you %ld %s (Yendorian Fuel Tax)."; |
| 5712 | } else if (altusage && (otmp->otyp == BAG_OF_TRICKS |
| 5713 | || otmp->otyp == HORN_OF_PLENTY)) { |
| 5714 | fmt = "%s%sEmptying that will cost you %ld %s."; |
| 5715 | if (!rn2(3)) |
| 5716 | arg1 = "Whoa! "; |
| 5717 | if (!rn2(3)) |
| 5718 | arg1 = "Watch it! "; |
| 5719 | } else { |
| 5720 | fmt = "%s%sUsage fee, %ld %s."; |
| 5721 | if (!rn2(3)) |
| 5722 | arg1 = "Hey! "; |
| 5723 | if (!rn2(3)) |
| 5724 | arg2 = "Ahem. "; |
| 5725 | } |
| 5726 | |
| 5727 | if (!Deaf && !muteshk(shkp)) { |
| 5728 | SetVoice(shkp, 0, 80, 0); |
| 5729 | verbalize(fmt, arg1, arg2, tmp, currency(tmp)); |
| 5730 | exercise(A_WIS, TRUE); /* you just got info */ |
| 5731 | } |
| 5732 | ESHK(shkp)->debit += tmp; |
| 5733 | } |
| 5734 | |
| 5735 | RESTORE_WARNING_FORMAT_NONLITERAL |
| 5736 |
no test coverage detected