]> granicus.if.org Git - nethack/commitdiff
fix #K3577 - F+dir followed by ^A moved dir
authorPatR <rankin@nethack.org>
Fri, 15 Apr 2022 01:59:23 +0000 (18:59 -0700)
committerPatR <rankin@nethack.org>
Fri, 15 Apr 2022 01:59:23 +0000 (18:59 -0700)
Reported by luxidream via the web contact form and also as github
issue #732: using the repeat command after F+direction would take a
step in direction if there was no target to fight.

The direction was being repeated without the F prefix.  It wasn't
specific to F; m+dir misbehaved too.  This fix seems to work but it
should be replaced with something more robust.

Fixes #732

doc/fixes3-7-0.txt
src/cmd.c

index cfa314fa156a93bf97d774cb65a70b4e291fc6c5..8ae631f61c8f6232816447ba9f1b3e4f3c4b0181 100644 (file)
@@ -1149,6 +1149,8 @@ sequencing confusion: picking an item when viewing inventory and picking an
 program would access freed memory if charging caused a ring to explode
 arriving on Valkyrie quest final level could produce impossible warning
        "mkstairs: placing stairs up on molten lava at <68,13>"
+if the repeat command was used after prefix+command, only the command part got
+       repeated
 
 curses: 'msg_window' option wasn't functional for curses unless the binary
        also included tty support
index b4b6064824aee9fb53622d5189b93c515912471a..1750584c096b971399270c8068f990e3b0e342bd 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -4261,10 +4261,10 @@ getdir(const char *s)
 }
 
 static void
-show_direction_keys(winid win, /* should specify a window which is
-                                * using a fixed-width font... */
-                    char centerchar, /* '.' or '@' or ' ' */
-                    boolean nodiag)
+show_direction_keys(
+    winid win, /* should specify a window which is using a fixed-width font */
+    char centerchar, /* '.' or '@' or ' ' */
+    boolean nodiag)
 {
     char buf[BUFSZ];
 
@@ -5159,12 +5159,16 @@ parse(void)
     } else if (g.in_doagain) {
         g.command_count = g.last_command_count;
     } else if (foo && foo == cmd_from_func(do_repeat)) {
-        // g.command_count will be set again when we
-        // re-enter with g.in_doagain set true
+        /* g.command_count will be set again when we
+           re-enter with g.in_doagain set true */
         g.command_count = g.last_command_count;
     } else {
+        uchar c = (g.shead > 0) ? (uchar) g.saveq[g.shead - 1] & 0xff : 0;
+
         g.last_command_count = g.command_count;
-        savech(0); /* reset input queue */
+        /* reset saveq unless it holds a prefix */
+        if (!c || (g.Cmd.commands[c]->flags & PREFIXCMD) == 0)
+            savech(0);
         savech((char) foo);
     }
 
@@ -5186,8 +5190,9 @@ parse(void)
    the return value so we should be safe using `void' unconditionally */
 /*ARGUSED*/
 void
-hangup(int sig_unused UNUSED)   /* called as signal() handler, so sent
-                                   at least one arg */
+hangup(
+    int sig_unused UNUSED)   /* called as signal() handler, so sent
+                              * at least one arg */
 {
     if (g.program_state.exiting)
         g.program_state.in_moveloop = 0;