]> granicus.if.org Git - nethack/commitdiff
venom fixes
authorPatR <rankin@nethack.org>
Thu, 1 Oct 2020 23:41:56 +0000 (16:41 -0700)
committerPatR <rankin@nethack.org>
Thu, 1 Oct 2020 23:41:56 +0000 (16:41 -0700)
Noticed when fixing 'D$'.  Some commands, including D, which should
have been handling venom weren't doing so.

I'm not sure whether I got all the applicable cases.

doc/fixes37.0
include/hack.h
src/do.c
src/invent.c
src/pickup.c

index 4f70d8dfafbbd36501cdeaf689b121fb779ed3ca..325db0d6b7ee9dbab081fe1796a98b71ad7bc336 100644 (file)
@@ -1,4 +1,4 @@
-NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.316 $ $NHDT-Date: 1601594180 2020/10/01 23:16:20 $
+NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.317 $ $NHDT-Date: 1601595709 2020/10/01 23:41:49 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -227,6 +227,9 @@ hero poly'd into a mind flayer who used #monster to emit a psychic blast was
        able to harm mindless monsters with it
 some hero attacks that should have gotten a skill bonus or penalty didn't
 change internal name of "<foo> venom" to "splash of <foo> venom"
+some operations that made sense to handle venom ('D', scroll of identify, no
+       doubt others) ignored it because venom is suppressed from packorder;
+       matters for wizard mode or for normal play that loads wizard bones
 singularize "splashes" to "splash" instead of "splashe"
 treat slinging gems and tossing or slinging stones at unicorns as attacks
 give rot-away timer instead of revive timer to corpses of cancelled trolls
index ae66209e622fdab5ba84d4c729c71959428976e8..9900d54263be8f12b700cf3de1b28ce80dcee278 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 hack.h  $NHDT-Date: 1596498538 2020/08/03 23:48:58 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.140 $ */
+/* NetHack 3.7 hack.h  $NHDT-Date: 1601595709 2020/10/01 23:41:49 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.141 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Pasi Kallinen, 2017. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -346,27 +346,29 @@ typedef struct sortloot_item Loot;
 #define ALL_FINISHED 0x01 /* called routine already finished the job */
 
 /* flags to control query_objlist() */
-#define BY_NEXTHERE     0x01   /* follow objlist by nexthere field */
-#define AUTOSELECT_SINGLE 0x02 /* if only 1 object, don't ask */
-#define USE_INVLET      0x04   /* use object's invlet */
-#define INVORDER_SORT   0x08   /* sort objects by packorder */
-#define SIGNAL_NOMENU   0x10   /* return -1 rather than 0 if none allowed */
-#define SIGNAL_ESCAPE   0x20   /* return -2 rather than 0 for ESC */
-#define FEEL_COCKATRICE 0x40   /* engage cockatrice checks and react */
-#define INCLUDE_HERO    0x80   /* show hero among engulfer's inventory */
+#define BY_NEXTHERE       0x0001 /* follow objlist by nexthere field */
+#define INCLUDE_VENOM     0x0002 /* include venom objects if present */
+#define AUTOSELECT_SINGLE 0x0004 /* if only 1 object, don't ask */
+#define USE_INVLET        0x0008 /* use object's invlet */
+#define INVORDER_SORT     0x0010 /* sort objects by packorder */
+#define SIGNAL_NOMENU     0x0020 /* return -1 rather than 0 if none allowed */
+#define SIGNAL_ESCAPE     0x0040 /* return -2 rather than 0 for ESC */
+#define FEEL_COCKATRICE   0x0080 /* engage cockatrice checks and react */
+#define INCLUDE_HERO      0x0100 /* show hero among engulfer's inventory */
 
 /* Flags to control query_category() */
