From 93f8e5b3b354a02c0ae55c28d605fde6976f84de Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 20 Nov 2025 15:02:54 -0800 Subject: [PATCH] fix #S14702 - travel to covered vibrating square Targeting '~' when vibrating square has been discovered would report "Can't find dungeon feature '~'" if it was covered by an object or a monster. That's normal behavior for a trap but the vibrating square is only one of those for display purposes. --- doc/fixes3-7-0.txt | 5 ++++- src/detect.c | 8 +++++++- src/getpos.c | 33 ++++++++++++++++++++++++++++----- src/hack.c | 7 +++++-- 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 8954f3c00..185f271ee 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1,4 +1,4 @@ -NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1575 $ $NHDT-Date: 1762750699 2025/11/09 20:58:19 $ +NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1576 $ $NHDT-Date: 1763708572 2025/11/20 23:02:52 $ General Fixes and Modified Features ----------------------------------- @@ -1532,6 +1532,9 @@ some food and paper items do no damage when bashing improved messages for oilskin sacks protecting from water damage some messages by amorous demons and mail daemon were delivered as verbal ones even when the hero is deaf +travel couldn't find the vibrating square if it was covered by an object or + a monster; it isn't really a trap so treat it as special terrain +travel would stop one step in front of known vibrating square like other traps Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/src/detect.c b/src/detect.c index 61e5dd3d6..a74cdfea4 100644 --- a/src/detect.c +++ b/src/detect.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 detect.c $NHDT-Date: 1745114235 2025/04/19 17:57:15 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.190 $ */ +/* NetHack 3.7 detect.c $NHDT-Date: 1763708572 2025/11/20 23:02:52 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.191 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2018. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2179,6 +2179,12 @@ reveal_terrain_getglyph( keep_mons = (which_subset & TER_MON) != 0, full = (which_subset & TER_FULL) != 0; + /* + * FIXME: + * travel treats discovered vibrating square as if it were terrain + * rather than a trap so this should do so too. + */ + /* for 'full', show the actual terrain for the entire level, otherwise what the hero remembers for seen locations with monsters, objects, and/or traps removed as caller dictates */ diff --git a/src/getpos.c b/src/getpos.c index 36e9d95ea..bc892a187 100644 --- a/src/getpos.c +++ b/src/getpos.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 getpos.c $NHDT-Date: 1723875487 2024/08/17 06:18:07 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.3 $ */ +/* NetHack 3.7 getpos.c $NHDT-Date: 1763708572 2025/11/20 23:02:52 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.6 $ */ /*-Copyright (c) Pasi Kallinen, 2023. */ /* NetHack may be freely redistributed. See license for details. */ @@ -18,6 +18,7 @@ staticfn void gloc_filter_floodfill(coordxy, coordxy); staticfn void gloc_filter_init(void); staticfn void gloc_filter_done(void); staticfn void gather_locs(coord **, int *, int); +staticfn boolean known_vibrating_square_at(coordxy, coordxy); staticfn void truncate_to_map(coordxy *, coordxy *, schar, schar); staticfn void getpos_refresh(void); /* Callback function for getpos() to highlight desired map locations. @@ -192,7 +193,7 @@ getpos_help(boolean force, const char *goal) putstr(tmpwin, 0, sbuf); putstr(tmpwin, 0, "Or enter a background symbol (ex. '<')."); Sprintf(sbuf, "Use '%s' to move the cursor on yourself.", - visctrl(gc.Cmd.spkeys[NHKF_GETPOS_SELF])); + visctrl(gc.Cmd.spkeys[NHKF_GETPOS_SELF])); putstr(tmpwin, 0, sbuf); if (!iflags.terrainmode || (iflags.terrainmode & TER_MON) != 0) { getpos_help_keyxhelp(tmpwin, @@ -417,10 +418,26 @@ gloc_filter_done(void) } } +staticfn boolean +known_vibrating_square_at(coordxy x, coordxy y) +{ + /* note: this only acknowledges the genuine vibrating square, not + fake ones produced by wizard mode wishing for traps which could + possibly be transfered to normal play via bones file */ + if (invocation_pos(x, y)) { + struct trap *ttmp = t_at(x, y); + + return ttmp && ttmp->ttyp == VIBRATING_SQUARE && ttmp->tseen; + } + return FALSE; +} + DISABLE_WARNING_UNREACHABLE_CODE boolean -gather_locs_interesting(coordxy x, coordxy y, int gloc) +gather_locs_interesting( + coordxy x, coordxy y, + int gloc) { int glyph, sym; @@ -439,7 +456,7 @@ gather_locs_interesting(coordxy x, coordxy y, int gloc) /* unlike '/M', this skips monsters revealed by warning glyphs and remembered unseen ones */ return (glyph_is_monster(glyph) - && glyph != monnum_to_glyph(PM_LONG_WORM_TAIL,MALE) + && glyph != monnum_to_glyph(PM_LONG_WORM_TAIL, MALE) && glyph != monnum_to_glyph(PM_LONG_WORM_TAIL, FEMALE)); case GLOC_OBJS: return (glyph_is_object(glyph) @@ -482,7 +499,8 @@ gather_locs_interesting(coordxy x, coordxy y, int gloc) || is_cmap_room(sym) || is_cmap_corr(sym))) || glyph_is_nothing(glyph) - || glyph_is_unexplored(glyph))); + || glyph_is_unexplored(glyph)) + || known_vibrating_square_at(x, y)); } /*NOTREACHED*/ return FALSE; @@ -1069,6 +1087,11 @@ getpos(coord *ccp, boolean force, const char *goal) && matching[glyph_to_cmap(k)]) goto foundc; } + /* FIXME: check player-specified vib.sq trap + symbol rather than or in addition to '~' */ + if (c == '~' + && known_vibrating_square_at(tx, ty)) + goto foundc; /* last, try actual terrain here (shouldn't we be using svl.lastseentyp[][] instead?) */ if (levl[tx][ty].seenv) { diff --git a/src/hack.c b/src/hack.c index 89c153746..9c0a56712 100644 --- a/src/hack.c +++ b/src/hack.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 hack.c $NHDT-Date: 1736530208 2025/01/10 09:30:08 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.477 $ */ +/* NetHack 3.7 hack.c $NHDT-Date: 1763708572 2025/11/20 23:02:52 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.494 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2425,7 +2425,10 @@ avoid_moving_on_trap(coordxy x, coordxy y, boolean msg) { struct trap *trap; - if ((trap = t_at(x, y)) && trap->tseen) { + if ((trap = t_at(x, y)) && trap->tseen + /* the vibrating square is implemented as a trap but treated as if + it were a type of terrain */ + && trap->ttyp != VIBRATING_SQUARE) { if (msg && flags.mention_walls) { set_msg_xy(x, y); You("stop in front of %s.",