]> granicus.if.org Git - nethack/commitdiff
Sleeping vs Sleepy (trunk only)
authornethack.rankin <nethack.rankin>
Thu, 28 Jul 2011 04:00:21 +0000 (04:00 +0000)
committernethack.rankin <nethack.rankin>
Thu, 28 Jul 2011 04:00:21 +0000 (04:00 +0000)
     While looking at fixing the mfrozen issue for monsters (there's no
way to tell whether it's been caused by sleep or paralysis, necessitating
that some messages be vague or suppressed when actions impact monsters
who can't move), I noticed a drawbridge bug for the hero.  It was using
the misleadingly named Sleeping intrinsic incorrectly.  When that is
nonzero, the hero is prone to falling asleep at random intervals, not
necessarily asleep right now.  I've always intended to rename it to
something that's not misleading, but hadn't ever gotten around to doing
so, until now:  change the SLEEPING property to SLEEPY and the Sleeping
intrinsic/attribute to Sleepy.

     This may be moot for the drawbridge.  I can't remember any hero ever
jumping to safety instead of being crushed by either the bridge or its
portcullis, and I'm sure sleepiness hasn't been a factor.  So I haven't
included any fixes entry about misusing Sleeping when it meant u.usleep
(or better yet, unconscious(); or even better, Unaware [a post-3.4.3
pseudo-property that tests both unconscious() and fainted() when checking
whether hero is incapacitated]).

doc/fixes35.0
include/prop.h
include/youprop.h
src/cmd.c
src/dbridge.c
src/do_wear.c
src/eat.c
src/objects.c
src/timeout.c

index 09c25667713438cdddd3105c23436527aa1d0adc..4a7c0a4a255b5da3f1db1559fe2f1899e5d467f1 100644 (file)
@@ -376,6 +376,7 @@ for poly'd hero hiding on ceiling, attack by long worm might fill hero's
 when shop prices are adjusted, handle roundoff (integer truncation) better
 for hero poly'd into a monster form that lacks a weapon attack but has a claw
        attack, use wielded weapon even when claw attack isn't the very first
+rename the SLEEPING property and Sleeping attribute to SLEEPY and Sleepy, resp.
 
 
 Platform- and/or Interface-Specific Fixes
index 2a11dde2ede0930e6685092861a4aa2e96cd739c..5b3a572d6b6ecc619475daa70cbcf12176d44fbc 100644 (file)
@@ -1,5 +1,4 @@
 /* NetHack 3.5 prop.h  $Date$  $Revision$ */
-/*     SCCS Id: @(#)prop.h     3.5     1999/07/07      */
 /* Copyright (c) 1989 Mike Threepoint                            */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -36,7 +35,7 @@
 #define HALLUC_RES             24
 #define FUMBLING               25
 #define WOUNDED_LEGS           26
-#define SLEEPING               27
+#define SLEEPY                 27
 #define HUNGER                 28
 /* Vision and senses */
 #define SEE_INVIS              29
index 593403129648aa28203add3e1a95632282980b97..ae7b72cf3a5d29a6d8b8a2716c27b9fd8bf70b5b 100644 (file)
@@ -1,5 +1,4 @@
 /* NetHack 3.5 youprop.h       $Date$  $Revision$ */
-/*     SCCS Id: @(#)youprop.h  3.5     2007/03/16      */
 /* Copyright (c) 1989 Mike Threepoint                            */
 /* NetHack may be freely redistributed.  See license for details. */
 
 #define EWounded_legs          u.uprops[WOUNDED_LEGS].extrinsic
 #define Wounded_legs           (HWounded_legs || EWounded_legs)
 
-#define HSleeping              u.uprops[SLEEPING].intrinsic
-#define ESleeping              u.uprops[SLEEPING].extrinsic
-#define Sleeping               (HSleeping || ESleeping)
+#define HSleepy                        u.uprops[SLEEPY].intrinsic
+#define ESleepy                        u.uprops[SLEEPY].extrinsic
+#define Sleepy                 (HSleepy || ESleepy)
 
 #define HHunger                        u.uprops[HUNGER].intrinsic
 #define EHunger                        u.uprops[HUNGER].extrinsic
index 0593a67f756d9831eb6d4b92e1bce7c15531f5e3..320456938803a8a9a27ebbef30b4c8f7c3b64a0a 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -1544,11 +1544,11 @@ int final;
            if (magic || cause_known(FUMBLING))
                enl_msg(You_, "fumble", "fumbled", "", from_what(FUMBLING));
        }
