MCPcopy Create free account
hub / github.com/NetHack/NetHack / menu_remarm

Function menu_remarm

src/do_wear.c:3089–3138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3087}
3088
3089staticfn int
3090menu_remarm(int retry)
3091{
3092 int n, i = 0;
3093 menu_item *pick_list;
3094 boolean all_worn_categories = TRUE;
3095
3096 if (retry) {
3097 all_worn_categories = (retry == -2);
3098 } else if (flags.menu_style == MENU_FULL) {
3099 all_worn_categories = FALSE;
3100 n = query_category("What type of things do you want to take off?",
3101 gi.invent, (WORN_TYPES | ALL_TYPES
3102 | UNPAID_TYPES | BUCX_TYPES),
3103 &pick_list, PICK_ANY);
3104 if (!n)
3105 return 0;
3106 for (i = 0; i < n; i++) {
3107 if (pick_list[i].item.a_int == ALL_TYPES_SELECTED)
3108 all_worn_categories = TRUE;
3109 else
3110 add_valid_menu_class(pick_list[i].item.a_int);
3111 }
3112 free((genericptr_t) pick_list);
3113 } else if (flags.menu_style == MENU_COMBINATION) {
3114 unsigned ggofeedback = 0;
3115
3116 i = ggetobj("take off", select_off, 0, TRUE, &ggofeedback);
3117 if (ggofeedback & ALL_FINISHED)
3118 return 0;
3119 all_worn_categories = (i == -2);
3120 }
3121 if (menu_class_present('u')
3122 || menu_class_present('B') || menu_class_present('U')
3123 || menu_class_present('C') || menu_class_present('X'))
3124 all_worn_categories = FALSE;
3125
3126 n = query_objlist("What do you want to take off?", &gi.invent,
3127 (SIGNAL_NOMENU | USE_INVLET | INVORDER_SORT),
3128 &pick_list, PICK_ANY,
3129 all_worn_categories ? is_worn : is_worn_by_type);
3130 if (n > 0) {
3131 for (i = 0; i < n; i++)
3132 (void) select_off(pick_list[i].item.a_obj);
3133 free((genericptr_t) pick_list);
3134 } else if (n < 0 && flags.menu_style != MENU_COMBINATION) {
3135 There("is nothing else you can remove or unwield.");
3136 }
3137 return 0;
3138}
3139
3140/* take off the specific worn object and if it still exists after that,
3141 destroy it (taking off the item might already destroy it by dunking

Callers 1

doddoremarmFunction · 0.85

Calls 7

query_categoryFunction · 0.85
add_valid_menu_classFunction · 0.85
ggetobjFunction · 0.85
menu_class_presentFunction · 0.85
query_objlistFunction · 0.85
select_offFunction · 0.85
ThereFunction · 0.85

Tested by

no test coverage detected