From: PatR Date: Thu, 6 May 2021 18:42:14 +0000 (-0700) Subject: fix github issue #503 - bad Magic Key logic X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=86120d45747b9fe22b689f31a8ceef7fd3da36c8;p=nethack fix github issue #503 - bad Magic Key logic 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 --- diff --git a/doc/fixes37.0 b/doc/fixes37.0 index ecae26886..fe805db69 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -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 , while {paralyzed|frozen} by " 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 diff --git a/src/artifact.c b/src/artifact.c index 1202369e1..c50b7c426 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -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; }