From 36a921ca3b5b8fae547ac44894639e042001c7cd Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 30 Jun 2017 23:51:14 -0700 Subject: [PATCH] more obj filtering Add support for filtering by unpaid status for container-in and container-out actions. When taking out of a container, it works as expected if you're carrying the container while in a shop, but won't find any unpaid items if the container is on the floor. That's because they're only flagged as unpaid while in the hero's inventory. (And when it doesn't find any unpaid items it won't list 'unpaid' as a category of item to manipulate, so while that might be suboptimal for taking items out of shop containers, it shouldn't be a problem. Typically all the contents are shop-owned anyway, so using unpaid as a filter wouldn't gain any advantage over just taking stuff out.) --- src/invent.c | 3 ++- src/pickup.c | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/invent.c b/src/invent.c index cb1cfb2d0..b5ed81c6d 100644 --- a/src/invent.c +++ b/src/invent.c @@ -1747,7 +1747,8 @@ int FDECL((*fn), (OBJ_P)), FDECL((*ckfn), (OBJ_P)); nodot = (!strcmp(word, "nodot") || !strcmp(word, "drop") || ident || takeoff || take_out || put_in); ininv = (*objchn == invent); - bycat = (menu_class_present('B') || menu_class_present('U') + bycat = (menu_class_present('u') + || menu_class_present('B') || menu_class_present('U') || menu_class_present('C') || menu_class_present('X')); /* someday maybe we'll sort by 'olets' too (temporarily replace diff --git a/src/pickup.c b/src/pickup.c index 2395c4110..0b91a4bb4 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -177,6 +177,8 @@ int *menu_on_demand; } if (itemcount && menu_on_demand) ilets[iletct++] = 'm'; + if (count_unpaid(objs)) + ilets[iletct++] = 'u'; tally_BUCX(objs, here, &bcnt, &ucnt, &ccnt, &xcnt, &ocnt); if (bcnt) @@ -222,8 +224,8 @@ int *menu_on_demand; goto ask_again; } else if (sym == 'm') { m_seen = TRUE; - } else if (index("BUCX", sym)) { - add_valid_menu_class(sym); /* 'B','U','C',or 'X' */ + } else if (index("uBUCX", sym)) { + add_valid_menu_class(sym); /* 'u' or 'B','U','C',or 'X' */ filtered = TRUE; } else { oc_of_sym = def_char_to_objclass(sym); @@ -2666,7 +2668,7 @@ boolean put_in; } else if (flags.menu_style == MENU_FULL) { all_categories = FALSE; Sprintf(buf, "%s what type of objects?", action); - mflags = (ALL_TYPES | BUCX_TYPES); + mflags = (ALL_TYPES | UNPAID_TYPES | BUCX_TYPES); if (put_in) mflags |= CHOOSE_ALL; n = query_category(buf, put_in ? invent : current_container->cobj,