MCPcopy Create free account
hub / github.com/NetHack/NetHack / costly_gold

Function costly_gold

src/shk.c:5744–5786  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5742}
5743
5744void
5745costly_gold(
5746 coordxy x, coordxy y,
5747 long amount,
5748 boolean silent)
5749{
5750 long delta;
5751 struct monst *shkp;
5752 struct eshk *eshkp;
5753
5754 if (!costly_spot(x, y))
5755 return;
5756 /* shkp is guaranteed to exist after successful costly_spot(), but
5757 the static analyzer isn't smart enough to realize that, so follow
5758 the shkp assignment with a redundant test that will always fail */
5759 shkp = shop_keeper(*in_rooms(x, y, SHOPBASE));
5760 if (!shkp)
5761 return;
5762
5763 eshkp = ESHK(shkp);
5764 if (eshkp->credit >= amount) {
5765 if (!silent) {
5766 if (eshkp->credit > amount)
5767 Your("credit is reduced by %ld %s.", amount, currency(amount));
5768 else
5769 Your("credit is erased.");
5770 }
5771 eshkp->credit -= amount;
5772 } else {
5773 delta = amount - eshkp->credit;
5774 if (!silent) {
5775 if (eshkp->credit)
5776 Your("credit is erased.");
5777 if (eshkp->debit)
5778 Your("debt increases by %ld %s.", delta, currency(delta));
5779 else
5780 You("owe %s %ld %s.", shkname(shkp), delta, currency(delta));
5781 }
5782 eshkp->debit += delta;
5783 eshkp->loan += delta;
5784 eshkp->credit = 0L;
5785 }
5786}
5787
5788/* used in domove to block diagonal shop-exit */
5789/* x,y should always be a door */

Callers 2

really_kick_objectFunction · 0.85
addtobillFunction · 0.85

Calls 7

costly_spotFunction · 0.85
shop_keeperFunction · 0.85
in_roomsFunction · 0.85
YourFunction · 0.85
currencyFunction · 0.85
YouFunction · 0.85
shknameFunction · 0.85

Tested by

no test coverage detected