more command prefix handling
When a command doesn't allow a prefix, go back to showing the prefix keystroke in the can't-do-that feedback rather than the command name that it has for potential binding. I went away from that earlier after typing 'G' followed by 'o' and getting "the open command does not accept 5 prefix" instead of "G prefix". Fix the lookup routine which was responsible for that. At least partially fix it; actually it only ignores digits for !numpad. If a numpad user types G where it isn't allowed, the feedback will still be about 5 instead of G. The code is going from keystroke-used to command-it-invokes back to keystroke-for-command which won't necessarily yield the original keystroke because a command can be bound to more than one key.
This commit is contained in:
@@ -2905,6 +2905,11 @@ cmd_from_func(int (*fn)(void))
|
|||||||
keystroke invokes space's command */
|
keystroke invokes space's command */
|
||||||
if (i == ' ')
|
if (i == ' ')
|
||||||
continue;
|
continue;
|
||||||
|
/* skip digits if number_pad is Off; also skip '-' unless it has
|
||||||
|
been bound to something other than what number_pad assigns */
|
||||||
|
if (((i >= '0' && i <= '9') || (i == '-' && fn == do_fight))
|
||||||
|
&& !g.Cmd.num_pad)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (g.Cmd.commands[i] && g.Cmd.commands[i]->ef_funct == fn)
|
if (g.Cmd.commands[i] && g.Cmd.commands[i]->ef_funct == fn)
|
||||||
return (char) i;
|
return (char) i;
|
||||||
@@ -3848,11 +3853,13 @@ rhack(char *cmd)
|
|||||||
&& !(tlist->flags & (PREFIXCMD | MOVEMENTCMD))
|
&& !(tlist->flags & (PREFIXCMD | MOVEMENTCMD))
|
||||||
&& (!was_m_prefix || !accept_menu_prefix(tlist))) {
|
&& (!was_m_prefix || !accept_menu_prefix(tlist))) {
|
||||||
const char *which;
|
const char *which;
|
||||||
|
char pfxidx = cmd_from_func(prefix_seen->ef_funct);
|
||||||
|
|
||||||
/* got prefix previously but this command doesn't accept one */
|
/* got prefix previously but this command doesn't accept one */
|
||||||
which = (prefix_seen->ef_funct == do_reqmenu)
|
which = (pfxidx != 0) ? visctrl(pfxidx)
|
||||||
? "move-no-pickup or request-menu"
|
: (prefix_seen->ef_funct == do_reqmenu)
|
||||||
: prefix_seen->ef_txt;
|
? "move-no-pickup or request-menu"
|
||||||
|
: prefix_seen->ef_txt;
|
||||||
pline("The %s command does not accept %s prefix.",
|
pline("The %s command does not accept %s prefix.",
|
||||||
tlist->ef_txt, which);
|
tlist->ef_txt, which);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user