Skip to content

Commit

Permalink
inventory display after regaining sight (trunk only)
Browse files Browse the repository at this point in the history
     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.
  • Loading branch information
nethack.rankin committed Jan 27, 2008
1 parent 6095d4a commit fb043c5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
5 changes: 3 additions & 2 deletions include/extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
21 changes: 21 additions & 0 deletions src/invent.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/potion.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down

0 comments on commit fb043c5

Please sign in to comment.