fix github issue #426 - binding special commands

Binding 'repeat' (DOAGAIN, or redo) to a different key than ^A
didn't work as intended because the code that used it was
checking for DOAGAIN (a key value from config.h) instead of
g.Cmd.spkeys[NHKF_DOAGAIN] (the key currently bound to repeat).

Contrary to the github issue, re-bound prefix keys worked ok for
me if followed by a direction.  However, they behaved strangely
if followed by anything else.  If the keystroke was stolen from
some other command and that command hadn't been bound to another
key, following the prefix with a non-direction could end up
executing the command that used to own the key.  For example,
 BIND=d:nopickup
to use 'd' to move without auto-pickup would work if you used
d<direction> but if you used d<something-else> if would execute
the drop command.

The NHKF_REQMENU prefix could be bound to some key other than
'm' but it only worked as intended if the new key was a movement
prefix.

This also makes DOAGAIN be unconditional.  If it is deleted or
commented out in config.h, the default binding will be '\000' so
unusable (freeing up ^A for something), but still be available
to be bound to some key (perhaps even ^A).

This also includes an unrelated change to mdlib.c.  The comments
added to config.h will force a full rebuild.  Changing mdlib.c
now rather than separately will avoid forcing that twice.

Fixes #426
This commit is contained in:
PatR
2020-12-25 13:57:05 -08:00
parent 1a2afd21d4
commit 0ec355bdb4
5 changed files with 75 additions and 28 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 config.h $NHDT-Date: 1596498529 2020/08/03 23:48:49 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.143 $ */
/* NetHack 3.7 config.h $NHDT-Date: 1608933417 2020/12/25 21:56:57 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.146 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2016. */
/* NetHack may be freely redistributed. See license for details. */
@@ -482,7 +482,12 @@ typedef unsigned char uchar;
#endif
#endif
#define DOAGAIN '\001' /* ^A, the "redo" key used in cmd.c and getline.c */
/* The "repeat" key used in cmd.c as NHKF_DOAGAIN; if commented out or the
* value is changed from C('A') to 0, it won't be bound to any keystroke
* unless you use the run-time configuration file's BIND directive for it.
* [Note: C() macro isn't defined yet but it will be before DOAGAIN is used.]
*/
#define DOAGAIN C('A') /* repeat previous command; default is ^A, '\001' */
/* CONFIG_ERROR_SECURE: If user makes NETHACKOPTIONS point to a file ...
* TRUE: Show the first error, nothing else.