]> granicus.if.org Git - nethack/commitdiff
Debug flag allowing overwriting stairs
authorPasi Kallinen <paxed@alt.org>
Fri, 30 Jul 2021 13:35:33 +0000 (16:35 +0300)
committerPasi Kallinen <paxed@alt.org>
Fri, 30 Jul 2021 13:35:36 +0000 (16:35 +0300)
And using it in the movement tests, so running doesn't stop
at stairs.

include/flag.h
include/sp_lev.h
src/nhlua.c
src/sp_lev.c
test/testmove.lua

index fa8ed6f5823b2efa18a828d5076fd5d457e45a65..cff075431cde3d66e0b35ba862c25fa8b875579d 100644 (file)
@@ -204,6 +204,7 @@ struct instance_flags {
     boolean window_inited; /* true if init_nhwindows() completed */
     boolean vision_inited; /* true if vision is ready */
     boolean sanity_check;  /* run sanity checks */
+    boolean debug_overwrite_stairs; /* debug: allow overwriting stairs */
     boolean debug_mongen;  /* debug: prevent monster generation */
     boolean debug_hunger;  /* debug: prevent hunger */
     boolean mon_polycontrol; /* debug: control monster polymorphs */
index ae43d767b5fce9df8e48141e4347b5639a1b58dc..920253543a57fb44f008bdba83bd74283da4ba77 100644 (file)
@@ -196,11 +196,14 @@ struct mapfragment {
     char *data;
 };
 
+#define CAN_OVERWRITE_TERRAIN(ttyp) \
+    (iflags.debug_overwrite_stairs || !((ttyp) == LADDER || (ttyp) == STAIRS))
+
 #define SET_TYPLIT(x, y, ttyp, llit) \
     do {                                                          \
         if ((x) >= 1 && (y) >= 0 && (x) < COLNO && (y) < ROWNO) { \
-            if ((ttyp) < MAX_TYPE && levl[(x)][(y)].typ != STAIRS \
-                && levl[(x)][(y)].typ != LADDER)                  \
+            if ((ttyp) < MAX_TYPE                                 \
+                && CAN_OVERWRITE_TERRAIN(levl[(x)][(y)].typ))     \
                 levl[(x)][(y)].typ = (ttyp);                      \
             if ((ttyp) == LAVAPOOL)                               \
                 levl[(x)][(y)].lit = 1;                           \
index ba3834857eab028c30131006f68a57b805fe29e9..92b0808eaf3d7074d3abfce57208bbdfe84f4be5 100644 (file)
@@ -974,7 +974,9 @@ nhl_doturn(lua_State *L)
 }
 
 /* set debugging flags. debugging use only, of course. */
-/* nh.debug_flags({ mongen = false, hunger = false }); */
+/* nh.debug_flags({ mongen = false,
+                    hunger = false,
+                    overwrite_stairs = true }); */
 static int
 nhl_debug_flags(lua_State *L)
 {
@@ -1004,6 +1006,12 @@ nhl_debug_flags(lua_State *L)
         iflags.debug_hunger = !(boolean)val; /* value in lua is negated */
     }
 
+    /* allow overwriting stairs */
+    val = get_table_boolean_opt(L, "overwrite_stairs", -1);
+    if (val != -1) {
+        iflags.debug_overwrite_stairs = (boolean)val;
+    }
+
     return 0;
 }
 
index 7cd2cd108a1ca2f2888f10bebb2f37fa767c9a64..a73ed4f3067187f39dd85f9c08eb5c2e124c47ca 100755 (executable)
@@ -2338,7 +2338,7 @@ create_altar(altar* a, struct mkroom* croom)
 
     /* check for existing features */
     oldtyp = levl[x][y].typ;
-    if (oldtyp == STAIRS || oldtyp == LADDER)
+    if (!CAN_OVERWRITE_TERRAIN(oldtyp))
         return;
 
     amask = sp_amask_to_amask(a->sp_amask);
index 3e591e36b075082a105cbe16aa5e656b38a204e9..b8d310e8e76fae82594a9931b5feb294e711594c 100644 (file)
@@ -13,12 +13,15 @@ local POS = { x = 10, y = 05 };
 local number_pad = 0;
 
 function initlev()
-   nh.debug_flags({mongen = false, hunger = false });
+   nh.debug_flags({mongen = false, hunger = false, overwrite_stairs = true });
    des.level_flags("noflip");
    des.reset_level();
    des.level_init({ style = "solidfill", fg = ".", lit = true });
    des.teleport_region({ region = {POS.x,POS.y,POS.x,POS.y}, region_islev = true, dir="both" });
    des.finalize_level();
+   for k, v in pairs(nh.stairways()) do
+      des.terrain(v.x - 1, v.y, ".");
+   end
 end
 
 function ctrl(key)