fix #H2559+2564 - using 'a' command to discover potion of oil (trunk only)

From a bug report, if you used the apply command while
not carrying anything applicable except for unknown potion, you would get
"you don't have anything to apply" if that potion wasn't oil but an
inventory selection prompt (with '*' as the default since you wouldn't
have anything considered to be a likely candidate) if that potion was oil,
giving away information.

     This fix makes carrying any unknown potion yield the inventory
selection result, unless oil is already discovered and hero can see that
the unknown potion isn't oil.
This commit is contained in:
nethack.rankin
2012-01-10 08:50:19 +00:00
parent 92b15c5f8a
commit 369b1031fd
2 changed files with 42 additions and 23 deletions

View File

@@ -401,6 +401,7 @@ autosearch finds and transforms secret doors and corridors even while blind,
hangup save made during magic mapping or <foo> detection performed while
underwater could put hero on top of the water after restore
items conferring life drain resistance were affected by drain life spell
'a'pply command could be used to recogniize undiscovered potions of oil
Platform- and/or Interface-Specific Fixes

View File

@@ -6,10 +6,6 @@
extern boolean notonhead; /* for long worms */
static const char tools[] = { TOOL_CLASS, WEAPON_CLASS, WAND_CLASS, 0 };
static const char tools_too[] = { ALL_CLASSES, TOOL_CLASS, POTION_CLASS,
WEAPON_CLASS, WAND_CLASS, GEM_CLASS, 0 };
#ifdef TOURIST
STATIC_DCL int FDECL(use_camera, (struct obj *));
#endif
@@ -38,8 +34,8 @@ STATIC_DCL int FDECL(use_grapple, (struct obj *));
STATIC_DCL int FDECL(do_break_wand, (struct obj *));
STATIC_DCL boolean FDECL(figurine_location_checks,
(struct obj *, coord *, BOOLEAN_P));
STATIC_DCL boolean NDECL(uhave_graystone);
STATIC_DCL void FDECL(add_class, (char *, CHAR_P));
STATIC_DCL void FDECL(setapplyclasses, (char *));
#ifdef AMIGA
void FDECL( amii_speaker, ( struct obj *, char *, int ) );
@@ -3069,28 +3065,56 @@ do_break_wand(obj)
return 1;
}
STATIC_OVL boolean
uhave_graystone()
{
register struct obj *otmp;
for(otmp = invent; otmp; otmp = otmp->nobj)
if(is_graystone(otmp))
return TRUE;
return FALSE;
}
STATIC_OVL void
add_class(cl, class)
char *cl;
char class;
{
char tmp[2];
tmp[0] = class;
tmp[1] = '\0';
Strcat(cl, tmp);
}
static const char tools[] = { TOOL_CLASS, WEAPON_CLASS, WAND_CLASS, 0 };
/* augment tools[] if various items are carried */
STATIC_OVL void
setapplyclasses(class_list)
char class_list[];
{
register struct obj *otmp;
int otyp;
boolean knowoil, knowtouchstone, addpotions, addstones, addfood;
knowoil = objects[POT_OIL].oc_name_known;
knowtouchstone = objects[TOUCHSTONE].oc_name_known;
addpotions = addstones = addfood = FALSE;
for (otmp = invent; otmp; otmp = otmp->nobj) {
otyp = otmp->otyp;
if (otyp == POT_OIL ||
(otmp->oclass == POTION_CLASS &&
(!otmp->dknown ||
(!knowoil && !objects[otyp].oc_name_known))))
addpotions = TRUE;
if (otyp == TOUCHSTONE ||
(is_graystone(otmp) &&
(!otmp->dknown ||
(!knowtouchstone && !objects[otyp].oc_name_known))))
addstones = TRUE;
if (otyp == CREAM_PIE || otyp == EUCALYPTUS_LEAF)
addfood = TRUE;
}
class_list[0] = '\0';
if (addpotions || addstones) add_class(class_list, ALL_CLASSES);
Strcat(class_list, tools);
if (addpotions) add_class(class_list, POTION_CLASS);
if (addstones) add_class(class_list, GEM_CLASS);
if (addfood) add_class(class_list, FOOD_CLASS);
}
int
doapply()
{
@@ -3100,13 +3124,7 @@ doapply()
if(check_capacity((char *)0)) return (0);
if (carrying(POT_OIL) || uhave_graystone())
Strcpy(class_list, tools_too);
else
Strcpy(class_list, tools);
if (carrying(CREAM_PIE) || carrying(EUCALYPTUS_LEAF))
add_class(class_list, FOOD_CLASS);
setapplyclasses(class_list); /* tools[] */
obj = getobj(class_list, "use or apply");
if(!obj) return 0;