| 5950 | } |
| 5951 | |
| 5952 | staticfn int |
| 5953 | handler_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, ¶noia_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 |
no test coverage detected