From: Michael Meyer Date: Wed, 21 Jul 2021 16:18:40 +0000 (-0400) Subject: Fix: off-by-one error in movecmd X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e8cb683ad03ae98c3e648dfc99e0b253f1d5f7e0;p=nethack Fix: off-by-one error in movecmd 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. --- diff --git a/src/cmd.c b/src/cmd.c index 7d1185f9c..ad03bff66 100644 --- 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]