]> granicus.if.org Git - nethack/commitdiff
menu handling for ':' when hero is swallowed
authorPatR <rankin@nethack.org>
Tue, 19 Apr 2016 01:15:58 +0000 (18:15 -0700)
committerPatR <rankin@nethack.org>
Tue, 19 Apr 2016 01:15:58 +0000 (18:15 -0700)
Force the menu for the look-here command when 'here' is the inside
of an engulfer to be PICK_NONE.  That way '>' won't exit the menu
by choosing the extra inventory item "> - hero".

include/monst.h
include/wintype.h
src/invent.c
src/zap.c

index 171b840a26894eb948cb7537c8dfa9624aa95ee0..d918897de7f95c1cccfe62b8b432ee0f794342b5 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 monst.h $NHDT-Date: 1457995142 2016/03/14 22:39:02 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.23 $ */
+/* NetHack 3.6 monst.h $NHDT-Date: 1461028522 2016/04/19 01:15:22 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.24 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
 /* The following flags are used for the second argument to display_minventory
  * in invent.c:
  *
+ * PICK_NONE, PICK_ONE, PICK_ANY (wintype.h)  0, 1, 2
  * MINV_NOLET  If set, don't display inventory letters on monster's inventory.
  * MINV_ALL    If set, display all items in monster's inventory, otherwise
  *            just display wielded weapons and worn items.
  */
-#define MINV_NOLET 0x01
-#define MINV_ALL   0x02
+#define MINV_PICKMASK 0x03 /* 1|2 */
+#define MINV_NOLET    0x04
+#define MINV_ALL      0x08
 
 struct monst {
     struct monst *nmon;
index 960f652746cd645094f08011a5803d4448803478..e15e6725e60d35e45b4fdd2b5ede8ba0c718e6af 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6  wintype.h       $NHDT-Date: 1433207914 2015/06/02 01:18:34 $  $NHDT-Branch: master $:$NHDT-Revision: 1.15 $ */
+/* NetHack 3.6  wintype.h       $NHDT-Date: 1461028538 2016/04/19 01:15:38 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.16 $ */
 /* Copyright (c) David Cohrs, 1991                                */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -56,6 +56,7 @@ typedef struct mi {
 #define MENU_ITEM_P struct mi
 
 /* select_menu() "how" argument types */
+/* [MINV_PICKMASK in monst.h assumes these have values of 0, 1, 2] */
 #define PICK_NONE 0 /* user picks nothing (display only) */
 #define PICK_ONE 1  /* only pick one */
 #define PICK_ANY 2  /* can pick any amount */
index 6219f833036bac310fa106e433cd382a4bdaac5f..49fdb3c1a6f5a22ddb73b80bb93a881e6d255b36 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 invent.c        $NHDT-Date: 1457994703 2016/03/14 22:31:43 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.199 $ */
+/* NetHack 3.6 invent.c        $NHDT-Date: 1461028538 2016/04/19 01:15:38 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.204 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -2867,7 +2867,7 @@ boolean picked_some;
             if (Blind)
                 Strcpy(fbuf, "You feel");
             Strcat(fbuf, ":");
-            (void) display_minventory(mtmp, MINV_ALL, fbuf);
+            (void) display_minventory(mtmp, MINV_ALL | PICK_NONE, fbuf);
         } else {
             You("%s no objects here.", verb);
         }
@@ -3709,8 +3709,10 @@ struct obj *obj;
  * By default, only worn and wielded items are displayed.  The caller
  * can pick one.  Modifier flags are:
  *
- *      MINV_NOLET      - nothing selectable
- *      MINV_ALL        - display all inventory
+ *      PICK_NONE, PICK_ONE - standard menu control
+ *      PICK_ANY            - allowed, but we only return a single object
+ *      MINV_NOLET          - nothing selectable
+ *      MINV_ALL            - display all inventory
  */
 struct obj *
 display_minventory(mon, dflags, title)
@@ -3724,7 +3726,8 @@ char *title;
     menu_item *selected = 0;
     int do_all = (dflags & MINV_ALL) != 0,
         incl_hero = (do_all && u.uswallow && mon == u.ustuck),
-        have_inv = (mon->minvent != 0), have_any = (have_inv || incl_hero);
+        have_inv = (mon->minvent != 0), have_any = (have_inv || incl_hero),
+        pickings = (dflags & MINV_PICKMASK);
 
     Sprintf(tmp, "%s %s:", s_suffix(noit_Monnam(mon)),
             do_all ? "possessions" : "armament");
@@ -3737,10 +3740,8 @@ char *title;
 
         n = query_objlist(title ? title : tmp, &(mon->minvent),
                           (INVORDER_SORT | (incl_hero ? INCLUDE_HERO : 0)),
-                          &selected,
-                          (dflags & MINV_NOLET) ? PICK_NONE : PICK_ONE,
+                          &selected, pickings,
                           do_all ? allow_all : worn_wield_only);
-
         set_uasmon();
     } else {
         invdisp_nothing(title ? title : tmp, "(none)");
index daa4d5ec6564d84bb8dbef0c7b30c4d474db9677..21d683e487e6a256e421919e89b4591d4c415546 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -1,4 +1,4 @@
-/* NetHack 3.6 zap.c   $NHDT-Date: 1457570259 2016/03/10 00:37:39 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.249 $ */
+/* NetHack 3.6 zap.c   $NHDT-Date: 1461028544 2016/04/19 01:15:44 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.251 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -466,7 +466,8 @@ struct monst *mtmp;
                     otmp->cknown = 1;
             }
         }
-        (void) display_minventory(mtmp, MINV_ALL | MINV_NOLET, (char *) 0);
+        (void) display_minventory(mtmp, MINV_ALL | MINV_NOLET | PICK_NONE,
+                                  (char *) 0);
     } else {
         pline("%s is not carrying anything%s.", noit_Monnam(mtmp),
               (u.uswallow && mtmp == u.ustuck) ? " besides you" : "");