From: PatR Date: Fri, 25 Dec 2015 22:24:18 +0000 (-0800) Subject: inappropriately sensing humans and elves X-Git-Tag: NetHack-3.6.1_RC01~1117 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=67826ff67b3eb13d26db70300e1af5a5229d9482;p=nethack inappropriately sensing humans and elves Discovered while testing the from-what enhancements to enlightenment. Polymorphing into a vampire confers the ability to sense humans and elves without having telepathy or being triggered by blindness. That would be taken away if you polymorphed into something else, but was being left in effect if polymorph just timed out and hero returned to normal form. Same thing occurred for sensing shriekers if you poly'd into a purple worm and then reverted to normal (something much less likely to get noticed and not really subject to abuse if it ever did). Bonus fix: the code involved was using 0 to mean that Warn_of_mon from polymorph wasn't in effect, but 0 is also giant ant. This makes it use NON_PM for that instead. --- diff --git a/doc/fixes36.1 b/doc/fixes36.1 index 852ab6ce8..f690b1ec3 100644 --- a/doc/fixes36.1 +++ b/doc/fixes36.1 @@ -60,6 +60,10 @@ actually make the castle chest not trapped level-drain resistance wasn't shown during enlightenment if it was conferred by worn/wielded equipment wizard mode enlightenment now shows more reasons for various intrinsics +rehumanizing after being poly'd into vampire left hero with ability to sense + humans and elves +Warn_of_mon wouldn't have been able to sense giant ants if any creature were + to have that ability, caused by using 0 instead of NON_PM for 'none' Platform- and/or Interface-Specific Fixes diff --git a/src/cmd.c b/src/cmd.c index 9ed18debd..51fd17f70 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 cmd.c $NHDT-Date: 1450473780 2015/12/18 21:23:00 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.211 $ */ +/* NetHack 3.6 cmd.c $NHDT-Date: 1451082253 2015/12/25 22:24:13 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.212 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2040,7 +2040,7 @@ int final; : "certain monsters"); you_are(buf, ""); } - if (Warn_of_mon && context.warntype.speciesidx) { + if (Warn_of_mon && context.warntype.speciesidx >= LOW_PM) { Sprintf(buf, "aware of the presence of %s", makeplural(mons[context.warntype.speciesidx].mname)); you_are(buf, from_what(WARN_OF_MON)); diff --git a/src/polyself.c b/src/polyself.c index 4cd01d0d6..9cdc83be8 100644 --- a/src/polyself.c +++ b/src/polyself.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 polyself.c $NHDT-Date: 1448496566 2015/11/26 00:09:26 $ $NHDT-Branch: master $:$NHDT-Revision: 1.104 $ */ +/* NetHack 3.6 polyself.c $NHDT-Date: 1451082254 2015/12/25 22:24:14 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.105 $ */ /* Copyright (C) 1987, 1988, 1989 by Ken Arromdee */ /* NetHack may be freely redistributed. See license for details. */ @@ -28,7 +28,7 @@ STATIC_DCL void FDECL(drop_weapon, (int)); STATIC_DCL void NDECL(uunstick); STATIC_DCL int FDECL(armor_to_dragon, (int)); STATIC_DCL void NDECL(newman); -STATIC_DCL boolean FDECL(polysense, (struct permonst *)); +STATIC_DCL void NDECL(polysense); STATIC_VAR const char no_longer_petrify_resistant[] = "No longer petrify-resistant, you"; @@ -100,6 +100,8 @@ set_uasmon() #ifdef STATUS_VIA_WINDOWPORT status_initialize(REASSESS_ONLY); #endif + + polysense(); } /* Levitation overrides Flying; set or clear BFlying|I_SPECIAL */ @@ -347,7 +349,6 @@ newman() Strcpy(killer.name, "unsuccessful polymorph"); done(DIED); newuhs(FALSE); - (void) polysense(youmonst.data); return; /* lifesaved */ } } @@ -362,7 +363,6 @@ newman() make_slimed(10L, (const char *) 0); } - (void) polysense(youmonst.data); context.botl = 1; see_monsters(); (void) encumber_msg(); @@ -827,7 +827,6 @@ int mntmp; u.utrap = 0; } check_strangling(TRUE); /* maybe start strangling */ - (void) polysense(youmonst.data); context.botl = 1; vision_full_recalc = 1; @@ -1777,20 +1776,18 @@ int atyp; } } -/* - * Some species have awareness of other species - */ -static boolean -polysense(mptr) -struct permonst *mptr; +/* some species have awareness of other species */ +static void +polysense() { - short warnidx = 0; + short warnidx = NON_PM; - context.warntype.speciesidx = 0; + context.warntype.speciesidx = NON_PM; context.warntype.species = 0; context.warntype.polyd = 0; + HWarn_of_mon &= ~FROMRACE; - switch (monsndx(mptr)) { + switch (u.umonnum) { case PM_PURPLE_WORM: warnidx = PM_SHRIEKER; break; @@ -1798,18 +1795,13 @@ struct permonst *mptr; case PM_VAMPIRE_LORD: context.warntype.polyd = M2_HUMAN | M2_ELF; HWarn_of_mon |= FROMRACE; - return TRUE; + return; } - if (warnidx) { + if (warnidx >= LOW_PM) { context.warntype.speciesidx = warnidx; context.warntype.species = &mons[warnidx]; HWarn_of_mon |= FROMRACE; - return TRUE; } - context.warntype.speciesidx = 0; - context.warntype.species = 0; - HWarn_of_mon &= ~FROMRACE; - return FALSE; } /*polyself.c*/ diff --git a/src/restore.c b/src/restore.c index d56af4ea6..509ff6ed9 100644 --- a/src/restore.c +++ b/src/restore.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 restore.c $NHDT-Date: 1450231174 2015/12/16 01:59:34 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.102 $ */ +/* NetHack 3.6 restore.c $NHDT-Date: 1451082255 2015/12/25 22:24:15 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.103 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -531,7 +531,7 @@ unsigned int *stuckid, *steedid; return FALSE; } mread(fd, (genericptr_t) &context, sizeof(struct context_info)); - if (context.warntype.speciesidx) + if (context.warntype.speciesidx >= LOW_PM) context.warntype.species = &mons[context.warntype.speciesidx]; /* we want to be able to revert to command line/environment/config