From: PatR Date: Thu, 1 Oct 2020 23:41:56 +0000 (-0700) Subject: venom fixes X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9045ccb63d23e0e575fbf5fff706e0d6d74abb39;p=nethack venom fixes 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. --- diff --git a/doc/fixes37.0 b/doc/fixes37.0 index 4f70d8dfa..325db0d6b 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -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 " venom" to "splash of 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 diff --git a/include/hack.h b/include/hack.h index ae66209e6..9900d5426 100644 --- a/include/hack.h +++ b/include/hack.h @@ -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 diff --git a/src/do.c b/src/do.c index 580c701c0..6aaee1407 100644 --- 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) { /* diff --git a/src/invent.c b/src/invent.c index 126947f99..eeb540449 100644 --- a/src/invent.c +++ b/src/invent.c @@ -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; diff --git a/src/pickup.c b/src/pickup.c index ad6644dfb..ddabf097c 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -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) {