]> granicus.if.org Git - nethack/commitdiff
another getobj/force_invmenu fix
authorPatR <rankin@nethack.org>
Sat, 20 Mar 2021 17:52:46 +0000 (10:52 -0700)
committerPatR <rankin@nethack.org>
Sat, 20 Mar 2021 17:52:46 +0000 (10:52 -0700)
For !force_invmenu when attempting a command that needs an object,
if inventory is completely empty
 What do you want to <foo>? [*]
will report "Never mind" and stop asking if player presses return
or report "Not carrying anything" and reprompt if player types '*'.
But for force_invmenu, it would report
 Not carrying anything.  Never mind.
without any reprompting in between the two messages.  Just skip
the second message in that situation.

Perhaps the first case should avoid reprompting too but I haven't
gone that far.

doc/fixes37.0
src/invent.c

index 126fba511bf5d964ac1a1bf2b456a54d1a4854b3..7583d74ae77cd3114dbd31835290dfe1822da61f 100644 (file)
@@ -553,6 +553,9 @@ engraving with non-blade dulled the weapon anyway (pr #464)
 loss of saddle by opening magic left hero mounted on unsaddled steed
 avoid segfault during error reporting for bad 'O' value(s) after theme rooms
        have been initialized, leaving iflags.in_lua set
+avoid complaints of "nothing to foo" for 'force_invmenu' if there are no
+       likely candidates to foo with but there are hidden acceptable choices
+avoid "Not carrying anything.  Never mind." for 'force_invmenu'
 
 curses: 'msg_window' option wasn't functional for curses unless the binary
        also included tty support
index 9f89996096dc21fc6d83874ec0b1295eb4d3d73c..5710fadc910f75a9be10969e85fa7b88abe25d8f 100644 (file)
@@ -1632,8 +1632,11 @@ getobj(const char *word,
             ilet = display_pickinv(allowed_choices, *qbuf ? qbuf : (char *) 0,
                                    menuquery,
                                    TRUE, allowcnt ? &ctmp : (long *) 0);
-            if (!ilet)
+            if (!ilet) {
+                if (oneloop)
+                    return (struct obj *) 0;
                 continue;
+            }
             if (ilet == HANDS_SYM)
                 return (struct obj *) &cg.zeroobj; /* cast away 'const' */
             if (ilet == '\033') {