From 28ab93325e067faa79e18d15775b6ee47e4a822e Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Thu, 28 Jul 2011 04:00:21 +0000 Subject: [PATCH] Sleeping vs Sleepy (trunk only) 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 | 1 + include/prop.h | 3 +-- include/youprop.h | 7 +++---- src/cmd.c | 8 ++++---- src/dbridge.c | 11 +++++------ src/do_wear.c | 10 +++++----- src/eat.c | 8 ++++---- src/objects.c | 2 +- src/timeout.c | 9 ++++----- 9 files changed, 28 insertions(+), 31 deletions(-) diff --git a/doc/fixes35.0 b/doc/fixes35.0 index 09c256677..4a7c0a4a2 100644 --- a/doc/fixes35.0 +++ b/doc/fixes35.0 @@ -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 diff --git a/include/prop.h b/include/prop.h index 2a11dde2e..5b3a572d6 100644 --- a/include/prop.h +++ b/include/prop.h @@ -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 diff --git a/include/youprop.h b/include/youprop.h index 593403129..ae7b72cf3 100644 --- a/include/youprop.h +++ b/include/youprop.h @@ -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. */ @@ -132,9 +131,9 @@ #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 diff --git a/src/cmd.c b/src/cmd.c index 0593a67f7..320456938 100644 --- 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); } diff --git a/src/dbridge.c b/src/dbridge.c index 54c83412b..6d34f215c 100644 --- a/src/dbridge.c +++ b/src/dbridge.c @@ -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) diff --git a/src/do_wear.c b/src/do_wear.c index bd6ea1b13..a7fc41a90 100644 --- a/src/do_wear.c +++ b/src/do_wear.c @@ -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; diff --git a/src/eat.c b/src/eat.c index 2e2b90cd6..212a85da6 100644 --- 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: diff --git a/src/objects.c b/src/objects.c index 46b4101e5..c59c2ec59 100644 --- a/src/objects.c +++ b/src/objects.c @@ -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 */ diff --git a/src/timeout.c b/src/timeout.c index c0b61e9f9..e59cbebc7 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -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: -- 2.50.1