From: PatR Date: Fri, 15 Apr 2022 01:59:23 +0000 (-0700) Subject: fix #K3577 - F+dir followed by ^A moved dir X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=da35dfe48e7f902dc8ed74dcf279cde394acf1aa;p=nethack fix #K3577 - F+dir followed by ^A moved dir 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 --- diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index cfa314fa1..8ae631f61 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -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 diff --git a/src/cmd.c b/src/cmd.c index b4b606482..1750584c0 100644 --- 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;