From 7a008b62b72447b20c7fd499a2facc001d758ceb Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Mon, 27 Jun 2022 10:10:17 -0400 Subject: [PATCH 1/2] Permit gold to be included in justpicked typeinv Just-picked-up gold was included in the list of items in the just-picked category for most category-based menus like 'D' or #loot, but special handling of gold for 'I'/#inventtype (to accomodate the 'goldX' option) caused it to be excluded from consideration as a just-picked item. Include recently picked up gold in 'P'/justpicked when doing type inventory, consist with other category-menu-based actions. --- src/invent.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/invent.c b/src/invent.c index 07c74ca3c..99ffc9335 100644 --- a/src/invent.c +++ b/src/invent.c @@ -3632,6 +3632,8 @@ tally_BUCX(struct obj *list, boolean by_nexthere, /* priests always know bless/curse state */ if (Role_if(PM_CLERIC)) list->bknown = (list->oclass != COIN_CLASS); + if (list->pickup_prev) + ++(*jcp); /* coins are either uncursed or unknown based upon option setting */ if (list->oclass == COIN_CLASS) { if (flags.goldX) @@ -3640,8 +3642,6 @@ tally_BUCX(struct obj *list, boolean by_nexthere, ++(*ucp); continue; } - if (list->pickup_prev) - ++(*jcp); /* ordinary items */ if (!list->bknown) ++(*xcp); @@ -3795,7 +3795,9 @@ this_type_only(struct obj *obj) { boolean res = (obj->oclass == g.this_type); - if (obj->oclass == COIN_CLASS) { + if (g.this_type == 'P') { + res = obj->pickup_prev; + } else if (obj->oclass == COIN_CLASS) { /* if filtering by bless/curse state, gold is classified as either unknown or uncursed based on user option setting */ if (g.this_type && index("BUCX", g.this_type)) @@ -3814,9 +3816,6 @@ this_type_only(struct obj *obj) case 'X': res = !obj->bknown; break; - case 'P': - res = obj->pickup_prev; - break; default: break; /* use 'res' as-is */ } From d5232c769370401c706f6a257bf0f864fc517622 Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Mon, 27 Jun 2022 16:17:52 -0400 Subject: [PATCH 2/2] allow_category: honor 'goldX' more consistently A comment in allow_category states that if gold is explicitly selected as a category, it should be included in the results regardless of what other BUCX filters may have also been applied. That makes sense to me: there's only one thing in the gold category, and it always has the same BUCX status, so it's pointless to try to "filter" the gold category with a BUCX filter. Considering it a "also add gold, on top of the filtered results" category adds utility. However, other categories which may include gold (specifically justpicked; unpaid is in the code too, but that can't actually happen in-game) were treated the same way: if the category included gold, no filter could exclude it. As a result, if the hero had just picked up gold, 'P'+'C', 'P'+'U', 'P'+'X', and 'P'+'B' all showed the just-picked gold pieces -- there was no way to filter justpicked to exclude gold the BUCX categories. This approach made less sense to me: justpicked as a category may include gold, but filtering by BUCX actually has utility there, and selecting it doesn't carry a "show me gold in addition to the other filtered items" implication. Maintain the same special treatment of selecting the coins category, but drop it for justpicked and unpaid. In those cases whether gold is listed in the justpicked result will depend on it not being filtered out by the selected BUCX categories (and which one it belongs to, in turn, depends on the 'goldX' option). --- src/pickup.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/pickup.c b/src/pickup.c index c8471e43d..21751d2ce 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -459,20 +459,9 @@ allow_category(struct obj *obj) /* For coins, if any class filter is specified, accept if coins * are included regardless of whether either unpaid or BUC-status * is also specified since player has explicitly requested coins. - * If no class filtering is specified but bless/curse state is, - * coins are either unknown or uncursed based on an option setting. */ - if (obj->oclass == COIN_CLASS) - return g.class_filter - ? (index(g.valid_menu_classes, COIN_CLASS) ? TRUE : FALSE) - : g.shop_filter /* coins are never unpaid, but check anyway */ - ? (obj->unpaid ? TRUE : FALSE) - : g.picked_filter - ? obj->pickup_prev - : g.bucx_filter - ? (index(g.valid_menu_classes, flags.goldX ? 'X' : 'U') - ? TRUE : FALSE) - : TRUE; /* catchall: no filters specified, so accept */ + if (obj->oclass == COIN_CLASS && g.class_filter) + return index(g.valid_menu_classes, COIN_CLASS) ? TRUE : FALSE; if (Role_if(PM_CLERIC) && !obj->bknown) set_bknown(obj, 1); @@ -505,8 +494,18 @@ allow_category(struct obj *obj) /* check for particular bless/curse state */ if (g.bucx_filter) { /* first categorize this object's bless/curse state */ - char bucx = !obj->bknown ? 'X' - : obj->blessed ? 'B' : obj->cursed ? 'C' : 'U'; + char bucx; + if (obj->oclass == COIN_CLASS) { + /* If no class filtering is specified but bless/curse state is, + coins are treated as either unknown or uncursed based on an + option setting. */ + bucx = flags.goldX ? 'X' : 'U'; + } else { + bucx = !obj->bknown ? 'X' + : obj->blessed ? 'B' + : obj->cursed ? 'C' + : 'U'; + } /* if its category is not in the list, reject */ if (!index(g.valid_menu_classes, bucx))