From 0ca2af4d8bcf8497f1916c6ac6d46361eafac28e Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 10 Jun 2023 01:46:35 -0700 Subject: [PATCH] wizwish fountain and sink bookkeeping Noticed while considering the pull request about loosening restrictions on trap creation at furniture locations. If you wish for a terrain feature while on a fountain or sink, the counters used to control whether sounds for those should be given will be off by one. It was incrementing the appropriate counter if you wished for a fountain or sink, but it shouldn't do that if recreating the same feature (perhaps to reset a magic fountain or looted sink) and it needed to decrement when replacing either of those with some other feature. After the count became wrong, if all fountains or sinks on the level were destroyed, those splashing, gurgling, &c sounds would continue to be generated periodically. --- doc/fixes3-7-0.txt | 5 ++++- src/objnam.c | 15 +++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index c46bed4a7..20e6310c2 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1,4 +1,4 @@ -HDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1188 $ $NHDT-Date: 1685202441 2023/05/27 15:47:21 $ +HDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1196 $ $NHDT-Date: 1686386794 2023/06/10 08:46:34 $ General Fixes and Modified Features ----------------------------------- @@ -1203,6 +1203,9 @@ hero might hear unseen monster read scroll of create monster or scroll of teleportation; when it was create monster, player was given a chance to call it something but not when it was teleportation, allowing the player to deduce which type of scroll it actually was +wizard mode wish for terrain while on a fountain|sink spot made the counter + for number of fountains|sinks become one too big; would affect level + sound messages if all fountains|sinks were eventually destroyed Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/src/objnam.c b/src/objnam.c index 97c163520..c9d713e88 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 objnam.c $NHDT-Date: 1672829441 2023/01/04 10:50:41 $ $NHDT-Branch: naming-overflow-fix $:$NHDT-Revision: 1.386 $ */ +/* NetHack 3.7 objnam.c $NHDT-Date: 1686386790 2023/06/10 08:46:30 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.392 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2011. */ /* NetHack may be freely redistributed. See license for details. */ @@ -3267,9 +3267,10 @@ wizterrainwish(struct _readobjnam_data *d) p = eos(bp); if (!BSTRCMPI(bp, p - 8, "fountain")) { lev->typ = FOUNTAIN; - gl.level.flags.nfountains++; + if (oldtyp != FOUNTAIN) + gl.level.flags.nfountains++; lev->looted = d->looted ? F_LOOTED : 0; /* overlays 'flags' */ - lev->blessedftn = !strncmpi(bp, "magic ", 6); + lev->blessedftn = d->blessed || !strncmpi(bp, "magic ", 6); pline("A %sfountain.", lev->blessedftn ? "magic " : ""); madeterrain = TRUE; } else if (!BSTRCMPI(bp, p - 6, "throne")) { @@ -3279,7 +3280,8 @@ wizterrainwish(struct _readobjnam_data *d) madeterrain = TRUE; } else if (!BSTRCMPI(bp, p - 4, "sink")) { lev->typ = SINK; - gl.level.flags.nsinks++; + if (oldtyp != SINK) + gl.level.flags.nsinks++; lev->looted = d->looted ? (S_LPUDDING | S_LDWASHER | S_LRING) : 0; pline("A sink."); madeterrain = TRUE; @@ -3483,6 +3485,11 @@ wizterrainwish(struct _readobjnam_data *d) if (madeterrain) { feel_newsym(x, y); /* map the spot where the wish occurred */ + if (oldtyp == FOUNTAIN && lev->typ != FOUNTAIN) + gl.level.flags.nfountains--; + else if (oldtyp == SINK && lev->typ != SINK) + gl.level.flags.nsinks--; + /* hero started at but might not be there anymore (create lava, decline to die, and get teleported away to safety) */ if (u.uinwater && !is_pool(u.ux, u.uy)) {