From: nethack.rankin Date: Tue, 11 Feb 2003 11:57:14 +0000 (+0000) Subject: falling into water while asleep X-Git-Tag: MOVE2GIT~2194 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fe05bcf52dde8e183e649b337c983b942a12eee5;p=nethack falling into water while asleep Try to fix the reported bug of not waking up if sleeping on ice that gets melted out from under you. This fixes the straightforward case but I suspect there are other permutations that it doesn't cover. Teleporting out of water is now blocked if asleep; waking up occurs after the chance for that has passed. --- diff --git a/doc/fixes34.1 b/doc/fixes34.1 index fef372d59..208c0b73f 100644 --- a/doc/fixes34.1 +++ b/doc/fixes34.1 @@ -380,6 +380,7 @@ xorns sink if the drawbridge they're standing on is raised applying figurines to an adjacent spot over water does drowning checks fix sequencing of Magicbane's hit messages avoid buffer overflow from long or too many -s params +wake up first if trying to crawl out of water while asleep Platform- and/or Interface-Specific Fixes diff --git a/src/trap.c b/src/trap.c index 2b32638ac..55ea74d95 100644 --- a/src/trap.c +++ b/src/trap.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)trap.c 3.4 2003/01/08 */ +/* SCCS Id: @(#)trap.c 3.4 2003/02/10 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2718,8 +2718,8 @@ drown() vision_full_recalc = 1; return(FALSE); } - if((Teleportation || can_teleport(youmonst.data)) && - (Teleport_control || rn2(3) < Luck+2)) { + if ((Teleportation || can_teleport(youmonst.data)) && + !u.usleep && (Teleport_control || rn2(3) < Luck+2)) { You("attempt a teleport spell."); /* utcsri!carroll */ (void) dotele(); if(!is_pool(u.ux,u.uy)) @@ -2733,6 +2733,12 @@ drown() } #endif crawl_ok = FALSE; + /* if sleeping, wake up now so that we don't crawl out of water + while still asleep; we can't do that the same way that waking + due to combat is handled; note unmul() clears u.usleep */ + if (u.usleep) unmul("Suddenly you wake up!"); + /* can't crawl if unable to move (crawl_ok flag stays false) */ + if (multi < 0 || (Upolyd && !youmonst.data->mmove)) goto crawl; /* look around for a place to crawl to */ for (i = 0; i < 100; i++) { x = rn1(3,u.ux - 1); @@ -2749,7 +2755,7 @@ drown() crawl_ok = TRUE; goto crawl; } -crawl:; + crawl: if (crawl_ok) { boolean lost = FALSE; /* time to do some strip-tease... */