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:
@@ -728,6 +728,7 @@ struct instance_globals {
|
|||||||
winid en_win;
|
winid en_win;
|
||||||
boolean en_via_menu;
|
boolean en_via_menu;
|
||||||
long last_command_count;
|
long last_command_count;
|
||||||
|
struct ext_func_tab *ext_tlist; /* info for rhack() from doextcmd() */
|
||||||
|
|
||||||
/* dbridge.c */
|
/* dbridge.c */
|
||||||
struct entity occupants[ENTITIES];
|
struct entity occupants[ENTITIES];
|
||||||
|
|||||||
10
src/cmd.c
10
src/cmd.c
@@ -391,6 +391,9 @@ doextcmd(void)
|
|||||||
extcmdlist[idx].ef_txt);
|
extcmdlist[idx].ef_txt);
|
||||||
iflags.menu_requested = FALSE;
|
iflags.menu_requested = FALSE;
|
||||||
}
|
}
|
||||||
|
/* tell rhack() what command is actually executing */
|
||||||
|
g.ext_tlist = &extcmdlist[idx];
|
||||||
|
|
||||||
retval = (*func)();
|
retval = (*func)();
|
||||||
} while (func == doextlist);
|
} while (func == doextlist);
|
||||||
|
|
||||||
@@ -3886,7 +3889,14 @@ rhack(char *cmd)
|
|||||||
func = ((struct ext_func_tab *) tlist)->ef_funct;
|
func = ((struct ext_func_tab *) tlist)->ef_funct;
|
||||||
if (tlist->f_text && !g.occupation && g.multi)
|
if (tlist->f_text && !g.occupation && g.multi)
|
||||||
set_occupation(func, tlist->f_text, g.multi);
|
set_occupation(func, tlist->f_text, g.multi);
|
||||||
|
g.ext_tlist = NULL;
|
||||||
res = (*func)(); /* perform the command */
|
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)) {
|
if ((tlist->flags & PREFIXCMD)) {
|
||||||
/* it was a prefix command, mark and get another cmd */
|
/* it was a prefix command, mark and get another cmd */
|
||||||
|
|||||||
@@ -231,6 +231,7 @@ const struct instance_globals g_init = {
|
|||||||
WIN_ERR, /* en_win */
|
WIN_ERR, /* en_win */
|
||||||
FALSE, /* en_via_menu */
|
FALSE, /* en_via_menu */
|
||||||
UNDEFINED_VALUE, /* last_command_count */
|
UNDEFINED_VALUE, /* last_command_count */
|
||||||
|
NULL, /* ext_tlist */
|
||||||
|
|
||||||
/* dbridge.c */
|
/* dbridge.c */
|
||||||
UNDEFINED_VALUES, /* occupants */
|
UNDEFINED_VALUES, /* occupants */
|
||||||
|
|||||||
Reference in New Issue
Block a user