fix #S15038 - cursed magic whistle

Reported via contact form but misclassified as spam.  Applyin a magic
has a chance to teleport the hero to be adjacent to a pet rather than
vice versa, but it could do so even on no-teleport levels.
This commit is contained in:
PatR
2026-01-24 20:03:22 -08:00
parent 77ea8de105
commit cb8de068ad
3 changed files with 11 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1580 $ $NHDT-Date: 1764109066 2025/11/25 22:17:46 $
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1614 $ $NHDT-Date: 1769342601 2026/01/25 04:03:21 $
General Fixes and Modified Features
-----------------------------------
@@ -2201,6 +2201,7 @@ when reading a T-shirt or apron, add trailing period to the slogan unless
already present in the quoted text
when reading an engraving, suppress the addition of a trailing period if the
text already has one
cursed magic whistle could teleport hero on no-teleport levels
Fixes to 3.7.0-x Platform and/or Interface Problems Exposed Via git Repository

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 apply.c $NHDT-Date: 1753856387 2025/07/29 22:19:47 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.472 $ */
/* NetHack 3.7 apply.c $NHDT-Date: 1769342601 2026/01/25 04:03:21 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.475 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
@@ -500,7 +500,7 @@ use_magic_whistle(struct obj *obj)
You("produce a %shigh-%s.", Underwater ? "very " : "",
Deaf ? "frequency vibration" : "pitched humming noise");
wake_nearby(TRUE);
if (!rn2(2))
if (!rn2(2) && !noteleport_level(&gy.youmonst))
tele_to_rnd_pet();
} else {
/* it's magic! it works underwater too (at a higher pitch) */

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 teleport.c $NHDT-Date: 1736129950 2025/01/05 18:19:10 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.235 $ */
/* NetHack 3.7 teleport.c $NHDT-Date: 1769342601 2026/01/25 04:03:21 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.239 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2011. */
/* NetHack may be freely redistributed. See license for details. */
@@ -811,6 +811,12 @@ tele_to_rnd_pet(void)
struct monst *mtmp, *pet = (struct monst *) 0;
int cnt = 0;
if (noteleport_level(&gy.youmonst)) {
impossible("%s", "attempt to teleport hero to be near a pet"
" on no-teleport level");
return;
}
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon)
if (!DEADMONSTER(mtmp) && mtmp->mtame && !mon_offmap(mtmp)) {
cnt++;