W_WEAPON, W_ACCESSORY

Add macros W_WEAPON and W_ACCESSORY, similar to existing W_ARMOR, bitmask
of all the relevant worn bits.  Just for code readability; there should
be no change in behavior.

Also, reformat the "ugly checks" portion of getobj().  Slightly better
readability and fewer continuation lines, but only a modest improvement.
This commit is contained in:
PatR
2015-07-25 19:19:58 -07:00
parent 64dfb4fcc8
commit 9034e2a7e5
10 changed files with 152 additions and 153 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 prop.h $NHDT-Date: 1432512777 2015/05/25 00:12:57 $ $NHDT-Branch: master $:$NHDT-Revision: 1.15 $ */
/* NetHack 3.6 prop.h $NHDT-Date: 1437877163 2015/07/26 02:19:23 $ $NHDT-Branch: master $:$NHDT-Revision: 1.16 $ */
/* Copyright (c) 1989 Mike Threepoint */
/* NetHack may be freely redistributed. See license for details. */
@@ -100,14 +100,18 @@ struct prop {
#define W_WEP 0x00000100L /* Wielded weapon */
#define W_QUIVER 0x00000200L /* Quiver for (f)iring ammo */
#define W_SWAPWEP 0x00000400L /* Secondary weapon */
#define W_WEAPON (W_WEP | W_SWAPWEP | W_QUIVER)
#define W_ART 0x00001000L /* Carrying artifact (not really worn) */
#define W_ARTI 0x00002000L /* Invoked artifact (not really worn) */
/* Amulets, rings, tools, and other items */
/* Amulets, rings, tools, and other items */
#define W_AMUL 0x00010000L /* Amulet */
#define W_RINGL 0x00020000L /* Left ring */
#define W_RINGR 0x00040000L /* Right ring */
#define W_RING (W_RINGL | W_RINGR)
#define W_TOOL 0x00080000L /* Eyewear */
#define W_ACCESSORY (W_RING | W_AMUL | W_TOOL)
/* historical note: originally in slash'em, 'worn' saddle stayed in
hero's inventory; in nethack, it's kept in the steed's inventory */
#define W_SADDLE 0x00100000L /* KMH -- For riding monsters */
#define W_BALL 0x00200000L /* Punishment ball */
#define W_CHAIN 0x00400000L /* Punishment chain */

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 do.c $NHDT-Date: 1436057350 2015/07/05 00:49:10 $ $NHDT-Branch: master $:$NHDT-Revision: 1.146 $ */
/* NetHack 3.6 do.c $NHDT-Date: 1437877173 2015/07/26 02:19:33 $ $NHDT-Branch: master $:$NHDT-Revision: 1.147 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -482,7 +482,7 @@ canletgo(obj, word)
struct obj *obj;
const char *word;
{
if (obj->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL)) {
if (obj->owornmask & (W_ARMOR | W_ACCESSORY)) {
if (*word)
Norep("You cannot %s %s you are wearing.", word, something);
return (FALSE);

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 do_wear.c $NHDT-Date: 1433289458 2015/06/02 23:57:38 $ $NHDT-Branch: master $:$NHDT-Revision: 1.82 $ */
/* NetHack 3.6 do_wear.c $NHDT-Date: 1437877177 2015/07/26 02:19:37 $ $NHDT-Branch: master $:$NHDT-Revision: 1.83 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1069,7 +1069,7 @@ register struct obj *otmp;
boolean already_blind = Blind, changed = FALSE;
/* blindfold might be wielded; release it for wearing */
if (otmp->owornmask & (W_WEP | W_SWAPWEP | W_QUIVER))
if (otmp->owornmask & W_WEAPON)
remove_worn_item(otmp, FALSE);
setworn(otmp, W_TOOL);
on_msg(otmp);
@@ -1414,7 +1414,7 @@ doremring()
otmp = getobj(accessories, "remove");
if (!otmp)
return 0;
if (!(otmp->owornmask & (W_RING | W_AMUL | W_TOOL))) {
if (!(otmp->owornmask & W_ACCESSORY)) {
You("are not wearing that.");
return 0;
}
@@ -1742,7 +1742,7 @@ dowear()
otmp->known = 1; /* since AC is shown on the status line */
/* if the armor is wielded, release it for wearing */
if (otmp->owornmask & (W_WEP | W_SWAPWEP | W_QUIVER))
if (otmp->owornmask & W_WEAPON)
remove_worn_item(otmp, FALSE);
setworn(otmp, mask);
delay = -objects[otmp->otyp].oc_delay;
@@ -1781,13 +1781,13 @@ doputon()
Your("%s%s are full, and you're already wearing an amulet and %s.",
humanoid(youmonst.data) ? "ring-" : "",
makeplural(body_part(FINGER)),
ublindf->otyp == LENSES ? "some lenses" : "a blindfold");
(ublindf->otyp == LENSES) ? "some lenses" : "a blindfold");
return (0);
}
otmp = getobj(accessories, "put on");
if (!otmp)
return (0);
if (otmp->owornmask & (W_RING | W_AMUL | W_TOOL)) {
if (otmp->owornmask & W_ACCESSORY) {
already_wearing(c_that_);
return (0);
}
@@ -1795,12 +1795,10 @@ doputon()
weldmsg(otmp);
return (0);
}
#if 0
/* defer til Xxx_on(); various failures below now leave item wielded
*/
/* accessory might be wielded; release it for wearing */
if (otmp->owornmask & (W_WEP|W_SWAPWEP|W_QUIVER))
remove_worn_item(otmp, FALSE);
#if 0 /* defer til Xxx_on(); various failures below now leave item wielded */
/* accessory might be wielded; release it for wearing */
if (otmp->owornmask & W_WEAPON)
remove_worn_item(otmp, FALSE);
#endif
if (otmp->oclass == RING_CLASS || otmp->otyp == MEAT_RING) {
@@ -2406,7 +2404,7 @@ doddoremarm()
possibly combined with weapons */
(void) strncpy(context.takeoff.disrobing, "disrobing", CONTEXTVERBSZ);
/* specific activity when handling weapons only */
if (!(context.takeoff.mask & ~(W_WEP | W_SWAPWEP | W_QUIVER)))
if (!(context.takeoff.mask & ~W_WEAPON))
(void) strncpy(context.takeoff.disrobing, "disarming",
CONTEXTVERBSZ);
(void) take_off();

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 invent.c $NHDT-Date: 1436753515 2015/07/13 02:11:55 $ $NHDT-Branch: master $:$NHDT-Revision: 1.168 $ */
/* NetHack 3.6 invent.c $NHDT-Date: 1437877178 2015/07/26 02:19:38 $ $NHDT-Branch: master $:$NHDT-Revision: 1.169 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1014,26 +1014,26 @@ register const char *let, *word;
register int otyp = otmp->otyp;
bp[foo++] = otmp->invlet;
/* clang-format off */
/* *INDENT-OFF* */
/* ugly check: remove inappropriate things */
if ((taking_off(word)
&& !(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 */
#if 0 /* 3.4.1 -- include currently wielded weapon among the choices */
|| (!strcmp(word, "wield") &&
(otmp->owornmask & W_WEP))
if (
(taking_off(word) /* exclude if not worn */
&& !(otmp->owornmask & (W_ARMOR | W_ACCESSORY)))
|| (putting_on(word) /* exclude if already worn */
&& (otmp->owornmask & (W_ARMOR | W_ACCESSORY)))
#if 0 /* 3.4.1 -- include currently wielded weapon among 'wield' choices */
|| (!strcmp(word, "wield")
&& (otmp->owornmask & W_WEP))
#endif
|| (!strcmp(word, "ready")
&& (otmp == uwep || (otmp == uswapwep && u.twoweap)))
|| ((!strcmp(word, "dip") || !strcmp(word, "grease"))
&& inaccessible_equipment(otmp, (const char *) 0,
FALSE))) {
|| (!strcmp(word, "ready") /* exclude if wielded */
&& (otmp == uwep || (otmp == uswapwep && u.twoweap)))
|| ((!strcmp(word, "dip") || !strcmp(word, "grease"))
&& inaccessible_equipment(otmp, (const char *) 0, FALSE))
) {
foo--;
foox++;
}
/* Second ugly check; unlike the first it won't trigger an
* "else" in "you don't have anything else to ___".
*/
@@ -1042,89 +1042,93 @@ register const char *let, *word;
&& ((otmp->oclass == FOOD_CLASS && otmp->otyp != MEAT_RING)
|| (otmp->oclass == TOOL_CLASS && otyp != BLINDFOLD
&& otyp != TOWEL && otyp != LENSES)))
|| (!strcmp(word, "wield")
&& (otmp->oclass == TOOL_CLASS && !is_weptool(otmp)))
|| (!strcmp(word, "eat") && !is_edible(otmp))
|| (!strcmp(word, "sacrifice")
&& (otyp != CORPSE && otyp != AMULET_OF_YENDOR
&& otyp != FAKE_AMULET_OF_YENDOR))
|| (!strcmp(word, "write with")
&& (otmp->oclass == TOOL_CLASS && otyp != MAGIC_MARKER
&& otyp != TOWEL))
|| (!strcmp(word, "tin")
&& (otyp != CORPSE || !tinnable(otmp)))
|| (!strcmp(word, "rub")
&& ((otmp->oclass == TOOL_CLASS && otyp != OIL_LAMP
&& otyp != MAGIC_LAMP && otyp != BRASS_LANTERN)
|| (otmp->oclass == GEM_CLASS
&& !is_graystone(otmp))))
|| ((!strcmp(word, "use or apply")
|| !strcmp(word, "untrap with")) &&
/* Picks, axes, pole-weapons, bullwhips */
((otmp->oclass == WEAPON_CLASS && !is_pick(otmp)
&& !is_axe(otmp) && !is_pole(otmp) && otyp != BULLWHIP)
|| (otmp->oclass == POTION_CLASS &&
/* only applicable potion is oil, and it will only
be offered as a choice when already discovered */
(otyp != POT_OIL || !otmp->dknown
|| !objects[POT_OIL].oc_name_known))
|| (otmp->oclass == FOOD_CLASS && otyp != CREAM_PIE
&& otyp != EUCALYPTUS_LEAF)
|| (!strcmp(word, "wield")
&& (otmp->oclass == TOOL_CLASS && !is_weptool(otmp)))
|| (!strcmp(word, "eat") && !is_edible(otmp))
|| (!strcmp(word, "sacrifice")
&& (otyp != CORPSE && otyp != AMULET_OF_YENDOR
&& otyp != FAKE_AMULET_OF_YENDOR))
|| (!strcmp(word, "write with")
&& (otmp->oclass == TOOL_CLASS
&& otyp != MAGIC_MARKER && otyp != TOWEL))
|| (!strcmp(word, "tin")
&& (otyp != CORPSE || !tinnable(otmp)))
|| (!strcmp(word, "rub")
&& ((otmp->oclass == TOOL_CLASS && otyp != OIL_LAMP
&& otyp != MAGIC_LAMP && otyp != BRASS_LANTERN)
|| (otmp->oclass == GEM_CLASS && !is_graystone(otmp))))
|| (!strcmp(word, "invoke")
&& (!otmp->oartifact && !objects[otyp].oc_unique
&& (otyp != FAKE_AMULET_OF_YENDOR || otmp->known)
&& otyp != CRYSTAL_BALL
&& /* #invoke synonym for apply */
/* note: presenting the possibility of invoking
non-artifact
mirrors and/or lamps is a simply a cruel
deception... */
otyp != MIRROR
&& otyp != MAGIC_LAMP
&& (otyp != OIL_LAMP
|| /* don't list known oil lamp */
(otmp->dknown
&& objects[OIL_LAMP].oc_name_known))))
|| (!strcmp(word, "untrap with")
&& (otmp->oclass == TOOL_CLASS && otyp != CAN_OF_GREASE))
|| (!strcmp(word, "tip") && !Is_container(otmp) &&
/* include horn of plenty if sufficiently discovered */
(otmp->otyp != HORN_OF_PLENTY || !otmp->dknown
|| (!strcmp(word, "use or apply")
/* Picks, axes, pole-weapons, bullwhips */
&& ((otmp->oclass == WEAPON_CLASS
&& !is_pick(otmp) && !is_axe(otmp)
&& !is_pole(otmp) && otyp != BULLWHIP)
|| (otmp->oclass == POTION_CLASS
/* only applicable potion is oil, and it will only
be offered as a choice when already discovered */
&& (otyp != POT_OIL || !otmp->dknown
|| !objects[POT_OIL].oc_name_known))
|| (otmp->oclass == FOOD_CLASS
&& otyp != CREAM_PIE && otyp != EUCALYPTUS_LEAF)
|| (otmp->oclass == GEM_CLASS && !is_graystone(otmp))))
|| (!strcmp(word, "invoke")
&& !otmp->oartifact
&& !objects[otyp].oc_unique
&& (otyp != FAKE_AMULET_OF_YENDOR || otmp->known)
&& otyp != CRYSTAL_BALL /* synonym for apply */
/* note: presenting the possibility of invoking non-artifact
mirrors and/or lamps is simply a cruel deception... */
&& otyp != MIRROR
&& otyp != MAGIC_LAMP
&& (otyp != OIL_LAMP /* don't list known oil lamp */
|| (otmp->dknown && objects[OIL_LAMP].oc_name_known)))
|| (!strcmp(word, "untrap with")
&& ((otmp->oclass == TOOL_CLASS && otyp != CAN_OF_GREASE)
|| (otmp->oclass == POTION_CLASS
/* only applicable potion is oil, and it will only
be offered as a choice when already discovered */
&& (otyp != POT_OIL || !otmp->dknown
|| !objects[POT_OIL].oc_name_known))))
|| (!strcmp(word, "tip") && !Is_container(otmp)
/* include horn of plenty if sufficiently discovered */
&& (otmp->otyp != HORN_OF_PLENTY || !otmp->dknown
|| !objects[HORN_OF_PLENTY].oc_name_known))
|| (!strcmp(word, "charge") && !is_chargeable(otmp))
|| (!strcmp(word, "call") && !objtyp_is_callable(otyp)))
|| (!strcmp(word, "charge") && !is_chargeable(otmp))
|| (!strcmp(word, "call") && !objtyp_is_callable(otyp))
) {
foo--;
}
/* ugly check for unworn armor that can't be worn */
else if ((putting_on(word) && *let == ARMOR_CLASS
&& !canwearobj(otmp, &dummymask, FALSE))
/* or unsuitable items rubbed on known touchstone */
|| (!strncmp(word, "rub on the stone", 16)
&& *let == GEM_CLASS && otmp->dknown
&& objects[otyp].oc_name_known)
/* suppress corpses on astral, amulets elsewhere */
|| (!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))) {
else if (
(putting_on(word) && *let == ARMOR_CLASS
&& !canwearobj(otmp, &dummymask, FALSE))
/* or unsuitable items rubbed on known touchstone */
|| (!strncmp(word, "rub on the stone", 16)
&& *let == GEM_CLASS && otmp->dknown
&& objects[otyp].oc_name_known)
/* suppress corpses on astral, amulets elsewhere */
|| (!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--;
allowall = TRUE;
*ap++ = otmp->invlet;
}
/* *INDENT-ON* */
/* clang-format on */
} else {
/* "ugly check" for reading fortune cookies, part 2 */
if ((!strcmp(word, "read") && is_readable(otmp)))
allowall = usegold = TRUE;
}
}
bp[foo] = 0;
if (foo == 0 && bp > buf && bp[-1] == ' ')
*--bp = 0;
@@ -1355,17 +1359,17 @@ register struct obj *otmp;
boolean
wearing_armor()
{
return ((boolean)(uarm || uarmc || uarmf || uarmg || uarmh || uarms
|| uarmu));
return (boolean) (uarm || uarmc || uarmf || uarmg
|| uarmh || uarms || uarmu);
}
boolean
is_worn(otmp)
register struct obj *otmp;
struct obj *otmp;
{
return ((boolean)(
!!(otmp->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL | W_SADDLE
| W_WEP | W_SWAPWEP | W_QUIVER))));
return (otmp->owornmask & (W_ARMOR | W_ACCESSORY | W_SADDLE | W_WEAPON))
? TRUE
: FALSE;
}
/* extra xprname() input that askchain() can't pass through safe_qbuf() */
@@ -2923,9 +2927,9 @@ register struct obj *otmp, *obj;
return FALSE;
if (obj->known == otmp->known || !objects[otmp->otyp].oc_uses_known) {
return ((boolean)(objects[obj->otyp].oc_merge));
return (boolean) objects[obj->otyp].oc_merge;
} else
return (FALSE);
return FALSE;
}
int
@@ -3045,8 +3049,8 @@ struct obj *obj;
return TRUE;
if (obj->oclass != TOOL_CLASS)
return FALSE;
return (boolean)(obj == uwep || obj->lamplit
|| (obj->otyp == LEASH && obj->leashmon));
return (boolean) (obj == uwep || obj->lamplit
|| (obj->otyp == LEASH && obj->leashmon));
}
int

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 mhitu.c $NHDT-Date: 1432512772 2015/05/25 00:12:52 $ $NHDT-Branch: master $:$NHDT-Revision: 1.127 $ */
/* NetHack 3.6 mhitu.c $NHDT-Date: 1437877180 2015/07/26 02:19:40 $ $NHDT-Branch: master $:$NHDT-Revision: 1.128 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -813,7 +813,7 @@ struct monst *mon;
continue;
/* omit W_SWAPWEP+W_QUIVER; W_ART+W_ARTI handled by protects() */
wearmask = W_ARMOR | W_RING | W_AMUL | W_TOOL;
wearmask = W_ARMOR | W_ACCESSORY;
if (o->oclass == WEAPON_CLASS || is_weptool(o))
wearmask |= W_WEP;
if (protects(o, ((o->owornmask & wearmask) != 0L) ? TRUE : FALSE))
@@ -827,9 +827,9 @@ struct monst *mon;
} else if (mc < 1) {
/* intrinsic Protection is weaker (play balance; obtaining divine
protection is too easy); it confers minimum mc 1 instead of 0 */
if ((is_you && ((HProtection && u.ublessed) || u.uspellprot)) ||
if ((is_you && ((HProtection && u.ublessed) || u.uspellprot))
/* aligned priests and angels have innate intrinsic Protection */
(mon->data == &mons[PM_ALIGNED_PRIEST] || is_minion(mon->data)))
|| (mon->data == &mons[PM_ALIGNED_PRIEST] || is_minion(mon->data)))
mc = 1;
}
return mc;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 mkobj.c $NHDT-Date: 1436753518 2015/07/13 02:11:58 $ $NHDT-Branch: master $:$NHDT-Revision: 1.103 $ */
/* NetHack 3.6 mkobj.c $NHDT-Date: 1437877180 2015/07/26 02:19:40 $ $NHDT-Branch: master $:$NHDT-Revision: 1.104 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -2290,8 +2290,9 @@ struct obj *obj;
++n;
allmask |= wearbits[i];
}
if (n == 2 && carried(obj) && obj == uball && (owornmask & W_BALL) != 0L
&& (owornmask & (W_WEP | W_SWAPWEP | W_QUIVER)) != 0L) {
if (n == 2 && carried(obj)
&& obj == uball && (owornmask & W_BALL) != 0L
&& (owornmask & W_WEAPON) != 0L) {
/* chained ball can be wielded/alt-wielded/quivered; if so,
pretend it's not chained in order to check the weapon pointer
(we've already verified the ball pointer by successfully passing
@@ -2396,7 +2397,7 @@ struct obj *obj;
if (owornmask & W_ARMOR) {
if (obj->oclass != ARMOR_CLASS)
what = "armor";
} else if (owornmask & (W_WEP | W_SWAPWEP | W_QUIVER)) {
} else if (owornmask & W_WEAPON) {
/* monsters don't maintain alternate weapon or quiver */
if (mcarried(obj) && (owornmask & (W_SWAPWEP | W_QUIVER)) != 0L)
what = (owornmask & W_SWAPWEP) != 0L ? "monst alt weapon?"

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 mondata.c $NHDT-Date: 1433117881 2015/06/01 00:18:01 $ $NHDT-Branch: master $:$NHDT-Revision: 1.54 $ */
/* NetHack 3.6 mondata.c $NHDT-Date: 1437877181 2015/07/26 02:19:41 $ $NHDT-Branch: master $:$NHDT-Revision: 1.55 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -115,7 +115,7 @@ struct monst *mon;
return TRUE;
/* check for magic resistance granted by worn or carried items */
o = is_you ? invent : mon->minvent;
slotmask = W_ARMOR | W_RING | W_AMUL | W_TOOL;
slotmask = W_ARMOR | W_ACCESSORY;
if (!is_you || /* assumes monsters don't wield non-weapons */
(uwep && (uwep->oclass == WEAPON_CLASS || is_weptool(uwep))))
slotmask |= W_WEP;
@@ -153,7 +153,7 @@ struct monst *mon;
if (o && o->oartifact && defends(AD_BLND, o))
return TRUE;
o = is_you ? invent : mon->minvent;
slotmask = W_ARMOR | W_RING | W_AMUL | W_TOOL;
slotmask = W_ARMOR | W_ACCESSORY;
if (!is_you || /* assumes monsters don't wield non-weapons */
(uwep && (uwep->oclass == WEAPON_CLASS || is_weptool(uwep))))
slotmask |= W_WEP;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 pickup.c $NHDT-Date: 1434507811 2015/06/17 02:23:31 $ $NHDT-Branch: master $:$NHDT-Revision: 1.159 $ */
/* NetHack 3.6 pickup.c $NHDT-Date: 1437877182 2015/07/26 02:19:42 $ $NHDT-Branch: master $:$NHDT-Revision: 1.160 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -437,9 +437,8 @@ boolean
is_worn_by_type(otmp)
register struct obj *otmp;
{
return ((boolean)(!!(otmp->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL
| W_WEP | W_SWAPWEP | W_QUIVER)))
&& (index(valid_menu_classes, otmp->oclass) != (char *) 0));
return (boolean) (!!(otmp->owornmask & (W_ARMOR | W_ACCESSORY | W_WEAPON))
&& index(valid_menu_classes, otmp->oclass) != 0);
}
/*
@@ -979,8 +978,7 @@ int how; /* type of query */
&& !(qflags & BILLED_TYPES)) {
for (curr = olist; curr; curr = FOLLOW(curr, qflags)) {
if ((qflags & WORN_TYPES)
&& !(curr->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL
| W_WEP | W_SWAPWEP | W_QUIVER)))
&& !(curr->owornmask & (W_ARMOR | W_ACCESSORY | W_WEAPON)))
continue;
break;
}
@@ -1012,8 +1010,7 @@ int how; /* type of query */
for (curr = olist; curr; curr = FOLLOW(curr, qflags)) {
if (curr->oclass == *pack) {
if ((qflags & WORN_TYPES)
&& !(curr->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL
| W_WEP | W_SWAPWEP | W_QUIVER)))
&& !(curr->owornmask & (W_ARMOR | W_ACCESSORY | W_WEAPON)))
continue;
if (!collected_type_name) {
any = zeroany;
@@ -1113,8 +1110,7 @@ int qflags;
for (curr = olist; curr; curr = FOLLOW(curr, qflags)) {
if (curr->oclass == *pack) {
if ((qflags & WORN_TYPES)
&& !(curr->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL
| W_WEP | W_SWAPWEP | W_QUIVER)))
&& !(curr->owornmask & (W_ARMOR | W_ACCESSORY | W_WEAPON)))
continue;
if (!counted_category) {
ccount++;
@@ -1938,7 +1934,7 @@ register struct obj *obj;
} else if (obj == current_container) {
pline("That would be an interesting topological exercise.");
return 0;
} else if (obj->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL)) {
} else if (obj->owornmask & (W_ARMOR | W_ACCESSORY)) {
Norep("You cannot %s %s you are wearing.",
Icebox ? "refrigerate" : "stash", something);
return 0;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 steal.c $NHDT-Date: 1432512772 2015/05/25 00:12:52 $ $NHDT-Branch: master $:$NHDT-Revision: 1.59 $ */
/* NetHack 3.6 steal.c $NHDT-Date: 1437877184 2015/07/26 02:19:44 $ $NHDT-Branch: master $:$NHDT-Revision: 1.62 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -24,11 +24,12 @@ register struct obj *otmp;
? cloak_simple_name(otmp)
: (otmp == uarmh)
? helm_simple_name(otmp)
: "armor");
: suit_simple_name(otmp));
}
long /* actually returns something that fits in an int */
somegold(lmoney)
/* proportional subset of gold; return value actually fits in an int */
long
somegold(lmoney)
long lmoney;
{
#ifdef LINT /* long conv. ok */
@@ -215,7 +216,7 @@ boolean unchain_ball; /* whether to unpunish or just unwield */
Ring_gone(obj);
} else if (obj->owornmask & W_TOOL) {
Blindf_off(obj);
} else if (obj->owornmask & (W_WEP | W_SWAPWEP | W_QUIVER)) {
} else if (obj->owornmask & W_WEAPON) {
if (obj == uwep)
uwepgone();
if (obj == uswapwep)
@@ -287,20 +288,17 @@ retry:
for (otmp = invent; otmp; otmp = otmp->nobj)
if ((!uarm || otmp != uarmc) && otmp != uskin
&& otmp->oclass != COIN_CLASS)
tmp += ((otmp->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL))
? 5
: 1);
tmp += (otmp->owornmask & (W_ARMOR | W_ACCESSORY)) ? 5 : 1;
if (!tmp)
goto nothing_to_steal;
tmp = rn2(tmp);
for (otmp = invent; otmp; otmp = otmp->nobj)
if ((!uarm || otmp != uarmc) && otmp != uskin
&& otmp->oclass != COIN_CLASS)
if ((tmp -=
((otmp->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL))
? 5
: 1)) < 0)
&& otmp->oclass != COIN_CLASS) {
tmp -= (otmp->owornmask & (W_ARMOR | W_ACCESSORY)) ? 5 : 1;
if (tmp < 0)
break;
}
if (!otmp) {
impossible("Steal fails!");
return (0);
@@ -374,7 +372,7 @@ gotobj:
/* you're going to notice the theft... */
stop_occupation();
if ((otmp->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL))) {
if (otmp->owornmask & (W_ARMOR | W_ACCESSORY)) {
switch (otmp->oclass) {
case TOOL_CLASS:
case AMULET_CLASS:

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 wield.c $NHDT-Date: 1436753528 2015/07/13 02:12:08 $ $NHDT-Branch: master $:$NHDT-Revision: 1.43 $ */
/* NetHack 3.6 wield.c $NHDT-Date: 1437877186 2015/07/26 02:19:46 $ $NHDT-Branch: master $:$NHDT-Revision: 1.44 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -273,8 +273,7 @@ dowield()
return (doswapweapon());
else if (wep == uquiver)
setuqwep((struct obj *) 0);
else if (wep->owornmask
& (W_ARMOR | W_RING | W_AMUL | W_TOOL | W_SADDLE)) {
else if (wep->owornmask & (W_ARMOR | W_ACCESSORY | W_SADDLE)) {
You("cannot wield that!");
return (0);
}
@@ -370,8 +369,7 @@ dowieldquiver()
pline("%s already being used as a weapon!",
!is_plural(uwep) ? "That is" : "They are");
return (0);
} else if (newquiver->owornmask
& (W_ARMOR | W_RING | W_AMUL | W_TOOL | W_SADDLE)) {
} else if (newquiver->owornmask & (W_ARMOR | W_ACCESSORY | W_SADDLE)) {
You("cannot ready that!");
return (0);
} else {
@@ -416,7 +414,7 @@ const char *verb; /* "rub",&c */
more_than_1 = (obj->quan > 1L || strstri(what, "pair of ") != 0
|| strstri(what, "s of ") != 0);
if (obj->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL)) {
if (obj->owornmask & (W_ARMOR | W_ACCESSORY)) {
You_cant("%s %s while wearing %s.", verb, yname(obj),
more_than_1 ? "them" : "it");
return FALSE;