]> granicus.if.org Git - nethack/commitdiff
Qt toolbar 'rest' button
authorPatR <rankin@nethack.org>
Tue, 13 Oct 2020 20:41:57 +0000 (13:41 -0700)
committerPatR <rankin@nethack.org>
Tue, 13 Oct 2020 20:41:57 +0000 (13:41 -0700)
An issue in the core made the "Zz" button in the Qt toolbar only
work if rest_on_space was enabled.  cmd_from_func() was returning
' ' instead of '.' for the keystroke to run the rest command.

doc/fixes37.0
src/cmd.c

index 0c1d1ea4df25c4414b4fd5576675638503bf04d7..3797a96b3ab7461d08458b488fbbc719f92db458 100644 (file)
@@ -1,4 +1,4 @@
-NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.326 $ $NHDT-Date: 1602355548 2020/10/10 18:45:48 $
+NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.327 $ $NHDT-Date: 1602621704 2020/10/13 20:41:44 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -439,6 +439,8 @@ Qt: implement --More-- prompt to support MSGTYPE=stop
 Qt: for menu search, don't require clicking on the search target popup before
        typing target string (was using typed letters to make menu selections
        if player didn't click on the popup first)
+Qt: rest ("Zz") button on the toolbar only worked when 'rest_on_space' was On
+       (core issue, not Qt's fault)
 Qt+QSX: fix control key
 Qt+OSX: rename menu entry "nethack->Preferences..." for invoking nethack's
        'O' command to "Game->Run-time options" and entry "Game->Qt settings"
index 19ae95498b440f40376676f7a1df74bb6a501258..b870f0d464d9623a1d2ce97efee50ce0adcaf381 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -1,4 +1,4 @@
-/* NetHack 3.7 cmd.c   $NHDT-Date: 1597069374 2020/08/10 14:22:54 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.422 $ */
+/* NetHack 3.7 cmd.c   $NHDT-Date: 1602621705 2020/10/13 20:41:45 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.423 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2013. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -2272,9 +2272,18 @@ int NDECL((*fn));
 {
     int i;
 
-    for (i = 0; i < 256; ++i)
+    /* skip NUL; allowing it would wreak havoc */
+    for (i = 1; i < 256; ++i) {
+        /* skip space; we'll use it below as last resort if no other
+           keystroke invokes space's command */
+        if (i == ' ')
+            continue;
+
         if (g.Cmd.commands[i] && g.Cmd.commands[i]->ef_funct == fn)
             return (char) i;
+    }
+    if (g.Cmd.commands[' '] && g.Cmd.commands[' ']->ef_funct == fn)
+        return ' ';
     return '\0';
 }