using prefixes via their extended command names

Trying to use #reqmenu/#rush/#run/#fight prefixes by their extended
command names didn't work because rhack()'s post-processing was stuck
dealing with the entry for the '#' key after using doextcmd() to run
any command.  Use a static variable (actually a global one since I put
it into struct g) to notify rhack() of the command that ultimately got
executed.
This commit is contained in:
PatR
2022-02-07 16:53:56 -08:00
parent 50d8463b71
commit a0100dd300
3 changed files with 12 additions and 0 deletions

View File

@@ -728,6 +728,7 @@ struct instance_globals {
winid en_win;
boolean en_via_menu;
long last_command_count;
struct ext_func_tab *ext_tlist; /* info for rhack() from doextcmd() */
/* dbridge.c */
struct entity occupants[ENTITIES];

View File

@@ -391,6 +391,9 @@ doextcmd(void)
extcmdlist[idx].ef_txt);
iflags.menu_requested = FALSE;
}
/* tell rhack() what command is actually executing */
g.ext_tlist = &extcmdlist[idx];
retval = (*func)();
} while (func == doextlist);
@@ -3886,7 +3889,14 @@ rhack(char *cmd)
func = ((struct ext_func_tab *) tlist)->ef_funct;
if (tlist->f_text && !g.occupation && g.multi)
set_occupation(func, tlist->f_text, g.multi);
g.ext_tlist = NULL;
res = (*func)(); /* perform the command */
/* if 'func' is doextcmd(), 'tlist' is for Cmd.commands['#']
rather than for the command that doextcmd() just ran;
doextcmd() notifies us what that was via ext_tlist;
other commands leave it Null */
if (g.ext_tlist)
tlist = g.ext_tlist;
if ((tlist->flags & PREFIXCMD)) {
/* it was a prefix command, mark and get another cmd */

View File

@@ -231,6 +231,7 @@ const struct instance_globals g_init = {
WIN_ERR, /* en_win */
FALSE, /* en_via_menu */
UNDEFINED_VALUE, /* last_command_count */
NULL, /* ext_tlist */
/* dbridge.c */
UNDEFINED_VALUES, /* occupants */