From 6a259a1464af762adb31645c97f306d49c91d73f Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Tue, 27 May 2008 04:49:43 +0000 Subject: [PATCH] restful sleep bit (trunk only) A change yesterday made putting on an amulet of restful sleep avoid clobbering the timeout from having already eaten one, only replace it if the new timeout is shorter. This does the inverse; when eating one, if you're already sleepy from also wearing that type of amulet, only replace the timeout if new one is shorter. And don't clobber the other intrinsic bits with FROMOUTSIDE, just add it to whatever ones might already be set. Neither should have any observable effect on game play, so no fixes entry. --- src/eat.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/eat.c b/src/eat.c index 7faac3a6a..3f683fce7 100644 --- a/src/eat.c +++ b/src/eat.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)eat.c 3.5 2007/03/19 */ +/* SCCS Id: @(#)eat.c 3.5 2008/05/26 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1945,9 +1945,16 @@ struct obj *otmp; choke(otmp); break; case AMULET_OF_RESTFUL_SLEEP: /* another bad idea! */ + { + long newnap = (long)rnd(100), oldnap = (HSleeping & TIMEOUT); + if (!(HSleeping & FROMOUTSIDE)) accessory_has_effect(otmp); - HSleeping = FROMOUTSIDE | rnd(100); + HSleeping |= FROMOUTSIDE; + /* might also be wearing one; use shorter of two timeouts */ + if (newnap < oldnap || oldnap == 0L) + HSleeping = (HSleeping & ~TIMEOUT) | newnap; + } break; case RIN_SUSTAIN_ABILITY: case AMULET_OF_LIFE_SAVING: -- 2.40.0