]> granicus.if.org Git - nethack/commitdiff
fix github issue #503 - bad Magic Key logic
authorPatR <rankin@nethack.org>
Thu, 6 May 2021 18:42:14 +0000 (11:42 -0700)
committerPatR <rankin@nethack.org>
Thu, 6 May 2021 18:42:14 +0000 (11:42 -0700)
When unlocking a trapped container, any blessed key was behaving
as if it was the rogue's Master Key of Thievery:  detecting the
trap, asking whether to untrap, and always succeeding if player
responds with yes.  The intended behavior is that the Master Key
will behave that way for a rogue if not cursed and for non-rogue
if blessed; it wasn't supposed to affect ordinary keys at all.

Fixes #503

doc/fixes37.0
src/artifact.c

index ecae268868cfd1dbf96a139b125011bf2b035908..fe805db692a3df0e07071228a4c4d0e7636cf0a4 100644 (file)
@@ -1,4 +1,4 @@
-NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.522 $ $NHDT-Date: 1620076691 2021/05/03 21:18:11 $
+NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.524 $ $NHDT-Date: 1620326528 2021/05/06 18:42:08 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -497,6 +497,8 @@ change "killed by <a foo>, while {paralyzed|frozen} by <a foo>" into
        offended an unseen demon lord
 Entering a special room, only wake up the monsters in that room instead of
        doing a level-wide wake-up
+any blessed key was behaving as if was the rogue's Master Key when unlocking
+       a trapped chest or box
 
 
 Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
index 1202369e1fc32716546139942381ced32bfa03b2..c50b7c426547a98e190def8d2938139e9bf6e453 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 artifact.c      $NHDT-Date: 1606765210 2020/11/30 19:40:10 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.161 $ */
+/* NetHack 3.7 artifact.c      $NHDT-Date: 1620326528 2021/05/06 18:42:08 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.167 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2013. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -2151,11 +2151,13 @@ boolean
 is_magic_key(struct monst *mon, /* if null, non-rogue is assumed */
              struct obj *obj)
 {
-    if (((obj && obj->oartifact == ART_MASTER_KEY_OF_THIEVERY)
-         && ((mon == &g.youmonst) ? Role_if(PM_ROGUE)
-                                : (mon && mon->data == &mons[PM_ROGUE])))
-        ? !obj->cursed : obj->blessed)
-        return TRUE;
+    if (obj && obj->oartifact == ART_MASTER_KEY_OF_THIEVERY) {
+        if ((mon == &g.youmonst) ? Role_if(PM_ROGUE)
+                                 : (mon && mon->data == &mons[PM_ROGUE]))
+            return !obj->cursed; /* a rogue; non-cursed suffices for magic */
+        /* not a rogue; key must be blessed to behave as a magic one */
+        return obj->blessed;
+    }
     return FALSE;
 }