Debug flag allowing overwriting stairs

And using it in the movement tests, so running doesn't stop
at stairs.
This commit is contained in:
Pasi Kallinen
2021-07-30 16:35:33 +03:00
parent 5580cd6286
commit b080ea12c2
5 changed files with 20 additions and 5 deletions

View 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 */

View 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; \

View 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;
}

View File

@@ -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);

View 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)