| 520 | } |
| 521 | |
| 522 | boolean |
| 523 | allow_category(struct obj *obj) |
| 524 | { |
| 525 | /* If no filters are active, nothing will match unless |
| 526 | paranoid_confirm:A is set. */ |
| 527 | if (!gc.class_filter && !gs.shop_filter && !gb.bucx_filter |
| 528 | && !gp.picked_filter && !ParanoidAutoAll) |
| 529 | return FALSE; |
| 530 | |
| 531 | /* For coins, if any class filter is specified, accept if coins |
| 532 | * are included regardless of whether either unpaid or BUC-status |
| 533 | * is also specified since player has explicitly requested coins. |
| 534 | */ |
| 535 | if (obj->oclass == COIN_CLASS && gc.class_filter) |
| 536 | return strchr(gv.valid_menu_classes, COIN_CLASS) ? TRUE : FALSE; |
| 537 | |
| 538 | if (Role_if(PM_CLERIC) && !obj->bknown) |
| 539 | set_bknown(obj, 1); |
| 540 | |
| 541 | /* |
| 542 | * Version 3.6 had three types of filters possible and the first |
| 543 | * and third can have more than one entry: |
| 544 | * 1) object class (armor, potion, &c); |
| 545 | * 2) unpaid shop item; |
| 546 | * 3) bless/curse state (blessed, uncursed, cursed, BUC-unknown). |
| 547 | * Version 5.0 added a fourth: |
| 548 | * 4) 'novelty' ('P' for just picked up items). |
| 549 | * When only one type is present, the situation is simple: |
| 550 | * to be accepted, obj's status must match one of the entries. |
| 551 | * When more than one type is present, the obj will now only |
| 552 | * be accepted when it matches one entry of each type. |
| 553 | * So ?!B will accept blessed scrolls or potions, and [u will |
| 554 | * accept unpaid armor. (In 3.4.3, an object was accepted by |
| 555 | * this filter if it met any entry of any type, so ?!B resulted |
| 556 | * in accepting all scrolls and potions regardless of bless/curse |
| 557 | * state plus all blessed non-scroll, non-potion objects.) |
| 558 | */ |
| 559 | |
| 560 | /* if class is expected but obj's class is not in the list, reject */ |
| 561 | if (gc.class_filter && !strchr(gv.valid_menu_classes, obj->oclass)) |
| 562 | return FALSE; |
| 563 | /* if unpaid is expected and obj isn't unpaid, reject (treat a container |
| 564 | holding any unpaid object as unpaid even if isn't unpaid itself) */ |
| 565 | if (gs.shop_filter && !obj->unpaid |
| 566 | && !(Has_contents(obj) && count_unpaid(obj->cobj) > 0)) |
| 567 | return FALSE; |
| 568 | /* check for particular bless/curse state */ |
| 569 | if (gb.bucx_filter) { |
| 570 | /* first categorize this object's bless/curse state */ |
| 571 | char bucx; |
| 572 | if (obj->oclass == COIN_CLASS) { |
| 573 | /* If no class filtering is specified but bless/curse state is, |
| 574 | coins are treated as either unknown or uncursed based on an |
| 575 | option setting. */ |
| 576 | bucx = flags.goldX ? 'X' : 'U'; |
| 577 | } else { |
| 578 | bucx = !obj->bknown ? 'X' |
| 579 | : obj->blessed ? 'B' |
no test coverage detected