]> granicus.if.org Git - nethack/commitdiff
more obj filtering
authorPatR <rankin@nethack.org>
Sat, 1 Jul 2017 06:51:14 +0000 (23:51 -0700)
committerPatR <rankin@nethack.org>
Sat, 1 Jul 2017 06:51:14 +0000 (23:51 -0700)
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
src/pickup.c

index cb1cfb2d0b380983147c55229a41ab08a6440a5d..b5ed81c6ddbe2db2425c1060fd46a049ce4b4cc4 100644 (file)
@@ -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
index 2395c411064a4701966a120bb734a59cd3460d0c..0b91a4bb42213d760b6b34d6c9df3e6852bbcf10 100644 (file)
@@ -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,