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

Function handler_paranoid_confirmation

src/options.c:5952–6008  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5950}
5951
5952staticfn int
5953handler_paranoid_confirmation(void)
5954{
5955 winid tmpwin;
5956 anything any;
5957 int i;
5958 char mkey, mbuf[QBUFSZ], ebuf[BUFSZ], cbuf[QBUFSZ];
5959 const char *explain, *cmdnm;
5960 menu_item *paranoia_picks = (menu_item *) 0;
5961 int clr = NO_COLOR;
5962
5963 tmpwin = create_nhwindow(NHW_MENU);
5964 start_menu(tmpwin, MENU_BEHAVE_STANDARD);
5965 any = cg.zeroany;
5966 for (i = 0; paranoia[i].flagmask != 0; ++i) {
5967 if (paranoia[i].flagmask == PARANOID_BONES && !wizard)
5968 continue;
5969 /* the 'swim' choice mentions the 'm' movement prefix in its
5970 explanation; if that's been bound to something else or been
5971 unbound altogether, substitute the replacement in the text */
5972 explain = paranoia[i].explain;
5973 if (strstri(explain, "'m'")
5974 && (mkey = cmd_from_func(do_reqmenu)) != 'm') {
5975 if (mkey) { /* key for 'm' prefix */
5976 Sprintf(mbuf, "'%.9s'", visctrl(mkey)); /* .5 is enough */
5977 } else { /* extended command name for 'm' prefix */
5978 cmdnm = cmdname_from_func(do_reqmenu, cbuf, TRUE);
5979 if (!cmdnm)
5980 cmdnm = "reqmenu";
5981 Sprintf(mbuf, "'%s%.31s'", (*cmdnm != '#') ? "#" : "", cmdnm);
5982 }
5983 explain = strsubst(strcpy(ebuf, explain), "'m'", mbuf);
5984 }
5985 any.a_int = paranoia[i].flagmask;
5986 add_menu(tmpwin, &nul_glyphinfo, &any, *paranoia[i].argname,
5987 0, ATR_NONE, clr, explain,
5988 (flags.paranoia_bits & paranoia[i].flagmask)
5989 ? MENU_ITEMFLAGS_SELECTED
5990 : MENU_ITEMFLAGS_NONE);
5991 }
5992 end_menu(tmpwin, "Actions requiring extra confirmation:");
5993 i = select_menu(tmpwin, PICK_ANY, &paranoia_picks);
5994 if (i >= 0) {
5995 /* player didn't cancel; we reset all the paranoia options
5996 here even if there were no items picked, since user
5997 could have toggled off preselected ones to end up with 0 */
5998 flags.paranoia_bits = 0;
5999 if (i > 0) {
6000 /* at least 1 item set, either preselected or newly picked */
6001 while (--i >= 0)
6002 flags.paranoia_bits |= paranoia_picks[i].item.a_int;
6003 free((genericptr_t) paranoia_picks);
6004 }
6005 }
6006 destroy_nhwindow(tmpwin);
6007 return optn_ok;
6008}
6009

Callers 1

Calls 7

strstriFunction · 0.85
cmd_from_funcFunction · 0.85
visctrlFunction · 0.85
cmdname_from_funcFunction · 0.85
strsubstFunction · 0.85
add_menuFunction · 0.85
select_menuFunction · 0.85

Tested by

no test coverage detected