]> granicus.if.org Git - nethack/commitdiff
inappropriately sensing humans and elves
authorPatR <rankin@nethack.org>
Fri, 25 Dec 2015 22:24:18 +0000 (14:24 -0800)
committerPatR <rankin@nethack.org>
Fri, 25 Dec 2015 22:24:18 +0000 (14:24 -0800)
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.

doc/fixes36.1
src/cmd.c
src/polyself.c
src/restore.c

index 852ab6ce87dd7b5600481da13c755a128390ba77..f690b1ec36ba3d510ef1299b338198b368da3d16 100644 (file)
@@ -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
index 9ed18debd085c5ee484eded6509303f368f5f9cf..51fd17f7081b695bd3d07a569e5ca14842ce5bff 100644 (file)
--- 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));
index 4cd01d0d6461e75df12511d4eaae8cacfc06b70f..9cdc83be804506cde7097c2af2e8595ebcd94c4d 100644 (file)
@@ -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*/
index d56af4ea6c13956c7007f748a1f8a96582dc6404..509ff6ed918c11ee4166a46d031bd33b54cc9ea5 100644 (file)
@@ -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