]> granicus.if.org Git - nethack/commitdiff
'R' behavior for rings (trunk only)
authornethack.rankin <nethack.rankin>
Fri, 25 Jan 2008 02:54:51 +0000 (02:54 +0000)
committernethack.rankin <nethack.rankin>
Fri, 25 Jan 2008 02:54:51 +0000 (02:54 +0000)
     A bug in some post-3.4.3 code made attempting to remove a worn ring
when wearing two skip inventory the selection and give "you don't have
anything else to remove" if you were wearing gloves and weren't wearing
an amulet or blindfold.  The intent was that rings wouldn't be included
as likely candidates in the list of inventory letters to choose from if
you were wearing cursed gloves, but had a copy+paste mistake in the
argument controlling whether to consider the gloves curse state and was
in the wrong section of getobj()'s "ugly hacks".  Also, it makes more
sense to require that the player know that those gloves are cursed, so
inaccessibe_equipment() got changed too.  [Not knowing that the gloves
are cursed leaves rings listed as candidates; picking a ring will get
removal failure feedback later and mark the gloves as known cursed then.]

src/do_wear.c
src/invent.c

index 8ce78939be1fc1371bc5bccadf1025f9081bb8ae..27050679e77cb61c4bf38b4bb8b6b51b9ea0f8ac 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)do_wear.c  3.5     2007/05/16      */
+/*     SCCS Id: @(#)do_wear.c  3.5     2008/01/23      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -2238,19 +2238,21 @@ register schar delta;
    used for dipping into liquid and applying grease;
    some criteria are different than select_off()'s */
 boolean
-inaccessible_equipment(obj, verb, only_if_cursed)
+inaccessible_equipment(obj, verb, only_if_known_cursed)
 struct obj *obj;
 const char *verb;      /* "dip" or "grease", or null to avoid messages */
-boolean only_if_cursed;        /* true => ignore non-cursed covering gear */
+boolean only_if_known_cursed;  /* ignore covering unless known to be cursed */
 {
     static NEARDATA const char need_to_take_off_outer_armor[] =
                                        "need to take off %s to %s %s.";
     char buf[BUFSZ];
+    boolean anycovering = !only_if_known_cursed; /* more comprehensible... */
+#define BLOCKSACCESS(x)                (anycovering || ((x)->cursed && (x)->bknown))
 
     if (!obj || !obj->owornmask) return FALSE; /* not inaccessible */
 
     /* check for suit covered by cloak */
-    if (obj == uarm && uarmc && (uarmc->cursed || !only_if_cursed)) {
+    if (obj == uarm && uarmc && BLOCKSACCESS(uarmc)) {
        if (verb) {
            Strcpy(buf, yname(uarmc));
            You(need_to_take_off_outer_armor, buf, verb, yname(obj));
@@ -2259,8 +2261,8 @@ boolean only_if_cursed;   /* true => ignore non-cursed covering gear */
     }
 #ifdef TOURIST
     /* check for shirt covered by suit and/or cloak */
-    if (obj == uarmu && ((uarm && (uarm->cursed || !only_if_cursed)) ||
-           (uarmc && (uarmc->cursed || !only_if_cursed)))) {
+    if (obj == uarmu && ((uarm && BLOCKSACCESS(uarm)) ||
+                        (uarmc && BLOCKSACCESS(uarmc)))) {
        if (verb) {
            char cloaktmp[QBUFSZ], suittmp[QBUFSZ];
            /* if sameprefix, use yname and xname to get "your cloak and suit"
@@ -2280,8 +2282,7 @@ boolean only_if_cursed;   /* true => ignore non-cursed covering gear */
     }
 #endif
     /* check for ring covered by gloves */
-    if ((obj == uleft || obj == uright) &&
-           uarmg && (uarmg->cursed || !only_if_cursed)) {
+    if ((obj == uleft || obj == uright) && uarmg && BLOCKSACCESS(uarmg)) {
        if (verb) {
            Strcpy(buf, yname(uarmg));
            You(need_to_take_off_outer_armor, buf, verb, yname(obj));
index 87a6e96a1ce2fd88e51a0a73273e55a3f21b7b78..c98c2fe5d01748048ba2b563f2fed6107f382eb7 100644 (file)
@@ -901,8 +901,7 @@ register const char *let,*word;
 
                /* ugly check: remove inappropriate things */
                if ((taking_off(word) &&
-                   (!(otmp->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL))
-                    || inaccessible_equipment(otmp, (const char *)0, FALSE)))
+                   !(otmp->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL)))
                || (putting_on(word) &&
                     (otmp->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL)))
                                                        /* already worn */
@@ -985,7 +984,11 @@ register const char *let,*word;
                || (!strcmp(word, "sacrifice") &&
                    /* (!astral && amulet) || (astral && !amulet) */
                    (!Is_astralevel(&u.uz) ^ (otmp->oclass != AMULET_CLASS)))
+               /* suppress container being stashed into */
                || (!strcmp(word, "stash") && !ck_bag(otmp))
+               /* worn armor or accessory covered by cursed worn armor */
+               || (taking_off(word) &&
+                   inaccessible_equipment(otmp, (const char *)0, TRUE))
                    ) {
                        /* acceptable but not listed as likely candidate */
                        foo--;