-/* NetHack 3.6 objnam.c $NHDT-Date: 1521377345 2018/03/18 12:49:05 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.194 $ */
+/* NetHack 3.6 objnam.c $NHDT-Date: 1521507553 2018/03/20 00:59:13 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.199 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
{ "grapnel", GRAPPLING_HOOK },
{ "grapple", GRAPPLING_HOOK },
{ "protection from shape shifters", RIN_PROTECTION_FROM_SHAPE_CHAN },
+ /* if we ever add other sizes, move this to o_ranges[] with "bag" */
+ { "box", LARGE_BOX },
/* normally we wouldn't have to worry about unnecessary <space>, but
" stone" will get stripped off, preventing a wishymatch; that actually
lets "flint stone" be a match, so we also accept bogus "flintstone" */
register struct obj *otmp;
int cnt, spe, spesgn, typ, very, rechrg;
int blessed, uncursed, iscursed, ispoisoned, isgreased;
- int eroded, eroded2, erodeproof;
+ int eroded, eroded2, erodeproof, locked, unlocked, broken;
int halfeaten, mntmp, contents;
int islit, unlabeled, ishistoric, isdiluted, trapped;
int tmp, tinv, tvariety;
char *un, *dn, *actualn, *origbp = bp;
const char *name = 0;
- cnt = spe = spesgn = typ = very = rechrg = blessed = uncursed = iscursed =
- ispoisoned = isgreased = eroded = eroded2 = erodeproof = halfeaten =
- islit = unlabeled = ishistoric = isdiluted = trapped = 0;
+ cnt = spe = spesgn = typ = 0;
+ very = rechrg = blessed = uncursed = iscursed = ispoisoned =
+ isgreased = eroded = eroded2 = erodeproof = halfeaten =
+ islit = unlabeled = ishistoric = isdiluted = trapped =
+ locked = unlocked = broken = 0;
tvariety = RANDOM_TIN;
mntmp = NON_PM;
#define UNDEFINED 0
trapped = 1;
} else if (!strncmpi(bp, "untrapped ", l = 10)) {
trapped = 2; /* not trapped */
+ /* locked, unlocked, broken: box/chest lock states */
+ } else if (!strncmpi(bp, "locked ", l = 7)) {
+ locked = 1, unlocked = broken = 0;
+ } else if (!strncmpi(bp, "unlocked ", l = 9)) {
+ unlocked = 1, locked = broken = 0;
+ } else if (!strncmpi(bp, "broken ", l = 7)) {
+ broken = 1, locked = unlocked = 0;
} else if (!strncmpi(bp, "greased ", l = 8)) {
isgreased = 1;
} else if (!strncmpi(bp, "very ", l = 5)) {
; /* avoid false hit on "* glass" */
} else if (!BSTRCMPI(bp, p - 6, " glass") || !strcmpi(bp, "glass")) {
register char *g = bp;
- if (strstri(g, "broken"))
+
+ /* treat "broken glass" as a non-existent item; since "broken" is
+ also a chest/box prefix it might have been stripped off above */
+ if (broken || strstri(g, "broken"))
return (struct obj *) 0;
if (!strncmpi(g, "worthless ", 10))
g += 10;
if (Is_box(otmp) || typ == TIN)
otmp->otrapped = (trapped == 1);
}
+ /* empty for containers rather than for tins */
+ if (contents == EMPTY) {
+ if (otmp->otyp == BAG_OF_TRICKS || otmp->otyp == HORN_OF_PLENTY) {
+ if (otmp->spe > 0)
+ otmp->spe = 0;
+ } else if (Has_contents(otmp)) {
+ /* this assumes that artifacts can't be randomly generated
+ inside containers */
+ delete_contents(otmp);
+ otmp->owt = weight(otmp);
+ }
+ }
+ /* set locked/unlocked/broken */
+ if (Is_box(otmp)) {
+ if (locked) {
+ otmp->olocked = 1, otmp->obroken = 0;
+ } else if (unlocked) {
+ otmp->olocked = 0, otmp->obroken = 0;
+ } else if (broken) {
+ otmp->olocked = 0, otmp->obroken = 1;
+ }
+ }
if (isgreased)
otmp->greased = 1;