-       if (Sleeping) {
-           if (magic || cause_known(SLEEPING)) {
-               Strcpy(buf, from_what(SLEEPING));
+       if (Sleepy) {
+           if (magic || cause_known(SLEEPY)) {
+               Strcpy(buf, from_what(SLEEPY));
 #ifdef WIZARD
-               if (wizard) Sprintf(eos(buf), " (%ld)", (HSleeping & TIMEOUT));
+               if (wizard) Sprintf(eos(buf), " (%ld)", (HSleepy & TIMEOUT));
 #endif
                enl_msg("You ", "fall", "fell", " asleep uncontrollably", buf);
            }
index 54c83412bbce533b4be19b1a8e2cf54fb9027db9..6d34f215c9de1cec3c1849164e94a2bd3e3b8494 100644 (file)
@@ -1,5 +1,4 @@
 /* NetHack 3.5 dbridge.c       $Date$  $Revision$ */
-/*     SCCS Id: @(#)dbridge.c  3.5     2007/02/19      */
 /*     Copyright (c) 1989 by Jean-Christophe Collet              */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -463,8 +462,8 @@ boolean chunks;
                return(TRUE);
 
        if (is_flyer(etmp->edata) &&
-           (is_u(etmp)? !Sleeping :
-            (etmp->emon->mcanmove && !etmp->emon->msleeping)))
+           (is_u(etmp)? !Unaware :
+               (etmp->emon->mcanmove && !etmp->emon->msleeping)))
                                                 /* flying requires mobility */
                misses = 5;     /* out of 8 */
        else if (is_floater(etmp->edata) ||
@@ -495,9 +494,9 @@ struct entity *etmp;
 {
        int tmp = 4;            /* out of 10 */
 
-       if (is_u(etmp)? (Sleeping || Fumbling) :
-                       (!etmp->emon->mcanmove || etmp->emon->msleeping ||
-                        !etmp->edata->mmove   || etmp->emon->wormno))
+       if (is_u(etmp) ? (Unaware || Fumbling) :
+                   (!etmp->emon->mcanmove || etmp->emon->msleeping ||
+                       !etmp->edata->mmove || etmp->emon->wormno))
                return(FALSE);
 
        if (is_u(etmp)? Confusion : etmp->emon->mconf)
index bd6ea1b1328d55c95012f1de2a89974d60078180..a7fc41a907385f4fdd082fe6044b25ffa3dd08a7 100644 (file)
@@ -712,12 +712,12 @@ Amulet_on()
                break;
        case AMULET_OF_RESTFUL_SLEEP:
            {
-               long newnap = (long)rnd(100), oldnap = (HSleeping & TIMEOUT);
+               long newnap = (long)rnd(100), oldnap = (HSleepy & 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;
+                   HSleepy = (HSleepy & ~TIMEOUT) | newnap;
            }
                break;
        case AMULET_OF_YENDOR:
@@ -767,9 +767,9 @@ Amulet_off()
                break;
        case AMULET_OF_RESTFUL_SLEEP:
                setworn((struct obj *)0, W_AMUL);
-               /* HSleeping = 0L; -- avoid clobbering FROMOUTSIDE bit */
-               if (!ESleeping && !(HSleeping & ~TIMEOUT))
-                   HSleeping &= ~TIMEOUT;      /* clear timeout bits */
+               /* HSleepy = 0L; -- avoid clobbering FROMOUTSIDE bit */
+               if (!ESleepy && !(HSleepy & ~TIMEOUT))
+                   HSleepy &= ~TIMEOUT;        /* clear timeout bits */
                return;
        case AMULET_OF_YENDOR:
                break;
index 2e2b90cd6f1203fde7d3dd04fbed80f30fd56ebf..212a85da6914afdcae6015faa78335687d63991b 100644 (file)
--- a/src/eat.c
+++ b/src/eat.c
@@ -1953,14 +1953,14 @@ struct obj *otmp;
                break;
            case AMULET_OF_RESTFUL_SLEEP: /* another bad idea! */
              {
-               long newnap = (long)rnd(100), oldnap = (HSleeping & TIMEOUT);
+               long newnap = (long)rnd(100), oldnap = (HSleepy & TIMEOUT);
 
-               if (!(HSleeping & FROMOUTSIDE))
+               if (!(HSleepy & FROMOUTSIDE))
                    accessory_has_effect(otmp);
-               HSleeping |= FROMOUTSIDE;
+               HSleepy |= FROMOUTSIDE;
                /* might also be wearing one; use shorter of two timeouts */
                if (newnap < oldnap || oldnap == 0L)
-                   HSleeping = (HSleeping & ~TIMEOUT) | newnap;
+                   HSleepy = (HSleepy & ~TIMEOUT) | newnap;
              }
                break;
            case RIN_SUSTAIN_ABILITY:
index 46b4101e51dd06af5dd8ce43c5c10cc3d9ef591e..c59c2ec59cd4da31a4561ecae8b9f46b024e923f 100644 (file)
@@ -548,7 +548,7 @@ RING("protection from shape changers", PROT_FROM_SHAPE_CHANGERS, "shiny",
 AMULET("amulet of ESP",           "circular",   TELEPAT,    175),
 AMULET("amulet of life saving",   "spherical",  LIFESAVED,   75),
 AMULET("amulet of strangulation", "oval",       STRANGLED,  135),
-AMULET("amulet of restful sleep", "triangular", SLEEPING,   135),
+AMULET("amulet of restful sleep", "triangular", SLEEPY,     135),
 AMULET("amulet versus poison",    "pyramidal",  POISON_RES, 165),
 AMULET("amulet of change",        "square",     0,          130),
                                                /* POLYMORPH */
index c0b61e9f933483074e7a05612059b6a84b9fd5e7..e59cbebc76a0a7df5041ea0a5055963aee09e268 100644 (file)
@@ -1,5 +1,4 @@
 /* NetHack 3.5 timeout.c       $Date$  $Revision$ */
-/*     SCCS Id: @(#)timeout.c  3.5     2009/01/20      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -337,14 +336,14 @@ nh_timeout()
                        (void) make_hallucinated(0L, TRUE, 0L);
                        stop_occupation();
                        break;
-               case SLEEPING:
+               case SLEEPY:
                        if (unconscious() || Sleep_resistance)
-                               HSleeping += rnd(100);
-                       else if (Sleeping) {
+                               HSleepy += rnd(100);
+                       else if (Sleepy) {
                                You("fall asleep.");
                                sleeptime = rnd(20);
                                fall_asleep(-sleeptime, TRUE);
-                               HSleeping += sleeptime + rnd(100);
+                               HSleepy += sleeptime + rnd(100);
                        }
                        break;
                case LEVITATION: