]> granicus.if.org Git - nethack/commitdiff
fix #H1662 - temporary vs permanent sleepiness (trunk only)
authornethack.rankin <nethack.rankin>
Mon, 26 May 2008 05:46:21 +0000 (05:46 +0000)
committernethack.rankin <nethack.rankin>
Mon, 26 May 2008 05:46:21 +0000 (05:46 +0000)
     From a bug report, wearing
(or removing) an amulet of restful sleep was overriding permanent
sleepiness which had been obtained previously via eating another amulet.
The setting of timeout clobbered the non-timeout bits for that intrinsic.

     This also adds the timeout counter for sleepiness to enlightenment
feedback in wizard mode.  Unrelated:  rephrase enlightenment feedback for
adornment to more accurately describe what that does.

doc/fixes35.0
src/cmd.c
src/do_wear.c

index 6f012fffa2f11b3289c17764ccf9019ae489979c..9b6e034b4296cb2244a84d10a7efef49088fb0b4 100644 (file)
@@ -285,6 +285,7 @@ seen eels who were stuck in isolated pools would never re-hide
 can no longer get both strength and resistance from eating one giant corpse
 aborting key/lock pick usage via ESC at direction prompt no longer use a move
 when probing from inside an engulfer, "not carrying anything" overlooked hero
+wearing or removing an amulet of restful sleep clobbered permanent sleepiness
 
 
 Platform- and/or Interface-Specific Fixes
index b8bdf286eb987004e9959df1b08e6f13b8ce3a34..a1499ccaf18278e568d5bbdb4bc9ecb763d87923 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)cmd.c      3.5     2008/02/12      */
+/*     SCCS Id: @(#)cmd.c      3.5     2008/05/25      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1525,9 +1525,13 @@ int final;
                enl_msg(You_, "fumble", "fumbled", "", from_what(FUMBLING));
        }
        if (Sleeping) {
-           if (magic || cause_known(SLEEPING))
-               enl_msg("You ", "fall", "fell", " asleep uncontrollably",
-                       from_what(SLEEPING));
+           if (magic || cause_known(SLEEPING)) {
+               Strcpy(buf, from_what(SLEEPING));
+#ifdef WIZARD
+               if (wizard) Sprintf(eos(buf), " (%ld)", (HSleeping & TIMEOUT));
+#endif
+               enl_msg("You ", "fall", "fell", " asleep uncontrollably", buf);
+           }
        }
        /* hunger/nutrition */
        if (Hunger) {
@@ -1687,12 +1691,14 @@ int final;
        if (Adornment) {
            int adorn = 0;
 
-           if(uleft && uleft->otyp == RIN_ADORNMENT) adorn += uleft->spe;
-           if(uright && uright->otyp == RIN_ADORNMENT) adorn += uright->spe;
-           if (adorn < 0)
-               you_are("poorly adorned","");
-           else
-               you_are("adorned","");
+           if (uleft && uleft->otyp == RIN_ADORNMENT) adorn += uleft->spe;
+           if (uright && uright->otyp == RIN_ADORNMENT) adorn += uright->spe;
+           /* the sum might be 0 (+0 ring or two which negate each other);
+              that yields "you are charismatic" (which isn't pointless
+              because it potentially impacts seduction attacks) */
+           Sprintf(buf, "%scharismatic",
+                   (adorn > 0) ? "more " : (adorn < 0) ? "less " : "");
+           you_are(buf, from_what(ADORNED));
        }
        if (Invisible) you_are("invisible",from_what(INVIS));
        else if (Invis) you_are("invisible to others",from_what(INVIS));
index ba5027931e61a9ffac8dfebd1e980d8829e6eda5..b0829ad112d2cf4f2723747e66da52de4ce900af 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)do_wear.c  3.5     2008/01/23      */
+/*     SCCS Id: @(#)do_wear.c  3.5     2008/05/25      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -641,7 +641,14 @@ Amulet_on()
                }
                break;
        case AMULET_OF_RESTFUL_SLEEP:
-               HSleeping = rnd(100);
+           {
+               long newnap = (long)rnd(100), oldnap = (HSleeping & TIMEOUT);
+
+               /* avoid clobbering FROMOUTSIDE bit, which might have
+                  gotten set by previously eating one of these amulets */
+               if (newnap < oldnap || oldnap == 0L)
+                   HSleeping = (HSleeping & ~TIMEOUT) | newnap;
+           }
                break;
        case AMULET_OF_YENDOR:
                break;
@@ -690,8 +697,9 @@ Amulet_off()
                break;
        case AMULET_OF_RESTFUL_SLEEP:
                setworn((struct obj *)0, W_AMUL);
-               if (!ESleeping)
-                       HSleeping = 0;
+               /* HSleeping = 0L; -- avoid clobbering FROMOUTSIDE bit */
+               if (!ESleeping && !(HSleeping & ~TIMEOUT))
+                   HSleeping &= ~TIMEOUT;      /* clear timeout bits */
                return;
        case AMULET_OF_YENDOR:
                break;