]> granicus.if.org Git - nethack/commitdiff
eating, drinking via #herecmdmenu
authorPatR <rankin@nethack.org>
Sat, 16 Apr 2022 22:32:41 +0000 (15:32 -0700)
committerPatR <rankin@nethack.org>
Sat, 16 Apr 2022 22:32:41 +0000 (15:32 -0700)
Fix eat floor food and drink from dungeon feature via #herecmdmenu.
That uses queued commands, but those two actions were changed to
skip the floor when queued input was present because asking about
floor items interfered with context-sensitive inventory item-actions.

I was misled by a comment that says it couldn't insert an m-prefix;
that was for treating the 'm' key as typed text rather than as a
command.  There's no problem with inserting a #reqmenu command which
is what 'm' is these days.  So item actions can force 'm' to skip the
floor and go directly to inventory, also the #eat and #quaff commands
don't have to alter their behavior when queued input is pending so
the #herecmdmenu usage for them gets fixed.

src/eat.c
src/invent.c
src/potion.c

index 3515fe6a3f0c57d9234c92bf074fefc657fde145..f03228ee21a0eb37739e4e2f4da95186e8ceaa9a 100644 (file)
--- a/src/eat.c
+++ b/src/eat.c
@@ -3437,9 +3437,8 @@ floorfood(
                       * floor food has been declined and inventory lacks
                       * any suitable items */
     /* if we can't touch floor objects then use invent food only;
-       same if 'm' prefix was used or we're executing an item action
-       for context-sensitive inventory */
-    if (iflags.menu_requested || cmdq_peek()
+       same when 'm' prefix is used--for #eat, it means "skip floor food" */
+    if (iflags.menu_requested
         || !can_reach_floor(TRUE) || (feeding && u.usteed)
         || (is_pool_or_lava(u.ux, u.uy)
             && (Wwalking || is_clinger(uptr) || (Flying && !Breathless))))
index 70a101a79024353ee12854b4f5a575e919f5f100..e108328fb184429522d904a24a3f512adb5a67ec 100644 (file)
@@ -2834,8 +2834,10 @@ itemactions(struct obj *otmp)
             cmdq_add_key(otmp->invlet);
             break;
         case IA_DIP_OBJ:
-            /*cmdq_add_ec(dodip);*/
-            /*cmdq_add_userinput();*/
+            /* #altdip instead of normal #dip - takes potion to dip into
+               first (the inventory item instigating this) and item to
+               be dipped second, also ignores floor features such as
+               fountain/sink so we don't need to force m-prefix here */
             cmdq_add_ec(dip_into);
             cmdq_add_key(otmp->invlet);
             break;
@@ -2844,7 +2846,9 @@ itemactions(struct obj *otmp)
             cmdq_add_key(otmp->invlet);
             break;
         case IA_EAT_OBJ:
-            /* FIXME: can't add this! cmdq_add_key('m');*/ /* m-prefix: eat, skip floor obj */
+            /* start with m-prefix; for #eat, it means ignore floor food
+               if present and eat food from invent */
+            cmdq_add_ec(do_reqmenu);
             cmdq_add_ec(doeat);
             cmdq_add_key(otmp->invlet);
             break;
@@ -2857,6 +2861,9 @@ itemactions(struct obj *otmp)
             cmdq_add_key(otmp->invlet);
             break;
         case IA_QUAFF_OBJ:
+            /* start with m-prefix; for #quaff, it means ignore fountain
+               or sink if present and drink a potion from invent */
+            cmdq_add_ec(do_reqmenu);
             cmdq_add_ec(dodrink);
             cmdq_add_key(otmp->invlet);
             break;
index 27ee711516f6084823eb16ff99e3666fb1bc8fba..049952baf24aca0cb95b7142093c7722b6fab038 100644 (file)
@@ -531,11 +531,9 @@ dodrink(void)
     drink_ok_extra = 0;
     /* preceding 'q'/#quaff with 'm' skips the possibility of drinking
        from fountains, sinks, and surrounding water plus the prompting
-       which those entail; if cmdq is non-empty, player has selected a
-       potion from inventory and then chosen action-item 'quaff' so
-       skip fountains,&c for that case too--the potion's inv letter is
-       queued up for next getobj() */
-    if (!iflags.menu_requested && !cmdq_peek()) {
+       which those entail; optional for interactive use, essential for
+       context-sensitive inventory item action 'quaff' */
+    if (!iflags.menu_requested) {
         /* Is there a fountain to drink from here? */
         if (IS_FOUNTAIN(levl[u.ux][u.uy].typ)
             /* not as low as floor level but similar restrictions apply */