MCPcopy Create free account
hub / github.com/crawl/crawl / pickup_menu

Function pickup_menu

crawl-ref/source/items.cc:1047–1114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1045}
1046
1047void pickup_menu(int item_link)
1048{
1049 int n_did_pickup = 0;
1050
1051 // XX why is this const?
1052 auto items = const_item_list_on_square(item_link);
1053 ASSERT(items.size());
1054
1055 string prompt = "Pick up what? " + slot_description() + " (_ for help)";
1056
1057 if (items.size() == 1 && items[0]->quantity > 1)
1058 prompt = "Select pick up quantity by entering a number, then select the item";
1059 vector<SelItem> selected = select_items(items, prompt.c_str(), false,
1060 menu_type::pickup);
1061 if (selected.empty())
1062 canned_msg(MSG_OK);
1063 redraw_screen();
1064 update_screen();
1065
1066 string pickup_warning;
1067 for (const SelItem &sel : selected)
1068 {
1069 // Moving the item might destroy it, in which case we can't
1070 // rely on the link.
1071 short next;
1072 for (int j = item_link; j != NON_ITEM; j = next)
1073 {
1074 next = env.item[j].link;
1075 if (&env.item[j] == sel.item)
1076 {
1077 if (j == item_link)
1078 item_link = next;
1079
1080 int num_to_take = sel.quantity;
1081 const bool take_all = (num_to_take == env.item[j].quantity);
1082 iflags_t oldflags = env.item[j].flags;
1083 clear_item_pickup_flags(env.item[j]);
1084
1085 // If we cleared any flags on the items, but the pickup was
1086 // partial, reset the flags for the items that remain on the
1087 // floor.
1088 if (!move_item_to_inv(j, num_to_take))
1089 {
1090 pickup_warning = "You can't carry that many items.";
1091 if (env.item[j].defined())
1092 env.item[j].flags = oldflags;
1093 }
1094 else
1095 {
1096 // If we deliberately chose to take only part of a
1097 // pile, we consider the rest to have been
1098 // "dropped."
1099 if (!take_all && env.item[j].defined())
1100 env.item[j].flags |= ISFLAG_DROPPED;
1101 }
1102 }
1103 }
1104 }

Callers 2

handle_mouseMethod · 0.85
pickupFunction · 0.85

Calls 13

slot_descriptionFunction · 0.85
select_itemsFunction · 0.85
canned_msgFunction · 0.85
redraw_screenFunction · 0.85
clear_item_pickup_flagsFunction · 0.85
move_item_to_invFunction · 0.85
mprFunction · 0.85
learned_something_newFunction · 0.85
update_screenFunction · 0.70
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected