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

Function alter_cost

src/shk.c:3236–3256  ·  view source on GitHub ↗

called when an item's value has been enhanced; if it happens to be on any shop bill, update that bill to reflect the new higher price [if the new price drops for some reason, keep the old one in place] */

Source from the content-addressed store, hash-verified

3234 on any shop bill, update that bill to reflect the new higher price
3235 [if the new price drops for some reason, keep the old one in place] */
3236void
3237alter_cost(
3238 struct obj *obj,
3239 long amt) /* if 0, use regular shop pricing, otherwise force amount;
3240 if negative, use abs(amt) even if it's less than old cost */
3241{
3242 struct bill_x *bp = 0;
3243 struct monst *shkp;
3244 long new_price;
3245
3246 for (shkp = next_shkp(fmon, TRUE); shkp; shkp = next_shkp(shkp, TRUE))
3247 if ((bp = onbill(obj, shkp, TRUE)) != 0) {
3248 new_price = !amt ? get_cost(obj, shkp) : (amt < 0L) ? -amt : amt;
3249 if (new_price > bp->price || amt < 0L) {
3250 bp->price = new_price;
3251 update_inventory();
3252 }
3253 break; /* done */
3254 }
3255 return;
3256}
3257
3258/* called from doinv(invent.c) for inventory of unpaid objects */
3259long

Callers 7

chweponFunction · 0.85
onameFunction · 0.85
H2Opotion_dipFunction · 0.85
bill_dummy_objectFunction · 0.85
rechargeFunction · 0.85
seffect_enchant_armorFunction · 0.85
seffect_remove_curseFunction · 0.85

Calls 4

next_shkpFunction · 0.85
onbillFunction · 0.85
get_costFunction · 0.85
update_inventoryFunction · 0.85

Tested by

no test coverage detected