From f3a5f4e61da527aa69c972a1beb86af5522d16c1 Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Sun, 22 Oct 2006 03:53:50 +0000 Subject: [PATCH] unhiding during summoning According to a newsgroup followup, a hidden pet summoned via magic whistle could produce the same effect as the level change case (where sometimes the glyph for unseen monster would appear unexpectedly). I was unable to reproduce this one, but I don't see anything in the code to deal with the situation, so I suspect that the monster is moving immediately and being revealed before I have a chance to notice anything odd. I assume that other situations where hidden monsters get teleported are being handled as attacks which expose them. At least I hope so. --- doc/fixes34.4 | 2 +- src/apply.c | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/doc/fixes34.4 b/doc/fixes34.4 index 2e0c416fc..6e3348a13 100644 --- a/doc/fixes34.4 +++ b/doc/fixes34.4 @@ -263,7 +263,7 @@ try harder to keep dragged chain between ball and hero fireproof containers should not burn in lava fix invalid pointer dereference after applying a wielded cream pie avoid drowned in a drowning and burned by burning if life-saving is inadequate -hidden monsters who change levels come out of hiding in the process +reveal hidden monsters who change levels or are magically summoned Platform- and/or Interface-Specific Fixes diff --git a/src/apply.c b/src/apply.c index bbe57d5a6..416c65f87 100644 --- a/src/apply.c +++ b/src/apply.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)apply.c 3.5 2006/07/08 */ +/* SCCS Id: @(#)apply.c 3.5 2006/10/21 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -409,7 +409,8 @@ struct obj *obj; Underwater ? "very " : ""); wake_nearby(); } else { - int pet_cnt = 0; + int pet_cnt = 0, omx, omy; + /* it's magic! it works underwater too (at a higher pitch) */ You(whistle_str, Hallucination ? "normal" : Underwater ? "strange, high-pitched" : "strange"); @@ -422,9 +423,16 @@ struct obj *obj; mtmp->mtrapped = 0; fill_pit(mtmp->mx, mtmp->my); } + /* mimic must be revealed before we know whether it + actually moves because line-of-sight may change */ + if (mtmp->m_ap_type) seemimic(mtmp); + omx = mtmp->mx, omy = mtmp->my; mnexto(mtmp); - if (canspotmon(mtmp)) ++pet_cnt; - if (mintrap(mtmp) == 2) change_luck(-1); + if (mtmp->mx != omx || mtmp->my != omy) { + mtmp->mundetected = 0; /* reveal non-mimic hider */ + if (canspotmon(mtmp)) ++pet_cnt; + if (mintrap(mtmp) == 2) change_luck(-1); + } } } if (pet_cnt > 0) makeknown(obj->otyp);