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

Function stolen_container

src/shk.c:3712–3751  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3710}
3711
3712staticfn long
3713stolen_container(
3714 struct obj *obj,
3715 struct monst *shkp,
3716 long price,
3717 boolean ininv)
3718{
3719 struct obj *otmp;
3720 struct bill_x *bp;
3721 long billamt;
3722
3723 /* the price of contained objects; caller handles top container */
3724 for (otmp = obj->cobj; otmp; otmp = otmp->nobj) {
3725 if (otmp->oclass == COIN_CLASS)
3726 continue;
3727 billamt = 0L;
3728 if (!billable(&shkp, otmp, ESHK(shkp)->shoproom, TRUE)) {
3729 /* billable() returns false for objects already on bill */
3730 if ((bp = onbill(otmp, shkp, FALSE)) == 0)
3731 continue;
3732 assert(shkp != NULL); /* onbill() found shkp so it's not Null */
3733 /* this assumes that we're being called by stolen_value()
3734 (or by a recursive call to self on behalf of it) where
3735 the cost of this object is about to be added to shop
3736 debt in place of having it remain on the current bill */
3737 billamt = bp->bquan * bp->price;
3738 sub_one_frombill(otmp, shkp); /* avoid double billing */
3739 }
3740
3741 if (billamt)
3742 price += billamt;
3743 else if (ininv ? otmp->unpaid : !otmp->no_charge)
3744 price += get_pricing_units(otmp) * get_cost(otmp, shkp);
3745
3746 if (Has_contents(otmp))
3747 price = stolen_container(otmp, shkp, price, ininv);
3748 }
3749
3750 return price;
3751}
3752
3753long
3754stolen_value(

Callers 1

stolen_valueFunction · 0.85

Calls 5

billableFunction · 0.85
onbillFunction · 0.85
sub_one_frombillFunction · 0.85
get_pricing_unitsFunction · 0.85
get_costFunction · 0.85

Tested by

no test coverage detected