From 656963118035fe4996f7b9f59aa5b21aaf234938 Mon Sep 17 00:00:00 2001 From: PatR Date: Wed, 18 Sep 2019 11:37:11 -0700 Subject: [PATCH 1/2] fix github issue 221 - unfixable troubles Fixes #221 Routine unfixeable_trouble_count() is used for both applying a unicorn horn (possibly internally via #monster if poly'd into a unicorn) and drinking a blessed potion of restore ability. For the latter case, it always gave the wrong answer (unless the hero happened to be all of Sick and Stunned and Confused and Hallucinating and Vomiting and Deaf). Since the actual count wasn't used to decide whether hero felt "great" or just "good", having any of those conditions would hide the problem. --- doc/fixes36.3 | 4 +++- include/youprop.h | 6 +++--- src/apply.c | 29 +++++++++++++++++++---------- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/doc/fixes36.3 b/doc/fixes36.3 index 6959edf19..c87d9022d 100644 --- a/doc/fixes36.3 +++ b/doc/fixes36.3 @@ -1,4 +1,4 @@ -$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.112 $ $NHDT-Date: 1568509226 2019/09/15 01:00:26 $ +$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.113 $ $NHDT-Date: 1568831820 2019/09/18 18:37:00 $ This fixes36.3 file is here to capture information about updates in the 3.6.x lineage following the release of 3.6.2 in May 2019. Please note, however, @@ -139,6 +139,8 @@ when spellcasting monster aimed at wrong spot due to not being able to see prevent impossible when guard tries to relocate a monster on a full level hallucination provides partial protection from passive gaze counterattack against hero's attack; check for that before checking for free action +feedback from blessed potion of restore ability never reported "you feel great" + due to bad logic for not-unihorn case in unfixable_trouble_count() Fixes to Post-3.6.2 Problems that Were Exposed Via git Repository diff --git a/include/youprop.h b/include/youprop.h index c0eb10eef..c9656aacf 100644 --- a/include/youprop.h +++ b/include/youprop.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 youprop.h $NHDT-Date: 1433291407 2015/06/03 00:30:07 $ $NHDT-Branch: master $:$NHDT-Revision: 1.23 $ */ +/* NetHack 3.6 youprop.h $NHDT-Date: 1568831820 2019/09/18 18:37:00 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.27 $ */ /* Copyright (c) 1989 Mike Threepoint */ /* NetHack may be freely redistributed. See license for details. */ @@ -75,8 +75,8 @@ /* Pseudo-property */ #define Punished (uball != 0) -/* Those implemented solely as timeouts (we use just intrinsic) */ -#define HStun u.uprops[STUNNED].intrinsic +/* Many are implemented solely as timeouts (we use just intrinsic) */ +#define HStun u.uprops[STUNNED].intrinsic /* timed or FROMFORM */ #define Stunned HStun #define HConfusion u.uprops[CONFUSION].intrinsic diff --git a/src/apply.c b/src/apply.c index 5bc67850a..cf1232bb5 100644 --- a/src/apply.c +++ b/src/apply.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 apply.c $NHDT-Date: 1559670602 2019/06/04 17:50:02 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.274 $ */ +/* NetHack 3.6 apply.c $NHDT-Date: 1568831822 2019/09/18 18:37:02 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.276 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -3738,25 +3738,34 @@ boolean is_horn; if (Stoned) unfixable_trbl++; + if (Slimed) + unfixable_trbl++; if (Strangled) unfixable_trbl++; if (Wounded_legs && !u.usteed) unfixable_trbl++; - if (Slimed) - unfixable_trbl++; - /* lycanthropy is undesirable, but it doesn't actually make you feel bad */ + /* lycanthropy is undesirable, but it doesn't actually make you feel bad + so don't count it as a trouble which can't be fixed */ - if (!is_horn || (Confusion & ~TIMEOUT)) + /* + * Unicorn horn can fix these when they're timed but not when + * they aren't. Potion of restore ability doesn't touch them, + * so they're always unfixable for the not-unihorn case. + * [Most of these are timed only, so always curable via horn. + * An exception is Stunned, which can be forced On by certain + * polymorph forms (stalker, bats).] + */ + if (Sick && (!is_horn || (Sick & ~TIMEOUT) != 0L)) unfixable_trbl++; - if (!is_horn || (Sick & ~TIMEOUT)) + if (Stunned && (!is_horn || (HStun & ~TIMEOUT) != 0L)) unfixable_trbl++; - if (!is_horn || (HHallucination & ~TIMEOUT)) + if (Confusion && (!is_horn || (HConfusion & ~TIMEOUT) != 0L)) unfixable_trbl++; - if (!is_horn || (Vomiting & ~TIMEOUT)) + if (Hallucination && (!is_horn || (HHallucination & ~TIMEOUT) != 0L)) unfixable_trbl++; - if (!is_horn || (HStun & ~TIMEOUT)) + if (Vomiting && (!is_horn || (Vomiting & ~TIMEOUT) != 0L)) unfixable_trbl++; - if (!is_horn || (HDeaf & ~TIMEOUT)) + if (Deaf && (!is_horn || (HDeaf & ~TIMEOUT) != 0L)) unfixable_trbl++; return unfixable_trbl; From b1154399f16b7619320f65b54eb094a2b486bd3f Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 19 Sep 2019 12:48:41 -0700 Subject: [PATCH 2/2] fix github issue 223 - rubbing ring on touchstone Fixes #223 The touchstone code treated all rings as if they had gemstones, but quite a few don't and feedback could be unexpected. Cited case was an iron ring yielding a cyan (hi_metal) streak instead of the normal iron result ("scritch, scritch"). A gold ring yielded a yellow streak rather than a golden scratch. I didn't test silver ring but suspect it yielded a silver streak rather than a silvery scratch. This changes touchstones to treat non-gemstone rings like other classes of objects instead of like gems. I made mineral rings keep acting like gemstone rings--I'm not sure whether that's right. --- doc/fixes36.3 | 6 +++++- src/apply.c | 18 +++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/doc/fixes36.3 b/doc/fixes36.3 index c87d9022d..2d045e8aa 100644 --- a/doc/fixes36.3 +++ b/doc/fixes36.3 @@ -1,4 +1,4 @@ -$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.113 $ $NHDT-Date: 1568831820 2019/09/18 18:37:00 $ +$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.114 $ $NHDT-Date: 1568922510 2019/09/19 19:48:30 $ This fixes36.3 file is here to capture information about updates in the 3.6.x lineage following the release of 3.6.2 in May 2019. Please note, however, @@ -141,6 +141,10 @@ hallucination provides partial protection from passive gaze counterattack against hero's attack; check for that before checking for free action feedback from blessed potion of restore ability never reported "you feel great" due to bad logic for not-unihorn case in unfixable_trouble_count() +when rubbing a ring on a touchstone, all types of rings were treated as if + they were gems; an iron ring made a cyan streak instead of yielding + "scritch, scritch" and a gold ring made a yellow streak rather than + a golden scratch Fixes to Post-3.6.2 Problems that Were Exposed Via git Repository diff --git a/src/apply.c b/src/apply.c index cf1232bb5..11bd09d03 100644 --- a/src/apply.c +++ b/src/apply.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 apply.c $NHDT-Date: 1568831822 2019/09/18 18:37:02 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.276 $ */ +/* NetHack 3.6 apply.c $NHDT-Date: 1568922511 2019/09/19 19:48:31 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.277 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2317,13 +2317,14 @@ STATIC_OVL void use_stone(tstone) struct obj *tstone; { + static const char scritch[] = "\"scritch, scritch\""; + static const char allowall[3] = { COIN_CLASS, ALL_CLASSES, 0 }; + static const char coins_gems[3] = { COIN_CLASS, GEM_CLASS, 0 }; struct obj *obj; boolean do_scratch; const char *streak_color, *choices; char stonebuf[QBUFSZ]; - static const char scritch[] = "\"scritch, scritch\""; - static const char allowall[3] = { COIN_CLASS, ALL_CLASSES, 0 }; - static const char coins_gems[3] = { COIN_CLASS, GEM_CLASS, 0 }; + int oclass; /* in case it was acquired while blinded */ if (!Blind) @@ -2368,7 +2369,14 @@ struct obj *tstone; do_scratch = FALSE; streak_color = 0; - switch (obj->oclass) { + oclass = obj->oclass; + /* prevent non-gemstone rings from being treated like gems */ + if (oclass == RING_CLASS + && objects[obj->otyp].oc_material != GEMSTONE + && objects[obj->otyp].oc_material != MINERAL) + oclass = RANDOM_CLASS; /* something that's neither gem nor ring */ + + switch (oclass) { case GEM_CLASS: /* these have class-specific handling below */ case RING_CLASS: if (tstone->otyp != TOUCHSTONE) {