]> granicus.if.org Git - nethack/commitdiff
falling into water while asleep
authornethack.rankin <nethack.rankin>
Tue, 11 Feb 2003 11:57:14 +0000 (11:57 +0000)
committernethack.rankin <nethack.rankin>
Tue, 11 Feb 2003 11:57:14 +0000 (11:57 +0000)
     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.

doc/fixes34.1
src/trap.c

index fef372d59bfbafd7d8c66c95b14d14c39d5b17e8..208c0b73fe4521764bf3ab998ad5c9a907cfa33d 100644 (file)
@@ -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
index 2b32638ac40155514fba79726144147247a77cad..55ea74d95743d44c290cdb630380dda839cc2ec9 100644 (file)
@@ -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... */