]> granicus.if.org Git - nethack/commitdiff
don't miss the special furniture checks during liquid flow
authornhmall <nhmall@nethack.org>
Fri, 11 Dec 2020 21:28:59 +0000 (16:28 -0500)
committernhmall <nhmall@nethack.org>
Fri, 11 Dec 2020 21:28:59 +0000 (16:28 -0500)
Closes #405

doc/fixes37.0
src/dig.c

index cc5b3f9544383962b1d15cf84a8131d3338319c8..5f7211531fecc517df8bf57f9e5f4858bcd1688c 100644 (file)
@@ -419,6 +419,8 @@ options help ('? g') listed all boolean options, then repeated them among
 change name of #wizlevelflip to #wizfliplevel
 dwarves could sometimes pass through walls without digging their way
 fix genetic engineers dropping Schroedinger's cat box
+the checks and handling for fountains, sinks, and drawbridges were being
+       missed during liquid_flow
 
 curses: 'msg_window' option wasn't functional for curses unless the binary
        also included tty support
index 7c3e603c269e6d8f1934ce9196f3a6ba6869dba0..15553d11bbae23ed5a4e80fe309095a96da96b06 100644 (file)
--- a/src/dig.c
+++ b/src/dig.c
@@ -13,6 +13,7 @@ static int NDECL(dig);
 static void FDECL(dig_up_grave, (coord *));
 static int FDECL(adj_pit_checks, (coord *, char *));
 static void FDECL(pit_flow, (struct trap *, SCHAR_P));
+static boolean FDECL(furniture_handled, (int, int, BOOLEAN_P));
 
 /* Indices returned by dig_typ() */
 enum dig_types {
@@ -489,6 +490,33 @@ dig(VOID_ARGS)
     return 1;
 }
 
+static boolean
+furniture_handled(x, y, madeby_u)
+int x, y;
+boolean madeby_u;
+{
+    struct rm *lev = &levl[x][y];
+
+    if (IS_FOUNTAIN(lev->typ)) {
+        dogushforth(FALSE);
+        SET_FOUNTAIN_WARNED(x, y); /* force dryup */
+        dryup(x, y, madeby_u);
+    } else if (IS_SINK(lev->typ)) {
+        breaksink(x, y);
+    } else if (lev->typ == DRAWBRIDGE_DOWN
+               || (is_drawbridge_wall(x, y) >= 0)) {
+        int bx = x, by = y;
+
+        /* if under the portcullis, the bridge is adjacent */
+        (void) find_drawbridge(&bx, &by);
+        destroy_drawbridge(bx, by);
+    } else {
+        return FALSE;
+    }
+    return TRUE;
+}
+
+
 /* When will hole be finished? Very rough indication used by shopkeeper. */
 int
 holetime()
@@ -558,25 +586,8 @@ int ttyp;
             reset_utrap(FALSE);
     }
 
-    /* these furniture checks were in dighole(), but wand
-       breaking bypasses that routine and calls us directly */
-    if (IS_FOUNTAIN(lev->typ)) {
-        dogushforth(FALSE);
-        SET_FOUNTAIN_WARNED(x, y); /* force dryup */
-        dryup(x, y, madeby_u);
-        return;
-    } else if (IS_SINK(lev->typ)) {
-        breaksink(x, y);
+    if (furniture_handled(x, y, madeby_u))
         return;
-    } else if (lev->typ == DRAWBRIDGE_DOWN
-               || (is_drawbridge_wall(x, y) >= 0)) {
-        int bx = x, by = y;
-
-        /* if under the portcullis, the bridge is adjacent */
-        (void) find_drawbridge(&bx, &by);
-        destroy_drawbridge(bx, by);
-        return;
-    }
 
     if (ttyp != PIT && (!Can_dig_down(&u.uz) && !lev->candig)) {
         impossible("digactualhole: can't dig %s on this level.",
@@ -876,9 +887,11 @@ coord *cc;
 
         lev->flags = 0;
         if (typ != ROOM) {
-            lev->typ = typ;
-            liquid_flow(dig_x, dig_y, typ, ttmp,
-                        "As you dig, the hole fills with %s!");
+            if (!furniture_handled((int) dig_x, (int) dig_y, TRUE)) {
+                lev->typ = typ;
+                liquid_flow(dig_x, dig_y, typ, ttmp,
+                            "As you dig, the hole fills with %s!");
+            }
             return TRUE;
         }