wiz_identify change (trunk only)

This patch alters wiz_identify so that it displays an
inventory menu with all items shown identified
without actually identifying them.

You can just press ^I (or whatever the wiz_identify command
is) a second time, while the menu is displayed to actually identify
them (tested with TTY menus only).
This commit is contained in:
nethack.allison
2006-01-14 17:02:22 +00:00
parent 40b426a977
commit 70b04bfb6e
5 changed files with 116 additions and 56 deletions

View File

@@ -152,32 +152,39 @@ struct sysflag {
*/
struct instance_flags {
boolean cbreak; /* in cbreak mode, rogue format */
boolean DECgraphics; /* use DEC VT-xxx extended character set */
boolean echo; /* 1 to echo characters */
boolean IBMgraphics; /* use IBM extended character set */
unsigned msg_history; /* hint: # of top lines to save */
boolean num_pad; /* use numbers for movement commands */
boolean news; /* print news */
/* stuff that really isn't option or platform related. They are
* set and cleared during the game to control the internal
* behaviour of various NetHack functions and probably warrant
* a structure of their own elsewhere some day.
*/
int in_lava_effects; /* hack for Boots_off() */
int purge_monsters; /* # of dead monsters still on fmon list */
int override_ID; /* true to force full identification of objects */
coord travelcc; /* coordinates for travel_cache */
boolean window_inited; /* true if init_nhwindows() completed */
boolean vision_inited; /* true if vision is ready */
#ifdef WIZARD
boolean sanity_check; /* run sanity checks */
boolean mon_polycontrol; /* debug: control monster polymorphs */
#endif
/* stuff that is related to options and/or user or platform preferences */
unsigned msg_history; /* hint: # of top lines to save */
int menu_headings; /* ATR for menu headings */
int *opt_booldup; /* for duplication of boolean opts in config file */
int *opt_compdup; /* for duplication of compound opts in config file */
boolean cbreak; /* in cbreak mode, rogue format */
boolean num_pad; /* use numbers for movement commands */
boolean news; /* print news */
boolean menu_tab_sep; /* Use tabs to separate option menu fields */
boolean menu_requested; /* Flag for overloaded use of 'm' prefix
* on some non-move commands */
boolean zerocomp; /* write zero-compressed save files */
boolean rlecomp; /* run-length comp of levels when writing savefile */
uchar num_pad_mode;
int in_lava_effects; /* hack for Boots_off() */
int menu_headings; /* ATR for menu headings */
int purge_monsters; /* # of dead monsters still on fmon list */
int *opt_booldup; /* for duplication of boolean opts in config file */
int *opt_compdup; /* for duplication of compound opts in config file */
boolean DECgraphics; /* use DEC VT-xxx extended character set */
boolean echo; /* 1 to echo characters */
boolean IBMgraphics; /* use IBM extended character set */
uchar bouldersym; /* symbol for boulder display */
coord travelcc; /* coordinates for travel_cache */
#ifdef WIZARD
boolean sanity_check; /* run sanity checks */
boolean mon_polycontrol; /* debug: control monster polymorphs */
#endif
#ifdef TTY_GRAPHICS
char prevmsg_window; /* type of old message window to use */
boolean extmenu; /* extended commands use menu interface */

View File

@@ -150,6 +150,7 @@ STATIC_PTR int NDECL(doattributes);
STATIC_PTR int NDECL(doconduct); /**/
STATIC_PTR boolean NDECL(minimal_enlightenment);
STATIC_DCL char FDECL(cmd_from_func, (int NDECL((*))));
STATIC_DCL void FDECL(enlght_line, (const char *,const char *,const char *,char *));
STATIC_DCL char *FDECL(enlght_combatinc, (const char *,int,int,char *));
#if defined(UNIX) || defined(SAFERHANGUP)
@@ -516,9 +517,13 @@ wiz_wish() /* Unlimited wishes for debug mode by Paul Polderman */
STATIC_PTR int
wiz_identify()
{
if (wizard) identify_pack(0);
else pline("Unavailable command '^I'.");
return 0;
if (wizard) {
iflags.override_ID = (int)cmd_from_func(wiz_identify);
if (display_inventory((char *)0, TRUE) == -1)
identify_pack(0);
iflags.override_ID = 0;
} else pline("Unavailable command '^I'.");
return 0;
}
/* ^F command - reveal the level map and any traps on it */
@@ -1749,6 +1754,17 @@ boolean initial;
Cmd.move_SW = Cmd.dirchars[7];
}
STATIC_OVL char
cmd_from_func(fn)
int NDECL((*fn));
{
int i;
for (i = 0; i < SIZE(cmdlist); ++i)
if (cmdlist[i].f_funct == fn)
return cmdlist[i].f_char;
return 0;
}
/* decide whether a character (user input keystroke) requests screen repaint */
boolean
redraw_cmd(c)

View File

@@ -1176,7 +1176,7 @@ char *buf;
else if (mnum == NON_PM)
Strcpy(buf, "empty tin");
else {
if (obj->cknown && obj->spe < 0) {
if ((obj->cknown || iflags.override_ID) && obj->spe < 0) {
int r = tin_variety(obj, TRUE);
if (r == ROTTEN_TIN || r == HOMEMADE_TIN) {
/* put these before the word tin */

View File

@@ -1732,7 +1732,7 @@ long* out_cnt;
/* oxymoron? temporarily assign permanent inventory letters */
if (!flags.invlet_constant) reassign();
if (lets && strlen(lets) == 1) {
if (lets && strlen(lets) == 1 && !iflags.override_ID) {
/* when only one item of interest, use pline instead of menus;
we actually use a fake message-line menu in order to allow
the user to perform selection at the --More-- prompt for tty */
@@ -1750,6 +1750,18 @@ long* out_cnt;
}
start_menu(win);
#ifdef WIZARD
if (wizard && iflags.override_ID) {
char prompt[BUFSZ];
any.a_char = -1;
/* wiz_identify stuffed the wiz_identify cmd character
into iflags.override_ID */
Sprintf(prompt, "Debug Identify (%s to permanently identify)",
visctrl(iflags.override_ID));
add_menu(win, NO_GLYPH, &any,' ', iflags.override_ID, ATR_NONE,
prompt, MENU_UNSELECTED);
}
#endif
nextclass:
classcount = 0;
any.a_void = 0; /* set all bits to zero */

View File

@@ -167,12 +167,14 @@ boolean
obj_is_pname(obj)
register struct obj *obj;
{
return((boolean)(obj->dknown && obj->known && obj->onamelth &&
/* Since there aren't any objects which are both
artifacts and unique, the last check is redundant. */
obj->oartifact && !objects[obj->otyp].oc_unique));
return((boolean)(
((obj->dknown && obj->known) || iflags.override_ID) && obj->onamelth &&
/* Since there aren't any objects which are both
artifacts and unique, the last check is redundant. */
obj->oartifact && !objects[obj->otyp].oc_unique));
}
/* Give the name of an object seen at a distance. Unlike xname/doname,
* we don't want to set dknown if it's not set already. The kludge used is
* to temporarily set Blind so that xname() skips the dknown setting. This
@@ -224,6 +226,7 @@ register struct obj *obj;
const char *dn = OBJ_DESCR(*ocl);
const char *un = ocl->oc_uname;
boolean pluralize = (obj->quan != 1L);
boolean known, dknown, bknown;
buf = nextobuf() + PREFIX; /* leave room for "17 -3 " */
if (Role_if(PM_SAMURAI) && Japanese_item_name(typ))
@@ -239,16 +242,26 @@ register struct obj *obj;
if (!nn && ocl->oc_uses_known && ocl->oc_unique) obj->known = 0;
if (!Blind) obj->dknown = TRUE;
if (Role_if(PM_PRIEST)) obj->bknown = TRUE;
if (iflags.override_ID) {
known = dknown = bknown = TRUE;
nn = 1;
} else {
known = obj->known;
dknown = obj->dknown;
bknown = obj->bknown;
}
if (obj_is_pname(obj))
goto nameit;
switch (obj->oclass) {
case AMULET_CLASS:
if (!obj->dknown)
if (!dknown)
Strcpy(buf, "amulet");
else if (typ == AMULET_OF_YENDOR ||
typ == FAKE_AMULET_OF_YENDOR)
/* each must be identified individually */
Strcpy(buf, obj->known ? actualn : dn);
Strcpy(buf, known ? actualn : dn);
else if (nn)
Strcpy(buf, actualn);
else if (un)
@@ -264,7 +277,7 @@ register struct obj *obj;
if (typ == LENSES)
Strcpy(buf, "pair of ");
if (!obj->dknown)
if (!dknown)
Strcat(buf, dn ? dn : actualn);
else if (nn)
Strcat(buf, actualn);
@@ -290,11 +303,11 @@ register struct obj *obj;
if(is_boots(obj) || is_gloves(obj)) Strcpy(buf,"pair of ");
if(obj->otyp >= ELVEN_SHIELD && obj->otyp <= ORCISH_SHIELD
&& !obj->dknown) {
&& !dknown) {
Strcpy(buf, "shield");
break;
}
if(obj->otyp == SHIELD_OF_REFLECTION && !obj->dknown) {
if(obj->otyp == SHIELD_OF_REFLECTION && !dknown) {
Strcpy(buf, "smooth shield");
break;
}
@@ -341,7 +354,7 @@ register struct obj *obj;
}
Strcpy(buf, actualn);
if (typ == TIN && obj->known)
if (typ == TIN && known)
tin_details(obj, omndx, buf);
break;
case COIN_CLASS:
@@ -365,15 +378,15 @@ register struct obj *obj;
(obj->owt > ocl->oc_weight) ? "very " : "");
break;
case POTION_CLASS:
if (obj->dknown && obj->odiluted)
if (dknown && obj->odiluted)
Strcpy(buf, "diluted ");
if(nn || un || !obj->dknown) {
if(nn || un || !dknown) {
Strcat(buf, "potion");
if(!obj->dknown) break;
if(!dknown) break;
if(nn) {
Strcat(buf, " of ");
if (typ == POT_WATER &&
obj->bknown && (obj->blessed || obj->cursed)) {
bknown && (obj->blessed || obj->cursed)) {
Strcat(buf, obj->blessed ? "holy " : "unholy ");
}
Strcat(buf, actualn);
@@ -388,7 +401,7 @@ register struct obj *obj;
break;
case SCROLL_CLASS:
Strcpy(buf, "scroll");
if(!obj->dknown) break;
if(!dknown) break;
if(nn) {
Strcat(buf, " of ");
Strcat(buf, actualn);
@@ -404,7 +417,7 @@ register struct obj *obj;
}
break;
case WAND_CLASS:
if(!obj->dknown)
if(!dknown)
Strcpy(buf, "wand");
else if(nn)
Sprintf(buf, "wand of %s", actualn);
@@ -414,7 +427,7 @@ register struct obj *obj;
Sprintf(buf, "%s wand", dn);
break;
case SPBOOK_CLASS:
if (!obj->dknown) {
if (!dknown) {
Strcpy(buf, "spellbook");
} else if (nn) {
if (typ != SPE_BOOK_OF_THE_DEAD)
@@ -426,7 +439,7 @@ register struct obj *obj;
Sprintf(buf, "%s spellbook", dn);
break;
case RING_CLASS:
if(!obj->dknown)
if(!dknown)
Strcpy(buf, "ring");
else if(nn)
Sprintf(buf, "ring of %s", actualn);
@@ -439,7 +452,7 @@ register struct obj *obj;
{
const char *rock =
(ocl->oc_material == MINERAL) ? "stone" : "gem";
if (!obj->dknown) {
if (!dknown) {
Strcpy(buf, rock);
} else if (!nn) {
if (un) Sprintf(buf,"%s called %s", rock, un);
@@ -455,7 +468,7 @@ register struct obj *obj;
}
if (pluralize) Strcpy(buf, makeplural(buf));
if (obj->onamelth && obj->dknown) {
if (obj->onamelth && dknown) {
Strcat(buf, " named ");
nameit:
Strcat(buf, ONAME(obj));
@@ -490,13 +503,14 @@ boolean
the_unique_obj(obj)
register struct obj *obj;
{
if (!obj->dknown)
boolean known = (obj->known || iflags.override_ID);
if (!obj->dknown && !iflags.override_ID)
return FALSE;
else if (obj->otyp == FAKE_AMULET_OF_YENDOR && !obj->known)
else if (obj->otyp == FAKE_AMULET_OF_YENDOR && !known)
return TRUE; /* lie */
else
return (boolean)(objects[obj->otyp].oc_unique &&
(obj->known || obj->otyp == AMULET_OF_YENDOR));
(known || obj->otyp == AMULET_OF_YENDOR));
}
/* should monster type be prefixed with "the"? (mostly used for corpses) */
@@ -528,7 +542,9 @@ struct obj *obj;
char *prefix;
{
boolean iscrys = (obj->otyp == CRYSKNIFE);
boolean rknown;
rknown = (iflags.override_ID == 0) ? obj->rknown : TRUE;
if (!is_damageable(obj) && !iscrys) return;
@@ -550,7 +566,7 @@ char *prefix;
Strcat(prefix, is_corrodeable(obj) ? "corroded " :
"rotted ");
}
if (obj->rknown && obj->oerodeproof)
if (rknown && obj->oerodeproof)
Strcat(prefix,
iscrys ? "fixed " :
is_rustprone(obj) ? "rustproof " :
@@ -563,6 +579,7 @@ doname(obj)
register struct obj *obj;
{
boolean ispoisoned = FALSE;
boolean known, cknown, bknown, lknown;
int omndx = obj->corpsenm;
char prefix[PREFIX];
char tmpbuf[PREFIX+1];
@@ -571,6 +588,14 @@ register struct obj *obj;
*/
register char *bp = xname(obj);
if (iflags.override_ID) known = cknown = bknown = lknown = TRUE;
else {
known = obj->known;
cknown = obj->cknown;
bknown = obj->bknown;
lknown = obj->lknown;
}
/* When using xname, we want "poisoned arrow", and when using
* doname, we want "poisoned +0 arrow". This kludge is about the only
* way to do it, at least until someone overhauls xname() and doname(),
@@ -600,11 +625,11 @@ register struct obj *obj;
#endif
/* "empty" goes at the beginning, but item count goes at the end */
if (obj->cknown &&
if (cknown &&
(Is_container(obj) || obj->otyp == STATUE) && !Has_contents(obj))
Strcat(prefix, "empty ");
if (obj->bknown &&
if (bknown &&
obj->oclass != COIN_CLASS &&
(obj->otyp != POT_WATER || !objects[POT_WATER].oc_name_known
|| (!obj->cursed && !obj->blessed))) {
@@ -615,7 +640,7 @@ register struct obj *obj;
Strcat(prefix, "cursed ");
else if (obj->blessed)
Strcat(prefix, "blessed ");
else if ((!obj->known || !objects[obj->otyp].oc_charged ||
else if ((!known || !objects[obj->otyp].oc_charged ||
(obj->oclass == ARMOR_CLASS ||
obj->oclass == RING_CLASS))
/* For most items with charges or +/-, if you know how many
@@ -637,7 +662,7 @@ register struct obj *obj;
Strcat(prefix, "uncursed ");
}
if (obj->lknown && Is_box(obj)) {
if (lknown && Is_box(obj)) {
if (obj->obroken)
Strcat(prefix, "unlockable ");
else if (obj->olocked)
@@ -648,7 +673,7 @@ register struct obj *obj;
if (obj->greased) Strcat(prefix, "greased ");
if (obj->cknown && Has_contents(obj)) {
if (cknown && Has_contents(obj)) {
struct obj *curr;
long itemcount = 0L;
@@ -669,7 +694,7 @@ register struct obj *obj;
Strcat(prefix, "poisoned ");
plus:
add_erosion_words(obj, prefix);
if(obj->known) {
if(known) {
Strcat(prefix, sitoa(obj->spe));
Strcat(prefix, " ");
}
@@ -721,7 +746,7 @@ plus:
case WAND_CLASS:
add_erosion_words(obj, prefix);
charges:
if(obj->known)
if(known)
Sprintf(eos(bp), " (%d:%d)", (int)obj->recharged, obj->spe);
break;
case POTION_CLASS:
@@ -737,7 +762,7 @@ ring:
Strcat(bp, body_part(HAND));
Strcat(bp, ")");
}
if(obj->known && objects[obj->otyp].oc_charged) {
if(known && objects[obj->otyp].oc_charged) {
Strcat(prefix, sitoa(obj->spe));
Strcat(prefix, " ");
}
@@ -751,10 +776,10 @@ ring:
CXN_ARTICLE|CXN_NOCORPSE));
} else if (obj->otyp == EGG) {
#if 0 /* corpses don't tell if they're stale either */
if (obj->known && stale_egg(obj))
if (known && stale_egg(obj))
Strcat(prefix, "stale ");
#endif
if (omndx >= LOW_PM && (obj->known ||
if (omndx >= LOW_PM && (known ||
(mvitals[omndx].mvflags & MV_KNOWS_EGG))) {
Strcat(prefix, mons[omndx].mname);
Strcat(prefix, " ");