diff --git a/include/func_tab.h b/include/func_tab.h index 878b12817..ca2c07c3d 100644 --- a/include/func_tab.h +++ b/include/func_tab.h @@ -14,6 +14,7 @@ #define CMD_NOT_AVAILABLE 0x10 /* recognized but non-functional (!SHELL,&c) */ #define NOFUZZERCMD 0x20 /* fuzzer cannot execute this command */ #define INTERNALCMD 0x40 /* only for internal use, not for user */ +#define CMD_M_PREFIX 0x80 /* accepts menu prefix */ struct ext_func_tab { uchar key; diff --git a/src/cmd.c b/src/cmd.c index 624fa35fa..ec3f62544 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -146,7 +146,7 @@ static void mon_chain(winid, const char *, struct monst *, boolean, long *, long *); static void contained_stats(winid, const char *, long *, long *); static void misc_stats(winid, long *, long *); -static boolean accept_menu_prefix(int (*)(void)); +static boolean accept_menu_prefix(const struct ext_func_tab *); static void add_herecmd_menuitem(winid, int (*)(void), const char *); static char here_cmd_menu(boolean); @@ -387,7 +387,7 @@ doextcmd(void) func = extcmdlist[idx].ef_funct; if (!can_do_extcmd(&extcmdlist[idx])) return 0; - if (iflags.menu_requested && !accept_menu_prefix(func)) { + if (iflags.menu_requested && !accept_menu_prefix(&extcmdlist[idx])) { pline("'%s' prefix has no effect for the %s command.", visctrl(g.Cmd.spkeys[NHKF_REQMENU]), extcmdlist[idx].ef_txt); @@ -421,7 +421,7 @@ doc_extcmd_flagstr(winid menuwin, MENU_ITEMFLAGS_NONE); return (char *) 0; } else { - boolean mprefix = accept_menu_prefix(efp->ef_funct), + boolean mprefix = accept_menu_prefix(efp), autocomplete = (efp->flags & AUTOCOMPLETE) != 0; char *p = Abuf; @@ -1852,15 +1852,15 @@ doterrain(void) such as ^O/#overview and C/N/#name */ struct ext_func_tab extcmdlist[] = { { '#', "#", "perform an extended command", - doextcmd, IFBURIED | GENERALCMD, NULL }, + doextcmd, IFBURIED | GENERALCMD | CMD_M_PREFIX, NULL }, { M('?'), "?", "list all extended commands", - doextlist, IFBURIED | AUTOCOMPLETE | GENERALCMD, NULL }, + doextlist, IFBURIED | AUTOCOMPLETE | GENERALCMD | CMD_M_PREFIX, NULL }, { M('a'), "adjust", "adjust inventory letters", doorganize, IFBURIED | AUTOCOMPLETE, NULL }, { M('A'), "annotate", "name current level", donamelevel, IFBURIED | AUTOCOMPLETE, NULL }, { 'a', "apply", "apply (use) a tool (pick-axe, key, lamp...)", - doapply, 0, NULL }, + doapply, CMD_M_PREFIX, NULL }, { C('x'), "attributes", "show your attributes", doattributes, IFBURIED, NULL }, { '@', "autopickup", "toggle the 'autopickup' option on/off", @@ -1884,7 +1884,7 @@ struct ext_func_tab extcmdlist[] = { { 'D', "droptype", "drop specific item types", doddrop, 0, NULL }, { 'e', "eat", "eat something", - doeat, 0, NULL }, + doeat, CMD_M_PREFIX, NULL }, { 'E', "engrave", "engrave writing on the floor", doengrave, 0, NULL }, { M('e'), "enhance", "advance or check weapon and spell skills", @@ -1916,9 +1916,9 @@ struct ext_func_tab extcmdlist[] = { { C('d'), "kick", "kick something", dokick, 0, NULL }, { '\\', "known", "show what object types have been discovered", - dodiscovered, IFBURIED | GENERALCMD, NULL }, + dodiscovered, IFBURIED | GENERALCMD | CMD_M_PREFIX, NULL }, { '`', "knownclass", "show discovered types for one class of objects", - doclassdisco, IFBURIED | GENERALCMD, NULL }, + doclassdisco, IFBURIED | GENERALCMD | CMD_M_PREFIX, NULL }, { '\0', "levelchange", "change experience level", wiz_level_change, IFBURIED | AUTOCOMPLETE | WIZMODECMD, NULL }, { '\0', "lightsources", "show mobile light sources", @@ -1926,7 +1926,7 @@ struct ext_func_tab extcmdlist[] = { { ':', "look", "look at what is here", dolook, IFBURIED, NULL }, { M('l'), "loot", "loot a box on the floor", - doloot, AUTOCOMPLETE, NULL }, + doloot, AUTOCOMPLETE | CMD_M_PREFIX, NULL }, #ifdef DEBUG_MIGRATING_MONS { '\0', "migratemons", "migrate N random monsters", wiz_migrate_mons, IFBURIED | AUTOCOMPLETE | WIZMODECMD, NULL }, @@ -1936,7 +1936,7 @@ struct ext_func_tab extcmdlist[] = { { 'N', "name", "same as call; name a monster or object or object type", docallcmd, IFBURIED | AUTOCOMPLETE, NULL }, { M('o'), "offer", "offer a sacrifice to the gods", - dosacrifice, AUTOCOMPLETE, NULL }, + dosacrifice, AUTOCOMPLETE | CMD_M_PREFIX, NULL }, { 'o', "open", "open a door", doopen, 0, NULL }, { 'O', "options", "show option settings, possibly change them", @@ -1953,7 +1953,7 @@ struct ext_func_tab extcmdlist[] = { { '|', "perminv", "scroll persistent inventory display", doperminv, IFBURIED | GENERALCMD | NOFUZZERCMD, NULL }, { ',', "pickup", "pick up things at the current location", - dopickup, 0, NULL }, + dopickup, CMD_M_PREFIX, NULL }, { '\0', "polyself", "polymorph self", wiz_polyself, IFBURIED | AUTOCOMPLETE | WIZMODECMD, NULL }, { M('p'), "pray", "pray to the gods for help", @@ -1984,7 +1984,7 @@ struct ext_func_tab extcmdlist[] = { { 'S', "save", "save the game and exit", dosave, IFBURIED | GENERALCMD | NOFUZZERCMD, NULL }, { 's', "search", "search for traps and secret doors", - dosearch, IFBURIED, "searching" }, + dosearch, IFBURIED | CMD_M_PREFIX, "searching" }, { '*', "seeall", "show all equipment in use", doprinuse, IFBURIED, NULL }, { AMULET_SYM, "seeamulet", "show the amulet currently worn", @@ -2027,7 +2027,7 @@ struct ext_func_tab extcmdlist[] = { { 'A', "takeoffall", "remove all armor", doddoremarm, 0, NULL }, { C('t'), "teleport", "teleport around the level", - dotelecmd, IFBURIED, NULL }, + dotelecmd, IFBURIED | CMD_M_PREFIX, NULL }, /* \177 == aka aka ; some terminals have an option to swap it with so if there's a key labeled it may or may not actually invoke the #terrain command */ @@ -2043,9 +2043,9 @@ struct ext_func_tab extcmdlist[] = { { '\0', "timeout", "look at timeout queue and hero's timed intrinsics", wiz_timeout_queue, IFBURIED | AUTOCOMPLETE | WIZMODECMD, NULL }, { M('T'), "tip", "empty a container", - dotip, AUTOCOMPLETE, NULL }, + dotip, AUTOCOMPLETE | CMD_M_PREFIX, NULL }, { '_', "travel", "travel to a specific location on the map", - dotravel, 0, NULL }, + dotravel, CMD_M_PREFIX, NULL }, { M('t'), "turn", "turn undead away", doturn, IFBURIED | AUTOCOMPLETE, NULL }, { 'X', "twoweapon", "toggle two-weapon combat", @@ -2064,7 +2064,7 @@ struct ext_func_tab extcmdlist[] = { { '\0', "vision", "show vision array", wiz_show_vision, IFBURIED | AUTOCOMPLETE | WIZMODECMD, NULL }, { '.', "wait", "rest one move while doing nothing", - donull, IFBURIED, "waiting" }, + donull, IFBURIED | CMD_M_PREFIX, "waiting" }, { 'W', "wear", "wear a piece of armor", dowear, 0, NULL }, { '&', "whatdoes", "tell what a command does", @@ -2093,7 +2093,7 @@ struct ext_func_tab extcmdlist[] = { { '\0', "wizintrinsic", "set an intrinsic", wiz_intrinsic, IFBURIED | AUTOCOMPLETE | WIZMODECMD, NULL }, { C('v'), "wizlevelport", "teleport to another level", - wiz_level_tele, IFBURIED | WIZMODECMD, NULL }, + wiz_level_tele, IFBURIED | WIZMODECMD | CMD_M_PREFIX, NULL }, { '\0', "wizloaddes", "load and execute a des-file lua script", wiz_load_splua, IFBURIED | WIZMODECMD | NOFUZZERCMD, NULL }, { '\0', "wizloadlua", "load and execute a lua script", @@ -3296,28 +3296,9 @@ reset_commands(boolean initial) /* non-movement commands which accept 'm' prefix to request menu operation */ static boolean -accept_menu_prefix(int (*cmd_func)(void)) +accept_menu_prefix(const struct ext_func_tab *ec) { - if (cmd_func == dopickup || cmd_func == dotip - /* eat, #offer, and apply tinning-kit all use floorfood() to pick - an item on floor or in invent; 'm' skips picking from floor - (ie, inventory only) rather than request use of menu operation */ - || cmd_func == doeat || cmd_func == dosacrifice || cmd_func == doapply - /* 'm' for removing saddle from adjacent monster without checking - for containers at */ - || cmd_func == doloot - /* offer menu to choose discoveries sort order */ - || cmd_func == dodiscovered || cmd_func == doclassdisco - /* travel: pop up a menu of interesting targets in view */ - || cmd_func == dotravel - /* wait and search: allow even if next to a hostile monster */ - || cmd_func == donull || cmd_func == dosearch - /* wizard mode ^V and ^T */ - || cmd_func == wiz_level_tele || cmd_func == dotelecmd - /* 'm' prefix allowed for some extended commands */ - || cmd_func == doextcmd || cmd_func == doextlist) - return TRUE; - return FALSE; + return (ec && ((ec->flags & CMD_M_PREFIX) != 0)); } char @@ -3551,7 +3532,7 @@ rhack(char *cmd) const struct ext_func_tab *ft = g.Cmd.commands[cmd[1] & 0xff]; int (*func)(void) = ft ? ((struct ext_func_tab *) ft)->ef_funct : 0; - if (func && accept_menu_prefix(func)) { + if (func && accept_menu_prefix(ft)) { iflags.menu_requested = TRUE; ++cmd; prefix_seen = FALSE;