wizidentify suppress unnecessary prompt; allow individual items for perm ID

Don't display the selection to identify all items if there are none.

Complete an item marked ToDo in cmd.c: allow selection of one or more
particular items to permanently identify rather than just all or nothing.
This commit is contained in:
nhmall
2018-09-01 10:43:26 -04:00
parent 111cfa0ff4
commit 5a44a34420
4 changed files with 82 additions and 39 deletions
+3
View File
@@ -154,6 +154,9 @@ sortloot option has been enhanced to improve object ordering; primarily,
within each class or sub-class of objects within each class or sub-class of objects
YAFM when stumbling on an undetected monster while hallucinating YAFM when stumbling on an undetected monster while hallucinating
Make it clear when a leprechaun dodges your attack Make it clear when a leprechaun dodges your attack
wizard mode #wizidentify can now select individual items for permanent
identification and don't display the selection to permanently
identify everything if everything is already fully identified
Code Cleanup and Reorganization Code Cleanup and Reorganization
+2 -1
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 extern.h $NHDT-Date: 1525012590 2018/04/29 14:36:30 $ $NHDT-Branch: master $:$NHDT-Revision: 1.629 $ */ /* NetHack 3.6 extern.h $NHDT-Date: 1535812936 2018/09/01 14:42:16 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.636 $ */
/* Copyright (c) Steve Creps, 1988. */ /* Copyright (c) Steve Creps, 1988. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -973,6 +973,7 @@ E int FDECL(askchain, (struct obj **, const char *, int, int (*)(OBJ_P),
int (*)(OBJ_P), int, const char *)); int (*)(OBJ_P), int, const char *));
E void FDECL(fully_identify_obj, (struct obj *)); E void FDECL(fully_identify_obj, (struct obj *));
E int FDECL(identify, (struct obj *)); E int FDECL(identify, (struct obj *));
E int FDECL(count_unidentified, (struct obj *));
E void FDECL(identify_pack, (int, BOOLEAN_P)); E void FDECL(identify_pack, (int, BOOLEAN_P));
E void NDECL(learn_unseen_invent); E void NDECL(learn_unseen_invent);
E void FDECL(prinv, (const char *, struct obj *, long)); E void FDECL(prinv, (const char *, struct obj *, long));
-1
View File
@@ -652,7 +652,6 @@ wiz_identify(VOID_ARGS)
it doesn't matter whether the command has been remapped */ it doesn't matter whether the command has been remapped */
if (display_inventory((char *) 0, TRUE) == C('I')) if (display_inventory((char *) 0, TRUE) == C('I'))
identify_pack(0, FALSE); identify_pack(0, FALSE);
/* [TODO? if player picks a specific inventory item, ID it] */
iflags.override_ID = 0; iflags.override_ID = 0;
} else } else
pline("Unavailable command '%s'.", pline("Unavailable command '%s'.",
+77 -37
View File
@@ -2279,6 +2279,19 @@ int id_limit;
} }
} }
} }
/* count the unidentified items */
int
count_unidentified(objchn)
struct obj *objchn;
{
int unid_cnt = 0;
struct obj *obj;
for (obj = objchn; obj; obj = obj->nobj)
if (not_fully_identified(obj))
++unid_cnt;
return unid_cnt;
}
/* dialog with user to identify a given number of items; 0 means all */ /* dialog with user to identify a given number of items; 0 means all */
void void
@@ -2286,28 +2299,21 @@ identify_pack(id_limit, learning_id)
int id_limit; int id_limit;
boolean learning_id; /* true if we just read unknown identify scroll */ boolean learning_id; /* true if we just read unknown identify scroll */
{ {
struct obj *obj, *the_obj; struct obj *obj;
int n, unid_cnt; int n, unid_cnt = count_unidentified(invent);
unid_cnt = 0;
the_obj = 0; /* if unid_cnt ends up 1, this will be it */
for (obj = invent; obj; obj = obj->nobj)
if (not_fully_identified(obj))
++unid_cnt, the_obj = obj;
if (!unid_cnt) { if (!unid_cnt) {
You("have already identified all %sof your possessions.", You("have already identified all %sof your possessions.",
learning_id ? "the rest " : ""); learning_id ? "the rest " : "");
} else if (!id_limit || id_limit >= unid_cnt) { } else if (!id_limit || id_limit >= unid_cnt) {
/* identify everything */ /* identify everything */
if (unid_cnt == 1) { /* TODO: use fully_identify_obj and cornline/menu/whatever here */
(void) identify(the_obj); for (obj = invent; obj; obj = obj->nobj) {
} else { if (not_fully_identified(obj)) {
/* TODO: use fully_identify_obj and cornline/menu/whatever here (void) identify(obj);
*/ if (unid_cnt == 1)
for (obj = invent; obj; obj = obj->nobj) break;
if (not_fully_identified(obj)) }
(void) identify(obj);
} }
} else { } else {
/* identify up to `id_limit' items */ /* identify up to `id_limit' items */
@@ -2491,7 +2497,7 @@ boolean want_reply;
long *out_cnt; long *out_cnt;
{ {
static const char not_carrying_anything[] = "Not carrying anything"; static const char not_carrying_anything[] = "Not carrying anything";
struct obj *otmp; struct obj *otmp, wizid_fakeobj;
char ilet, ret; char ilet, ret;
char *invlet = flags.inv_order; char *invlet = flags.inv_order;
int n, classcount; int n, classcount;
@@ -2500,6 +2506,7 @@ long *out_cnt;
menu_item *selected; menu_item *selected;
unsigned sortflags; unsigned sortflags;
Loot *sortedinvent, *srtinv; Loot *sortedinvent, *srtinv;
boolean wizid = FALSE;
if (lets && !*lets) if (lets && !*lets)
lets = 0; /* simplify tests: (lets) instead of (lets && *lets) */ lets = 0; /* simplify tests: (lets) instead of (lets && *lets) */
@@ -2582,22 +2589,30 @@ long *out_cnt;
start_menu(win); start_menu(win);
any = zeroany; any = zeroany;
if (wizard && iflags.override_ID) { if (wizard && iflags.override_ID) {
int unid_cnt;
char prompt[QBUFSZ]; char prompt[QBUFSZ];
/* C('I') == ^I == default keystroke for wiz_identify; unid_cnt = count_unidentified(invent);
it is guaranteed not to be in use as an inventory letter if (!unid_cnt) {
(wiz_identify might be remapped to an ordinary letter, add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE,
making iflags.override_ID ambiguous as a return value) */ "(all items are permanently identified already)",
any.a_char = C('I'); MENU_UNSELECTED);
/* wiz_identify stuffed the wiz_identify command character (^I) } else {
into iflags.override_ID for our use as an accelerator; any.a_obj = &wizid_fakeobj;
it could be ambiguous as a selector but the only time it /* wiz_identify stuffed the wiz_identify command character (^I)
is wanted is in case where no item is being selected */ into iflags.override_ID for our use as an accelerator;
Sprintf(prompt, "Debug Identify (%s to permanently identify)", it could be ambiguous as a selector but the only time it
visctrl(iflags.override_ID)); is wanted is in case where no item is being selected */
add_menu(win, NO_GLYPH, &any, '_', iflags.override_ID, ATR_NONE, Sprintf(prompt,
prompt, MENU_UNSELECTED); "Select any to identify permanently (%s for %s %d bolded item%s)",
} else if (xtra_choice) { visctrl(iflags.override_ID),
(unid_cnt == 1) ? "the" : "all", unid_cnt,
(unid_cnt > 1) ? "s" : "");
add_menu(win, NO_GLYPH, &any, '_', iflags.override_ID, ATR_NONE,
prompt, MENU_UNSELECTED);
wizid = TRUE;
}
} else if (xtra_choice) {
/* wizard override ID and xtra_choice are mutually exclusive */ /* wizard override ID and xtra_choice are mutually exclusive */
if (flags.sortpack) if (flags.sortpack)
add_menu(win, NO_GLYPH, &any, 0, 0, iflags.menu_headings, add_menu(win, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
@@ -2621,8 +2636,13 @@ nextclass:
MENU_UNSELECTED); MENU_UNSELECTED);
classcount++; classcount++;
} }
any.a_char = ilet; if (wizid)
add_menu(win, obj_to_glyph(otmp), &any, ilet, 0, ATR_NONE, any.a_obj = otmp;
else
any.a_char = ilet;
add_menu(win, obj_to_glyph(otmp), &any, ilet, 0,
(wizid && not_fully_identified(otmp)) ?
ATR_BOLD : ATR_NONE,
doname(otmp), MENU_UNSELECTED); doname(otmp), MENU_UNSELECTED);
} }
} }
@@ -2655,11 +2675,31 @@ nextclass:
} }
end_menu(win, query && *query ? query : (char *) 0); end_menu(win, query && *query ? query : (char *) 0);
n = select_menu(win, want_reply ? PICK_ONE : PICK_NONE, &selected); n = select_menu(win, wizid ? PICK_ANY :
want_reply ? PICK_ONE : PICK_NONE, &selected);
if (n > 0) { if (n > 0) {
ret = selected[0].item.a_char; if (wizid) {
if (out_cnt) int i = n;
*out_cnt = selected[0].count;
ret = '\0';
while (--i >= 0) {
otmp = selected[i].item.a_obj;
if (otmp == &wizid_fakeobj) {
/* C('I') == ^I == default keystroke for wiz_identify;
it is guaranteed not to be in use as an inventory letter
(wiz_identify might be remapped to an ordinary letter,
making iflags.override_ID ambiguous as a return value) */
ret = C('I');
} else {
if (not_fully_identified(otmp))
(void) identify(otmp);
}
}
} else {
ret = selected[0].item.a_char;
if (out_cnt)
*out_cnt = selected[0].count;
}
free((genericptr_t) selected); free((genericptr_t) selected);
} else } else
ret = !n ? '\0' : '\033'; /* cancelled */ ret = !n ? '\0' : '\033'; /* cancelled */