From 97cc68955328dddc3d565e68b5dfb39c5fe92c43 Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 31 Jul 2020 13:14:09 -0700 Subject: [PATCH] tin identification Tin handling code used tin->cknown to indicate that the variety (soup, deep fried, pureed, &c) was known, but neither object identification nor end of game disclosure was setting cknown for that type of object. ^I behaves as if cknown is set, so the problem was hidden during times when anyone was likely to be paying attention. --- doc/fixes37.0 | 4 +++- include/extern.h | 3 ++- include/obj.h | 5 +++-- src/end.c | 5 ++--- src/invent.c | 19 ++++++++++++++++--- 5 files changed, 26 insertions(+), 10 deletions(-) diff --git a/doc/fixes37.0 b/doc/fixes37.0 index fa8ca4296..c45b6e268 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -1,4 +1,4 @@ -NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.262 $ $NHDT-Date: 1596162338 2020/07/31 02:25:38 $ +NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.264 $ $NHDT-Date: 1596226446 2020/07/31 20:14:06 $ General Fixes and Modified Features ----------------------------------- @@ -236,6 +236,8 @@ uncancel an ice troll if its corpse is put into an ice box; give corpse a splitting a stack of candy bars gave new wrapper text depending upon the obj->o_id value assigned; keep existing text for both halves of stack (side-effect: separate candy bars usually won't merge anymore) +describing tin variety (deep fried, pureed, &c) relied on the 'contents known' + flag but object identification wasn't setting obj->cknown for tins Fixes to 3.7.0-x Problems that Were Exposed Via git Repository diff --git a/include/extern.h b/include/extern.h index cb198ff18..3c2d94dda 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 extern.h $NHDT-Date: 1596162339 2020/07/31 02:25:39 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.852 $ */ +/* NetHack 3.6 extern.h $NHDT-Date: 1596226441 2020/07/31 20:14:01 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.853 $ */ /* Copyright (c) Steve Creps, 1988. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1044,6 +1044,7 @@ E int FDECL(ggetobj, (const char *, int (*)(OBJ_P), int, BOOLEAN_P, unsigned *)); E int FDECL(askchain, (struct obj **, const char *, int, int (*)(OBJ_P), int (*)(OBJ_P), int, const char *)); +E void FDECL(set_cknown_lknown, (struct obj *)); E void FDECL(fully_identify_obj, (struct obj *)); E int FDECL(identify, (struct obj *)); E int FDECL(count_unidentified, (struct obj *)); diff --git a/include/obj.h b/include/obj.h index 9ff6bdc71..39f6c67a5 100644 --- a/include/obj.h +++ b/include/obj.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 obj.h $NHDT-Date: 1596162340 2020/07/31 02:25:40 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.70 $ */ +/* NetHack 3.6 obj.h $NHDT-Date: 1596226442 2020/07/31 20:14:02 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.75 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Michael Allison, 2006. */ /* NetHack may be freely redistributed. See license for details. */ @@ -106,7 +106,8 @@ struct obj { Bitfield(in_use, 1); /* for magic items before useup items */ Bitfield(bypass, 1); /* mark this as an object to be skipped by bhito() */ - Bitfield(cknown, 1); /* contents of container assumed to be known */ + Bitfield(cknown, 1); /* for containers (including statues): the contents + * are known; also applicable to tins */ Bitfield(lknown, 1); /* locked/unlocked status is known */ /* 4 free bits */ diff --git a/src/end.c b/src/end.c index a33e9ef07..fa6295b8b 100644 --- a/src/end.c +++ b/src/end.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 end.c $NHDT-Date: 1583190253 2020/03/02 23:04:13 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.208 $ */ +/* NetHack 3.6 end.c $NHDT-Date: 1596226442 2020/07/31 20:14:02 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.210 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1315,8 +1315,7 @@ int how; for (obj = g.invent; obj; obj = obj->nobj) { discover_object(obj->otyp, TRUE, FALSE); obj->known = obj->bknown = obj->dknown = obj->rknown = 1; - if (Is_container(obj) || obj->otyp == STATUE) - obj->cknown = obj->lknown = 1; + set_cknown_lknown(obj); /* set flags when applicable */ /* we resolve Schroedinger's cat now in case of both disclosure and dumplog, where the 50:50 chance for live cat has to be the same both times */ diff --git a/src/invent.c b/src/invent.c index 0e0ccec8f..e33740ace 100644 --- a/src/invent.c +++ b/src/invent.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 invent.c $NHDT-Date: 1590343765 2020/05/24 18:09:25 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.299 $ */ +/* NetHack 3.7 invent.c $NHDT-Date: 1596226443 2020/07/31 20:14:03 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.300 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2315,6 +2315,20 @@ int FDECL((*fn), (OBJ_P)), FDECL((*ckfn), (OBJ_P)); * Object identification routines: */ +/* set the cknown and lknown flags on an object if they're applicable */ +void +set_cknown_lknown(obj) +struct obj *obj; +{ + if (Is_container(obj) || obj->otyp == STATUE) + obj->cknown = obj->lknown = 1; + else if (obj->otyp == TIN) + obj->cknown = 1; + /* TODO? cknown might be extended to candy bar, where it would mean that + wrapper's text was known which in turn indicates candy bar's content */ + return; +} + /* make an object actually be identified; no display updating */ void fully_identify_obj(otmp) @@ -2324,8 +2338,7 @@ struct obj *otmp; if (otmp->oartifact) discover_artifact((xchar) otmp->oartifact); otmp->known = otmp->dknown = otmp->bknown = otmp->rknown = 1; - if (Is_container(otmp) || otmp->otyp == STATUE) - otmp->cknown = otmp->lknown = 1; + set_cknown_lknown(otmp); /* set otmp->{cknown,lknown} if applicable */ if (otmp->otyp == EGG && otmp->corpsenm != NON_PM) learn_egg_type(otmp->corpsenm); }