]> granicus.if.org Git - nethack/commitdiff
wizard mode wishing for secret doors
authorPatR <rankin@nethack.org>
Sun, 5 Jan 2020 21:13:21 +0000 (13:13 -0800)
committerPatR <rankin@nethack.org>
Sun, 5 Jan 2020 21:13:21 +0000 (13:13 -0800)
Allow wishing for secret doors and secret corridors.  It's a bit
more strict about where the wish is performed than wishing for
furniture.  Implemented in order to test drum of earthquake effects.

I spent a lot of time figuring out SDOOR details that somebody
already knew at some point but evidently didn't document--you can't
specify D_CLOSED for them or the display code will issue impossible
warnings about wall mode angles.

doc/fixes37.0
include/rm.h
src/objnam.c

index e6a332466f688a3ed7136cbdcabb301ac8e91665..614c26960c8049eca13010a2888f878bb99bb121 100644 (file)
@@ -1,4 +1,4 @@
-$NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.51 $ $NHDT-Date: 1578252630 2020/01/05 19:30:30 $
+$NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.52 $ $NHDT-Date: 1578258722 2020/01/05 21:12:02 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -74,6 +74,9 @@ add 'quick_farsight' option to provide some control over random clairvoyance
 replace "money" in in-game texts with "gold"
 when hallucinating, see hallucinated currencies instead of bits for an ale
 applying a spellbook hints about read charges left
+wizard mode wishing for level topology can now create hidden doors (ask for
+       "secret door" when at a door or wall location) and hidden corridor
+       spots ("secret corridor" at a corridor location)
 
 
 Platform- and/or Interface-Specific New Features
index 15d451bc329b079fbb24f0f9d07129b7d01b66dc..09553de13c1e5de9940e74fc7450d851e2484373 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 rm.h    $NHDT-Date: 1573943499 2019/11/16 22:31:39 $  $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.66 $ */
+/* NetHack 3.6 rm.h    $NHDT-Date: 1578258722 2020/01/05 21:12:02 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.77 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Pasi Kallinen, 2017. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -310,9 +310,20 @@ extern const struct symdef def_warnsyms[WARNCOUNT];
 #define SYMHANDLING(ht) (g.symset[g.currentgraphics].handling == (ht))
 
 /*
- * The 5 possible states of doors
+ *      Note:  secret doors (SDOOR) want to use both rm.doormask and
+ *      rm.wall_info but those both overload rm.flags.  SDOOR only
+ *      has 2 states (closed or locked).  However, it can't specify
+ *      D_CLOSED due to that conflicting with WM_MASK (below).  When
+ *      a secret door is revealed, the door gets set to D_CLOSED iff
+ *      it isn't set to D_LOCKED (see cvt_sdoor_to_door() in detect.c).
+ *
+ *      D_TRAPPED conflicts with W_NONDIGGABLE but the latter is not
+ *      expected to be used on door locations.
  */
 
+/*
+ * The 5 possible states of doors.
+ */
 #define D_NODOOR 0
 #define D_BROKEN 1
 #define D_ISOPEN 2
index fe5f2442a227daca6980b65da40ca0e7f5fdd1e4..df23fb57da6a906a14bc6dc215d50c190afc6b3b 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 objnam.c        $NHDT-Date: 1578190895 2020/01/05 02:21:35 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.279 $ */
+/* NetHack 3.7 objnam.c        $NHDT-Date: 1578258724 2020/01/05 21:12:04 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.280 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2011. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -3695,7 +3695,7 @@ struct obj *no_wish;
  wiztrap:
     if (wizard && !g.program_state.wizkit_wishing) {
         struct rm *lev;
-        boolean madeterrain = FALSE;
+        boolean madeterrain = FALSE, badterrain = FALSE;
         int trap, x = u.ux, y = u.uy;
 
         for (trap = NO_TRAP + 1; trap < TRAPNUM; trap++) {
@@ -3789,6 +3789,45 @@ struct obj *no_wish;
             lev->typ = IRONBARS;
             pline("Iron bars.");
             madeterrain = TRUE;
+        } else if (!BSTRCMPI(bp, p - 11, "secret door")) {
+            if (lev->typ == DOOR
+                || (IS_WALL(lev->typ) && lev->typ != DBWALL)) {
+                lev->typ = SDOOR;
+                lev->wall_info = 0;
+                /* lev->horizontal stays as-is */
+                /* no special handling for rogue level is necessary;
+                   exposing a secret door there yields a doorless doorway */
+#if 0       /*
+             * Can't do this; secret doors want both doormask and
+             * wall_info but those both overload rm.flags which makes
+             * D_CLOSED conflict with WM_MASK.  However, converting
+             * secret door to regular door sets D_CLOSED iff D_LOCKED
+             * isn't specified so the alternate code suffices.
+             */
+                lev->doormask = locked ? D_LOCKED : D_CLOSED;
+#else
+                /* cvt_sdoor_to_door() will change D_NODOOR to D_CLOSED */
+                lev->doormask = locked ? D_LOCKED : D_NODOOR;
+#endif
+                if (trapped)
+                    lev->doormask |= D_TRAPPED;
+                block_point(x, y);
+                pline("Secret door.");
+                madeterrain = TRUE;
+            } else {
+                pline("Secret door requires door or wall location.");
+                badterrain = TRUE;
+            }
+        } else if (!BSTRCMPI(bp, p - 15, "secret corridor")) {
+            if (lev->typ == CORR) {
+                lev->typ = SCORR;
+                block_point(x, y);
+                pline("Secret corridor.");
+                madeterrain = TRUE;
+            } else {
+                pline("Secret corridor requires corridor location.");
+                badterrain = TRUE;
+            }
         }
 
         if (madeterrain) {
@@ -3803,6 +3842,8 @@ struct obj *no_wish;
                        && !is_lava(u.ux, u.uy)) {
                 reset_utrap(FALSE);
             }
+        }
+        if (madeterrain || badterrain) {
             /* cast 'const' away; caller won't modify this */
             return (struct obj *) &cg.zeroobj;
         }