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

Function addtobill

src/shk.c:3489–3599  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3487}
3488
3489void
3490addtobill(
3491 struct obj *obj,
3492 boolean ininv,
3493 boolean dummy,
3494 boolean silent)
3495{
3496 struct monst *shkp = 0;
3497 long ltmp, cltmp, gltmp;
3498 int contentscount;
3499 boolean container;
3500
3501 if (!billable(&shkp, obj, *u.ushops, TRUE))
3502 return;
3503
3504 if (obj->oclass == COIN_CLASS) {
3505 costly_gold(obj->ox, obj->oy, obj->quan, silent);
3506 return;
3507 } else if (ESHK(shkp)->billct == BILLSZ) {
3508 if (!silent)
3509 You("got that for free!");
3510 return;
3511 }
3512
3513 ltmp = cltmp = gltmp = 0L;
3514 container = Has_contents(obj);
3515
3516 if (!obj->no_charge) {
3517 ltmp = get_cost(obj, shkp);
3518 if (obj->globby)
3519 ltmp *= get_pricing_units(obj);
3520 }
3521 if (obj->no_charge && !container) {
3522 obj->no_charge = 0;
3523 return;
3524 }
3525
3526 if (container) {
3527 cltmp = contained_cost(obj, shkp, cltmp, FALSE, FALSE);
3528 gltmp = contained_gold(obj, TRUE);
3529
3530 if (ltmp)
3531 add_one_tobill(obj, dummy, shkp);
3532 if (cltmp)
3533 bill_box_content(obj, ininv, dummy, shkp);
3534 picked_container(obj); /* reset contained obj->no_charge */
3535
3536 ltmp += cltmp;
3537
3538 if (gltmp) {
3539 costly_gold(obj->ox, obj->oy, gltmp, silent);
3540 if (!ltmp)
3541 return;
3542 }
3543
3544 if (obj->no_charge)
3545 obj->no_charge = 0;
3546 contentscount = count_unpaid(obj->cobj);

Callers 14

rlocoFunction · 0.85
dopushFunction · 0.85
useupfFunction · 0.85
pick_objFunction · 0.85
in_containerFunction · 0.85
out_containerFunction · 0.85
tipcontainerFunction · 0.85
tipcontainer_checksFunction · 0.85
bill_dummy_objectFunction · 0.85
hornoplentyFunction · 0.85
polyuseFunction · 0.85
do_osshockFunction · 0.85

Calls 15

billableFunction · 0.85
costly_goldFunction · 0.85
YouFunction · 0.85
get_costFunction · 0.85
get_pricing_unitsFunction · 0.85
contained_costFunction · 0.85
contained_goldFunction · 0.85
add_one_tobillFunction · 0.85
bill_box_contentFunction · 0.85
picked_containerFunction · 0.85
count_unpaidFunction · 0.85
ShknamFunction · 0.85

Tested by

no test coverage detected