secret doors in Garden filled rooms, take two

A comment in rm.h claimed that secret doors can't be trapped so I
used door flag D_TRAPPED to handle secret doors that should be shown
as trees instead of walls.  But the comment was inaccurate and secret
doors can be trapped.

Such trapped secret doors in ordinary rooms ended up being shown as
trees too.  Switch from using D_ARBOREAL in levl[][].doormask to new
levl[][].arboreal_sdoor which overloads levl[][].candig.

Also, wizard mode wishing for secret doors needed updating to allow
creating trapped ones (at wall or door locations).

This ought to update EDITLEVEL but I think existing save files can
live with secret door display issues.  Untrapped secret doors in
garden-fill rooms will end up becoming trapped.

Replaces the fix for github issue #1309
This commit is contained in:
PatR
2025-04-19 11:23:29 -07:00
parent 96a750d99e
commit 4b7e330f3a
5 changed files with 22 additions and 20 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 detect.c $NHDT-Date: 1721684299 2024/07/22 21:38:19 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.180 $ */
/* NetHack 3.7 detect.c $NHDT-Date: 1745114235 2025/04/19 17:57:15 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.190 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2018. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1584,11 +1584,11 @@ do_vicinity_map(
docrt();
}
/* convert a secret door into a normal door */
/* convert a secret door into a normal door; it might be trapped */
void
cvt_sdoor_to_door(struct rm *lev)
{
int newmask = lev->doormask & ~(WM_MASK | D_ARBOREAL);
int newmask = lev->doormask & ~WM_MASK;
if (Is_rogue_level(&u.uz)) {
/* rogue didn't have doors, only doorways */
@@ -1600,6 +1600,7 @@ cvt_sdoor_to_door(struct rm *lev)
}
lev->typ = DOOR;
lev->doormask = newmask;
lev->arboreal_sdoor = 0; /* clears 'candig' */
}
/* update the map for something which has just been found by wand of secret

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 display.c $NHDT-Date: 1723834773 2024/08/16 18:59:33 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.244 $ */
/* NetHack 3.7 display.c $NHDT-Date: 1745114235 2025/04/19 17:57:15 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.260 $ */
/* Copyright (c) Dean Luick, with acknowledgements to Kevin Darcy */
/* and Dave Cohrs, 1990. */
/* NetHack may be freely redistributed. See license for details. */
@@ -2291,7 +2291,7 @@ back_to_glyph(coordxy x, coordxy y)
idx = (ptr->waslit || flags.lit_corridor) ? S_litcorr : S_corr;
break;
case SDOOR:
if ((ptr->doormask & D_ARBOREAL) != 0) {
if (ptr->arboreal_sdoor) {
idx = S_tree;
break;
}
@@ -3586,7 +3586,7 @@ wall_angle(struct rm *lev)
break;
case SDOOR:
if ((lev->doormask & D_ARBOREAL) != 0) {
if (lev->arboreal_sdoor) {
idx = S_tree;
break;
}

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 mkmaze.c $NHDT-Date: 1737387068 2025/01/20 07:31:08 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.176 $ */
/* NetHack 3.7 mkmaze.c $NHDT-Date: 1745114235 2025/04/19 17:57:15 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.179 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Pasi Kallinen, 2018. */
/* NetHack may be freely redistributed. See license for details. */
@@ -81,7 +81,7 @@ set_levltyp(coordxy x, coordxy y, schar newtyp)
/* hack for secret doors in garden theme rooms */
if (oldtyp == SDOOR && newtyp == AIR) {
/* levl[][].typ stays SDOOR rather than change to AIR */
levl[x][y].doormask |= D_ARBOREAL;
levl[x][y].arboreal_sdoor = 1;
return TRUE;
}

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 objnam.c $NHDT-Date: 1737528848 2025/01/21 22:54:08 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.444 $ */
/* NetHack 3.7 objnam.c $NHDT-Date: 1745114235 2025/04/19 17:57:15 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.453 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2011. */
/* NetHack may be freely redistributed. See license for details. */
@@ -3770,10 +3770,9 @@ wizterrainwish(struct _readobjnam_data *d)
lev->wall_info |= (old_wall_info & WM_MASK);
/* set up trapped flag; open door states aren't eligible */
if (d->trapped == 2 /* 2: wish includes explicit "untrapped" */
|| secret /* secret doors can't be trapped due to their use
* of both doormask and wall_info; those both
* overlay rm->flags and partially conflict */
|| (lev->doormask & (D_LOCKED | D_CLOSED)) == 0)
|| ((lev->doormask & (D_LOCKED | D_CLOSED)) == 0
/* D_CLOSED is implicit for secret doors */
&& !secret))
d->trapped = 0;
if (d->trapped)
lev->doormask |= D_TRAPPED;