MCPcopy Index your code
hub / github.com/NetHack/NetHack / menu_drop

Function menu_drop

src/do.c:980–1107  ·  view source on GitHub ↗

Drop things from the hero's inventory, using a menu. */

Source from the content-addressed store, hash-verified

978
979/* Drop things from the hero's inventory, using a menu. */
980staticfn int
981menu_drop(int retry)
982{
983 int n, i, n_dropped = 0;
984 struct obj *otmp, *otmp2;
985 menu_item *pick_list;
986 boolean all_categories = TRUE, drop_everything = FALSE, autopick = FALSE;
987 boolean drop_justpicked = FALSE;
988 long justpicked_quan = 0;
989
990 if (retry) {
991 all_categories = (retry == -2);
992 } else if (flags.menu_style == MENU_FULL) {
993 all_categories = FALSE;
994 n = query_category("Drop what type of items?", gi.invent,
995 (UNPAID_TYPES | ALL_TYPES | CHOOSE_ALL
996 | BUC_BLESSED | BUC_CURSED | BUC_UNCURSED
997 | BUC_UNKNOWN | JUSTPICKED | INCLUDE_VENOM),
998 &pick_list, PICK_ANY);
999 /* when paranoid_confirm:A is set, 'A' by itself implies
1000 'A'+'a' which will be followed by a confirmation prompt;
1001 when that option isn't set, 'A' by itself is rejected
1002 by query_categorry() and result here will be n==0 */
1003 if (!n)
1004 goto drop_done; /* no non-autopick category filters specified */
1005
1006 for (i = 0; i < n; i++) {
1007 if (pick_list[i].item.a_int == ALL_TYPES_SELECTED) {
1008 all_categories = TRUE;
1009 } else if (pick_list[i].item.a_int == 'A') {
1010 drop_everything = autopick = TRUE;
1011 } else if (pick_list[i].item.a_int == 'P') {
1012 justpicked_quan = max(0, pick_list[i].count);
1013 drop_justpicked = TRUE;
1014 drop_everything = FALSE;
1015 add_valid_menu_class(pick_list[i].item.a_int);
1016 } else {
1017 add_valid_menu_class(pick_list[i].item.a_int);
1018 drop_everything = FALSE;
1019 }
1020 }
1021 free((genericptr_t) pick_list);
1022 } else if (flags.menu_style == MENU_COMBINATION) {
1023 unsigned ggoresults = 0;
1024
1025 all_categories = FALSE;
1026 /* Gather valid classes via traditional NetHack method */
1027 i = ggetobj("drop", drop, 0, TRUE, &ggoresults);
1028 if (i == -2)
1029 all_categories = TRUE;
1030 if ((ggoresults & ALL_FINISHED) != 0) {
1031 n_dropped = i;
1032 goto drop_done;
1033 }
1034 }
1035
1036 if (autopick) {
1037 /*

Callers 1

doddropFunction · 0.85

Calls 11

query_categoryFunction · 0.85
add_valid_menu_classFunction · 0.85
ggetobjFunction · 0.85
bypass_objlistFunction · 0.85
nxt_unbypassed_objFunction · 0.85
allow_categoryFunction · 0.85
dropFunction · 0.85
count_justpickedFunction · 0.85
find_justpickedFunction · 0.85
menudrop_splitFunction · 0.85
query_objlistFunction · 0.85

Tested by

no test coverage detected