-/* BY_NEXTHERE used by query_category() too, so skip 0x01 */
-#define UNPAID_TYPES 0x002
-#define GOLD_TYPES   0x004
-#define WORN_TYPES   0x008
-#define ALL_TYPES    0x010
-#define BILLED_TYPES 0x020
-#define CHOOSE_ALL   0x040
-#define BUC_BLESSED  0x080
-#define BUC_CURSED   0x100
-#define BUC_UNCURSED 0x200
-#define BUC_UNKNOWN  0x400
+/* BY_NEXTHERE and INCLUDE_VENOM are used by query_category() too, so
+   skip 0x0001 and 0x0002 */
+#define UNPAID_TYPES      0x0004
+#define GOLD_TYPES        0x0008
+#define WORN_TYPES        0x0010
+#define ALL_TYPES         0x0020
+#define BILLED_TYPES      0x0040
+#define CHOOSE_ALL        0x0080
+#define BUC_BLESSED       0x0100
+#define BUC_CURSED        0x0200
+#define BUC_UNCURSED      0x0400
+#define BUC_UNKNOWN       0x0800
 #define BUC_ALLBKNOWN (BUC_BLESSED | BUC_CURSED | BUC_UNCURSED)
 #define BUCX_TYPES (BUC_ALLBKNOWN | BUC_UNKNOWN)
 #define ALL_TYPES_SELECTED -2
index 580c701c094e15e35b80d9dc6fa60b7d4c347afc..6aaee14074f21f2bee2110ca7be82396a3da3d3e 100644 (file)
--- a/src/do.c
+++ b/src/do.c
@@ -1,4 +1,4 @@
-/* NetHack 3.7 do.c    $NHDT-Date: 1598575088 2020/08/28 00:38:08 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.248 $ */
+/* NetHack 3.7 do.c    $NHDT-Date: 1601595709 2020/10/01 23:41:49 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.249 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Derek S. Ray, 2015. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -845,8 +845,9 @@ int retry;
     } else if (flags.menu_style == MENU_FULL) {
         all_categories = FALSE;
         n = query_category("Drop what type of items?", g.invent,
-                           UNPAID_TYPES | ALL_TYPES | CHOOSE_ALL | BUC_BLESSED
-                               | BUC_CURSED | BUC_UNCURSED | BUC_UNKNOWN,
+                           (UNPAID_TYPES | ALL_TYPES | CHOOSE_ALL
+                            | BUC_BLESSED | BUC_CURSED | BUC_UNCURSED
+                            | BUC_UNKNOWN | INCLUDE_VENOM),
                            &pick_list, PICK_ANY);
         if (!n)
             goto drop_done;
@@ -897,7 +898,8 @@ int retry;
     } else {
         /* should coordinate with perm invent, maybe not show worn items */
         n = query_objlist("What would you like to drop?", &g.invent,
-                          (USE_INVLET | INVORDER_SORT), &pick_list, PICK_ANY,
+                          (USE_INVLET | INVORDER_SORT | INCLUDE_VENOM),
+                          &pick_list, PICK_ANY,
                           all_categories ? allow_all : allow_category);
         if (n > 0) {
             /*
index 126947f99322b6f69735628cbc0e9198fde101d4..eeb5404493a51c183e58ab4f88e9e551f8a78e87 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 invent.c        $NHDT-Date: 1601594180 2020/10/01 23:16:20 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.301 $ */
+/* NetHack 3.7 invent.c        $NHDT-Date: 1601595710 2020/10/01 23:41:50 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.302 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Derek S. Ray, 2015. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -2116,11 +2116,11 @@ unsigned *resultflags;
             m_seen = TRUE;
         } else if (oc_of_sym == MAXOCLASSES) {
             You("don't have any %c's.", sym);
-        } else if (oc_of_sym != VENOM_CLASS) { /* suppress venom */
+        } else {
             if (!index(olets, oc_of_sym)) {
                 add_valid_menu_class(oc_of_sym);
                 olets[oletct++] = oc_of_sym;
-                olets[oletct] = 0;
+                olets[oletct] = '\0';
             }
         }
     }
