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

Function dounpaid

src/invent.c:3653–3789  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3651}
3652
3653staticfn void
3654dounpaid(
3655 int count, /* unpaid items in inventory */
3656 int floorcount, /* unpaid items on floor (rare) */
3657 int buriedcount) /* unpaid items under the floor (extremely rare) */
3658{
3659 winid win;
3660 struct obj *otmp, *marker, *contnr;
3661 char ilet;
3662 char *invlet = flags.inv_order;
3663 int classcount, num_so_far, xtracount;
3664 long cost, totcost;
3665
3666 otmp = marker = contnr = (struct obj *) 0;
3667 xtracount = floorcount + buriedcount;
3668
3669 if (count == 1 && !xtracount) {
3670 otmp = find_unpaid(gi.invent, &marker);
3671 contnr = unknwn_contnr_contents(otmp);
3672 }
3673 if (otmp && !contnr) {
3674 /* 1 item; use pline instead of popup menu */
3675 cost = unpaid_cost(otmp, COST_NOCONTENTS);
3676 iflags.suppress_price++; /* suppress "(unpaid)" suffix */
3677 pline1(xprname(otmp, distant_name(otmp, doname),
3678 carried(otmp) ? otmp->invlet : CONTAINED_SYM,
3679 TRUE, cost, 0L));
3680 iflags.suppress_price--;
3681 return;
3682 }
3683
3684 win = create_nhwindow(NHW_MENU);
3685 totcost = 0L;
3686 num_so_far = 0; /* count of # printed so far */
3687 if (!flags.invlet_constant)
3688 reassign();
3689
3690 do {
3691 classcount = 0;
3692 for (otmp = gi.invent; otmp; otmp = otmp->nobj) {
3693 ilet = otmp->invlet;
3694 if (otmp->unpaid) {
3695 if (!flags.sortpack || otmp->oclass == *invlet) {
3696 if (flags.sortpack && !classcount) {
3697 putstr(win, 0, let_to_name(*invlet, TRUE, FALSE));
3698 classcount++;
3699 }
3700
3701 totcost += cost = unpaid_cost(otmp, COST_NOCONTENTS);
3702 iflags.suppress_price++; /* suppress "(unpaid)" suffix */
3703 putstr(win, 0, xprname(otmp, distant_name(otmp, doname),
3704 ilet, TRUE, cost, 0L));
3705 iflags.suppress_price--;
3706 num_so_far++;
3707 }
3708 }
3709 }
3710 } while (flags.sortpack && (*++invlet));

Callers 1

dotypeinvFunction · 0.85

Calls 10

find_unpaidFunction · 0.85
unknwn_contnr_contentsFunction · 0.85
unpaid_costFunction · 0.85
xprnameFunction · 0.85
distant_nameFunction · 0.85
reassignFunction · 0.85
let_to_nameFunction · 0.85
s_suffixFunction · 0.85
xnameFunction · 0.85
YouFunction · 0.85

Tested by

no test coverage detected