* Returns the number of items with b/u/c/unknown within the given list. * This does NOT include contained objects. * * Assumes that the hero sees or touches or otherwise senses the objects * at some point: bknown is forced for priest[ess], like in xname(). */
| 3545 | * at some point: bknown is forced for priest[ess], like in xname(). |
| 3546 | */ |
| 3547 | int |
| 3548 | count_buc(struct obj *list, int type, boolean (*filterfunc)(OBJ_P)) |
| 3549 | { |
| 3550 | int count = 0; |
| 3551 | |
| 3552 | for (; list; list = list->nobj) { |
| 3553 | /* priests always know bless/curse state */ |
| 3554 | if (Role_if(PM_CLERIC)) |
| 3555 | list->bknown = (list->oclass != COIN_CLASS); |
| 3556 | /* some actions exclude some or most items */ |
| 3557 | if (filterfunc && !(*filterfunc)(list)) |
| 3558 | continue; |
| 3559 | |
| 3560 | /* coins are either uncursed or unknown based upon option setting */ |
| 3561 | if (list->oclass == COIN_CLASS) { |
| 3562 | if (type == (flags.goldX ? BUC_UNKNOWN : BUC_UNCURSED)) |
| 3563 | ++count; |
| 3564 | continue; |
| 3565 | } |
| 3566 | /* check whether this object matches the requested type */ |
| 3567 | if (!list->bknown |
| 3568 | ? (type == BUC_UNKNOWN) |
| 3569 | : list->blessed ? (type == BUC_BLESSED) |
| 3570 | : list->cursed ? (type == BUC_CURSED) |
| 3571 | : (type == BUC_UNCURSED)) |
| 3572 | ++count; |
| 3573 | } |
| 3574 | return count; |
| 3575 | } |
| 3576 | |
| 3577 | /* similar to count_buc(), but tallies all states at once |
| 3578 | rather than looking for a specific type */ |
no outgoing calls
no test coverage detected