@@ -2360,7 +2360,7 @@ int id_limit;
         Sprintf(buf, "What would you like to identify %s?",
                 first ? "first" : "next");
         n = query_objlist(buf, &g.invent, (SIGNAL_NOMENU | SIGNAL_ESCAPE
-                                         | USE_INVLET | INVORDER_SORT),
+                                           | USE_INVLET | INVORDER_SORT),
                           &pick_list, PICK_ANY, not_fully_identified);
 
         if (n > 0) {
@@ -3217,6 +3217,7 @@ dotypeinv()
                 i |= BUC_CURSED;
             if (xcnt)
                 i |= BUC_UNKNOWN;
+            i |= INCLUDE_VENOM;
             n = query_category(prompt, g.invent, i, &pick_list, PICK_ONE);
             if (!n)
                 return 0;
@@ -3341,7 +3342,7 @@ dotypeinv()
     }
     if (query_objlist((char *) 0, &g.invent,
                       ((flags.invlet_constant ? USE_INVLET : 0)
-                       | INVORDER_SORT),
+                       | INVORDER_SORT | INCLUDE_VENOM),
                       &pick_list, PICK_NONE, this_type_only) > 0)
         free((genericptr_t) pick_list);
     return 0;
index ad6644dfbbff7917321926e0f130160ff29e0f96..ddabf097c111a99f2e8360dbc41532911bf4ec9f 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 pickup.c        $NHDT-Date: 1596498195 2020/08/03 23:43:15 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.271 $ */
+/* NetHack 3.7 pickup.c        $NHDT-Date: 1601595711 2020/10/01 23:41:51 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.272 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2012. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -910,7 +910,7 @@ boolean FDECL((*allow), (OBJ_P)); /* allow function */
     int i, n;
     winid win;
     struct obj *curr, *last, fake_hero_object, *olist = *olist_p;
-    char *pack;
+    char *pack, packbuf[MAXOCLASSES + 1];
     anything any;
     boolean printed_type_name, first,
             sorted = (qflags & INVORDER_SORT) != 0,
@@ -970,7 +970,9 @@ boolean FDECL((*allow), (OBJ_P)); /* allow function */
      * each type so we can group them.  The allow function was
      * called by sortloot() and will be called once per item here.
      */
-    pack = flags.inv_order;
+    pack = strcpy(packbuf, flags.inv_order);
+    if (qflags & INCLUDE_VENOM)
+        (void) strkitten(pack, VENOM_CLASS); /* venom is not in inv_order */
     first = TRUE;
     do {
         printed_type_name = FALSE;
@@ -1095,7 +1097,7 @@ int how;               /* type of query */
     int n;
     winid win;
     struct obj *curr;
-    char *pack;
+    char *pack, packbuf[MAXOCLASSES + 1];
     anything any;
     boolean collected_type_name;
     char invlet;
@@ -1154,7 +1156,10 @@ int how;               /* type of query */
 
     win = create_nhwindow(NHW_MENU);
     start_menu(win, MENU_BEHAVE_STANDARD);
-    pack = flags.inv_order;
+
+    pack = strcpy(packbuf, flags.inv_order);
+    if (qflags & INCLUDE_VENOM)
+        (void) strkitten(pack, VENOM_CLASS); /* venom is not in inv_order */
 
     if (qflags & CHOOSE_ALL) {
         invlet = 'A';
@@ -2990,13 +2995,14 @@ boolean put_in;
             }
         }
     } else {
-        mflags = INVORDER_SORT;
+        mflags = INVORDER_SORT | INCLUDE_VENOM;
         if (put_in && flags.invlet_constant)
             mflags |= USE_INVLET;
         if (!put_in)
             g.current_container->cknown = 1;
         Sprintf(buf, "%s what?", action);
-        n = query_objlist(buf, put_in ? &g.invent : &(g.current_container->cobj),
+        n = query_objlist(buf,
+                          put_in ? &g.invent : &(g.current_container->cobj),
                           mflags, &pick_list, PICK_ANY,
                           all_categories ? allow_all : allow_category);
         if (n) {