From fb043c5f01d3b0d9c2f65634de3c081f71510bed Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Sun, 27 Jan 2008 02:06:18 +0000 Subject: [PATCH] inventory display after regaining sight (trunk only) I suspect--but have no way to test--that there is a subtle difference in game play between perm_invent and !perm_invent involving object merging or other activity that depends on whether or not object->dknown is set. For objects pickup up while blind, where object->dknown is left as is, the perm_invent config would have such items marked as seen sooner (since there are umpteen places that call update_inventory() which will end up setting the seen bit while formatting objects). Non-perm_invent wouldn't have that done until the user examines invent (or asks to see a list of objects at the "which object?" prompt for various commands). This patch effectively examines inventory whenever blindness ends, so both modes get dknown set as soon as possible. And if we ever add an "effect known" flag for unseen objects which are used while blind, this would be a suitable place to perform deferred object discovery. --- include/extern.h | 5 +++-- src/invent.c | 21 +++++++++++++++++++++ src/potion.c | 3 +++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/include/extern.h b/include/extern.h index 8ad793291..699d9bf8c 100644 --- a/include/extern.h +++ b/include/extern.h @@ -907,11 +907,12 @@ E void NDECL(remove_gold_from_invent); #endif E struct obj *FDECL(getobj, (const char *,const char *)); 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(fully_identify_obj, (struct obj *)); E int FDECL(identify, (struct obj *)); E void FDECL(identify_pack, (int,BOOLEAN_P)); -E int FDECL(askchain, (struct obj **,const char *,int,int (*)(OBJ_P), - int (*)(OBJ_P),int,const char *)); +E void NDECL(learn_unseen_invent); E void FDECL(prinv, (const char *,struct obj *,long)); E char *FDECL(xprname, (struct obj *,const char *,CHAR_P,BOOLEAN_P,long,long)); E int NDECL(ddoinv); diff --git a/src/invent.c b/src/invent.c index c98c2fe5d..369fddcda 100644 --- a/src/invent.c +++ b/src/invent.c @@ -1692,6 +1692,27 @@ boolean learning_id; /* true if we just read unknown identify scroll */ update_inventory(); } +/* called when regaining sight; mark inventory objects which were picked + up while blind as now having been seen */ +void +notice_unseen_invent() +{ + struct obj *otmp; + + if (Blind) return; /* sanity check */ + + for (otmp = invent; otmp; otmp = otmp->nobj) { + if (otmp->dknown) continue; /* already seen */ + /* set dknown, perhaps bknown (for priest[ess]) */ + (void) xname(otmp); + /* + * If object->eknown gets implemented (see learnwand(zap.c)), + * handle deferred discovery here. + */ + } + update_inventory(); +} + STATIC_OVL char obj_to_let(obj) /* should of course only be called for things in invent */ register struct obj *obj; diff --git a/src/potion.c b/src/potion.c index b0819b8e3..31b53af3d 100644 --- a/src/potion.c +++ b/src/potion.c @@ -285,6 +285,9 @@ boolean talk; got the message "a door appears in the wall") */ vision_recalc(0); if (Blind_telepat || Infravision) see_monsters(); + + /* update dknown flag for inventory picked up while blind */ + if (can_see_now) learn_unseen_invent(); } }