]> granicus.if.org Git - nethack/commitdiff
Fix: off-by-one error in movecmd
authorMichael Meyer <me@entrez.cc>
Wed, 21 Jul 2021 16:18:40 +0000 (12:18 -0400)
committerPasi Kallinen <paxed@alt.org>
Wed, 21 Jul 2021 19:43:46 +0000 (22:43 +0300)
The for loop which iterates through the list of movement keys in
movecmd(cmd.c) was updated in 5abf948116 to count down to 0 instead of
up to the end of the list.  This commit inadvertently introduced an
off-by-one error which started the loop one past the actual end of the
array.  On my system this made 'H' stop working as the 'run West' key.

src/cmd.c

index 7d1185f9cf40b242ff02a54abdafc28759c974d2..ad03bff665417a12c17b1c58f140265c332a35ca 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -3693,7 +3693,7 @@ movecmd(char sym, int mode)
         char *mvkeys = (mode == MV_WALK) ? g.Cmd.move :
             ((mode == MV_RUN) ? g.Cmd.run : g.Cmd.rush);
 
-        for (d = N_DIRS; d > DIR_ERR; d--) {
+        for (d = N_DIRS - 1; d > DIR_ERR; d--) {
             if (mode == MV_ANY) {
                 if (sym == g.Cmd.move[d]
                     || sym == g.Cmd.rush[d]