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 @@
/* 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) */