'R' behavior for rings (trunk only)

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.]
This commit is contained in:
nethack.rankin
2008-01-25 02:54:51 +00:00
parent 5ac69ac845
commit c0b85902a8
2 changed files with 14 additions and 10 deletions

View 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));

View 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--;