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

Function docallcmd

src/do_name.c:498–601  ·  view source on GitHub ↗

#call / #name command - player can name monster or object or type of obj */

Source from the content-addressed store, hash-verified

496
497/* #call / #name command - player can name monster or object or type of obj */
498int
499docallcmd(void)
500{
501 struct obj *obj;
502 winid win;
503 anything any;
504 menu_item *pick_list = 0;
505 struct _cmd_queue cq, *cmdq;
506 char ch = 0;
507 /* if player wants a,b,c instead of i,o when looting, do that here too */
508 boolean abc = flags.lootabc;
509 int clr = NO_COLOR;
510
511 if ((cmdq = cmdq_pop()) != 0) {
512 cq = *cmdq;
513 free((genericptr_t) cmdq);
514 if (cq.typ == CMDQ_KEY)
515 ch = cq.key;
516 else
517 cmdq_clear(CQ_CANNED);
518 goto docallcmd;
519 }
520 win = create_nhwindow(NHW_MENU);
521 start_menu(win, MENU_BEHAVE_STANDARD);
522 any = cg.zeroany;
523 any.a_char = 'm'; /* group accelerator 'C' */
524 add_menu(win, &nul_glyphinfo, &any, abc ? 0 : any.a_char, 'C',
525 ATR_NONE, clr, "a monster", MENU_ITEMFLAGS_NONE);
526 if (gi.invent) {
527 /* we use y and n as accelerators so that we can accept user's
528 response keyed to old "name an individual object?" prompt */
529 any.a_char = 'i'; /* group accelerator 'y' */
530 add_menu(win, &nul_glyphinfo, &any, abc ? 0 : any.a_char, 'y',
531 ATR_NONE, clr, "a particular object in inventory",
532 MENU_ITEMFLAGS_NONE);
533 any.a_char = 'o'; /* group accelerator 'n' */
534 add_menu(win, &nul_glyphinfo, &any, abc ? 0 : any.a_char, 'n',
535 ATR_NONE, clr, "the type of an object in inventory",
536 MENU_ITEMFLAGS_NONE);
537 }
538 any.a_char = 'f'; /* group accelerator ',' (or ':' instead?) */
539 add_menu(win, &nul_glyphinfo, &any, abc ? 0 : any.a_char, ',',
540 ATR_NONE, clr, "the type of an object upon the floor",
541 MENU_ITEMFLAGS_NONE);
542 any.a_char = 'd'; /* group accelerator '\' */
543 add_menu(win, &nul_glyphinfo, &any, abc ? 0 : any.a_char, '\\',
544 ATR_NONE, clr, "the type of an object on discoveries list",
545 MENU_ITEMFLAGS_NONE);
546 any.a_char = 'a'; /* group accelerator 'l' */
547 add_menu(win, &nul_glyphinfo, &any, abc ? 0 : any.a_char, 'l',
548 ATR_NONE, clr, "record an annotation for the current level",
549 MENU_ITEMFLAGS_NONE);
550 end_menu(win, "What do you want to name?");
551 if (select_menu(win, PICK_ONE, &pick_list) > 0) {
552 ch = pick_list[0].item.a_char;
553 free((genericptr_t) pick_list);
554 } else
555 ch = 'q';

Callers

nothing calls this directly

Calls 14

cmdq_popFunction · 0.85
cmdq_clearFunction · 0.85
add_menuFunction · 0.85
select_menuFunction · 0.85
do_mgivennameFunction · 0.85
getobjFunction · 0.85
do_onameFunction · 0.85
xnameFunction · 0.85
YouFunction · 0.85
call_okFunction · 0.85
docallFunction · 0.85
namefloorobjFunction · 0.85

Tested by

no test coverage detected