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

Function tally_BUCX

src/invent.c:3579–3616  ·  view source on GitHub ↗

similar to count_buc(), but tallies all states at once rather than looking for a specific type */

Source from the content-addressed store, hash-verified

3577/* similar to count_buc(), but tallies all states at once
3578 rather than looking for a specific type */
3579void
3580tally_BUCX(
3581 struct obj *list,
3582 boolean by_nexthere,
3583 int *bcp, int *ucp, int *ccp, int *xcp, int *ocp, int *jcp)
3584{
3585 /* Future extensions:
3586 * Skip current_container when list is invent, uchain when
3587 * first object of list is located on the floor. 'ocp' will then
3588 * have a function again (it was a counter for having skipped gold,
3589 * but that's not skipped anymore).
3590 */
3591 *bcp = *ucp = *ccp = *xcp = *ocp = *jcp = 0;
3592 for ( ; list; list = (by_nexthere ? list->nexthere : list->nobj)) {
3593 /* priests always know bless/curse state */
3594 if (Role_if(PM_CLERIC))
3595 list->bknown = (list->oclass != COIN_CLASS);
3596 if (list->pickup_prev)
3597 ++(*jcp);
3598 /* coins are either uncursed or unknown based upon option setting */
3599 if (list->oclass == COIN_CLASS) {
3600 if (flags.goldX)
3601 ++(*xcp);
3602 else
3603 ++(*ucp);
3604 continue;
3605 }
3606 /* ordinary items */
3607 if (!list->bknown)
3608 ++(*xcp);
3609 else if (list->blessed)
3610 ++(*bcp);
3611 else if (list->cursed)
3612 ++(*ccp);
3613 else /* neither blessed nor cursed => uncursed */
3614 ++(*ucp);
3615 }
3616}
3617
3618/* count everything inside a container, or just shop-owned items inside */
3619long

Callers 2

dotypeinvFunction · 0.85
query_classesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected