]> granicus.if.org Git - nethack/commitdiff
diagonal movement glitch
authorPatR <rankin@nethack.org>
Tue, 3 Aug 2021 00:44:03 +0000 (17:44 -0700)
committerPatR <rankin@nethack.org>
Tue, 3 Aug 2021 00:44:03 +0000 (17:44 -0700)
|..X..
|.X}X.
|..X..
When testing the odd Samuari moats, I discovered that you could
easily walk diagonally between any two of the solid stone pillars
and fall into the water but you would always drown because it's a
no-teleport level and the crawl routine wouldn't let you back out
via that same diagonal.

The crawl routine is also being used by travel for the last step--a
post 3.6 change--so there was an unnecessary restriction on diagonal
movement there too.

doc/fixes37.0
src/hack.c
src/trap.c

index fa201ae20c867f7073fd2fba9a65a0a7cb308ffc..7851d0826082f4b1de914efd61bf3d83b27417fc 100644 (file)
@@ -1,4 +1,4 @@
-NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.614 $ $NHDT-Date: 1627951222 2021/08/03 00:40:22 $
+NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.615 $ $NHDT-Date: 1627951429 2021/08/03 00:43:49 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -582,6 +582,8 @@ in wizard mode, knowing teleport away spell resulted in ^T always attempting
        the spell instead of teleporting on demand
 describe a couple of isolated moat spots on Samurai quest home level as water
        rather than as moat
+crawling out of water to avoid drowning didn't work as intended when trying
+       to move diagonally through a tight squeeze
 
 
 Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
index d95542b44f9f1e7687d86240676ef1f1fc7ac836..a6a6e2997cccf9a6fceae760fbce8ebb8650788e 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 hack.c  $NHDT-Date: 1617035736 2021/03/29 16:35:36 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.281 $ */
+/* NetHack 3.7 hack.c  $NHDT-Date: 1627951429 2021/08/03 00:43:49 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.291 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Derek S. Ray, 2015. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -2969,7 +2969,8 @@ crawl_destination(int x, int y)
         return FALSE;
     /* finally, are we trying to squeeze through a too-narrow gap? */
     return !(bad_rock(g.youmonst.data, u.ux, y)
-             && bad_rock(g.youmonst.data, x, u.uy));
+             && bad_rock(g.youmonst.data, x, u.uy)
+             && cant_squeeze_thru(&g.youmonst));
 }
 
 /* something like lookaround, but we are not running */
index ddb5674e1f286605f8382636430c885ebab7225d..6fd29ecf55d216a644a2dd37c8b5b7a8fa2271bd 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 trap.c  $NHDT-Date: 1615759958 2021/03/14 22:12:38 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.403 $ */
+/* NetHack 3.7 trap.c  $NHDT-Date: 1627951430 2021/08/03 00:43:50 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.416 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2013. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -4229,6 +4229,7 @@ drown(void)
     if (g.multi < 0 || (Upolyd && !g.youmonst.data->mmove))
         goto crawl;
     /* look around for a place to crawl to */
+#if 0
     for (i = 0; i < 100; i++) {
         x = rn1(3, u.ux - 1);
         y = rn1(3, u.uy - 1);
@@ -4244,6 +4245,31 @@ drown(void)
                 crawl_ok = TRUE;
                 goto crawl;
             }
+#else
+    {
+        int j, k, dirs[N_DIRS];
+
+        /* instead of picking a random direction up to 100 times, try each
+           of the eight directions at most once after shuffling their order */
+        for (i = 0; i < N_DIRS; ++i)
+            dirs[i] = i;
+        for (i = N_DIRS; i > 0; --i) {
+            j = rn2(i);
+            k = dirs[j];
+            dirs[j] = dirs[i - 1];
+            dirs[i - 1] = k;
+        }
+        for (i = 0; i < N_DIRS; ++i) {
+            x = u.ux + xdir[dirs[i]];
+            y = u.uy + ydir[dirs[i]];
+            /* note: crawl_dest calls goodpos() which performs isok() check */
+            if (crawl_destination(x, y)) {
+                crawl_ok = TRUE;
+                break;
+            }
+        }
+    }
+#endif
  crawl:
     if (crawl_ok) {
         boolean lost = FALSE;