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

Function traditional_loot

src/pickup.c:3229–3261  ·  view source on GitHub ↗

loot current_container (take things out or put things in), by prompting */

Source from the content-addressed store, hash-verified

3227
3228/* loot current_container (take things out or put things in), by prompting */
3229staticfn int
3230traditional_loot(boolean put_in)
3231{
3232 int (*actionfunc)(OBJ_P), (*checkfunc)(OBJ_P);
3233 struct obj **objlist;
3234 char selection[MAXOCLASSES + 10]; /* +10: room for B,U,C,X plus slop */
3235 const char *action;
3236 boolean one_by_one, allflag;
3237 int used = ECMD_OK, menu_on_request = 0;
3238
3239 if (put_in) {
3240 action = "put in";
3241 objlist = &gi.invent;
3242 actionfunc = in_container;
3243 checkfunc = ck_bag;
3244 } else {
3245 action = "take out";
3246 objlist = &(gc.current_container->cobj);
3247 actionfunc = out_container;
3248 checkfunc = (int (*)(OBJ_P)) 0;
3249 gp.pickup_encumbrance = 0; /* used to limit verbosity */
3250 }
3251
3252 if (query_classes(selection, &one_by_one, &allflag, action, *objlist,
3253 FALSE, &menu_on_request)) {
3254 if (askchain(objlist, (one_by_one ? (char *) 0 : selection), allflag,
3255 actionfunc, checkfunc, 0, action))
3256 used = ECMD_TIME;
3257 } else if (menu_on_request < 0) {
3258 used = (menu_loot(menu_on_request, put_in) > 0);
3259 }
3260 return used;
3261}
3262
3263/* loot current_container (take things out or put things in), using a menu */
3264staticfn int

Callers 1

use_containerFunction · 0.85

Calls 3

query_classesFunction · 0.85
askchainFunction · 0.85
menu_lootFunction · 0.85

Tested by

no test coverage detected