}
}
}
+/* 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 */
void
int id_limit;
boolean learning_id; /* true if we just read unknown identify scroll */
{
- struct obj *obj, *the_obj;
- int n, unid_cnt;
-
- 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;
+ struct obj *obj;
+ int n, unid_cnt = count_unidentified(invent);
if (!unid_cnt) {
You("have already identified all %sof your possessions.",
learning_id ? "the rest " : "");
} else if (!id_limit || id_limit >= unid_cnt) {
/* identify everything */
- if (unid_cnt == 1) {
- (void) identify(the_obj);
- } else {
- /* TODO: use fully_identify_obj and cornline/menu/whatever here
- */
- for (obj = invent; obj; obj = obj->nobj)
- if (not_fully_identified(obj))
- (void) identify(obj);
+ /* TODO: use fully_identify_obj and cornline/menu/whatever here */
+ for (obj = invent; obj; obj = obj->nobj) {
+ if (not_fully_identified(obj)) {
+ (void) identify(obj);
+ if (unid_cnt == 1)
+ break;
+ }
}
} else {
/* identify up to `id_limit' items */
long *out_cnt;
{
static const char not_carrying_anything[] = "Not carrying anything";
- struct obj *otmp;
+ struct obj *otmp, wizid_fakeobj;
char ilet, ret;
char *invlet = flags.inv_order;
int n, classcount;
menu_item *selected;
unsigned sortflags;
Loot *sortedinvent, *srtinv;
+ boolean wizid = FALSE;
if (lets && !*lets)
lets = 0; /* simplify tests: (lets) instead of (lets && *lets) */
start_menu(win);
any = zeroany;
if (wizard && iflags.override_ID) {
+ int unid_cnt;
char prompt[QBUFSZ];
- /* 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) */
- any.a_char = C('I');
- /* wiz_identify stuffed the wiz_identify command character (^I)
- into iflags.override_ID for our use as an accelerator;
- it could be ambiguous as a selector but the only time it
- is wanted is in case where no item is being selected */
- 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);
- } else if (xtra_choice) {
+ unid_cnt = count_unidentified(invent);
+ if (!unid_cnt) {
+ add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE,
+ "(all items are permanently identified already)",
+ MENU_UNSELECTED);
+ } else {
+ any.a_obj = &wizid_fakeobj;
+ /* wiz_identify stuffed the wiz_identify command character (^I)
+ into iflags.override_ID for our use as an accelerator;
+ it could be ambiguous as a selector but the only time it
+ is wanted is in case where no item is being selected */
+ Sprintf(prompt,
+ "Select any to identify permanently (%s for %s %d bolded item%s)",
+ 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 */
if (flags.sortpack)
add_menu(win, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
MENU_UNSELECTED);
classcount++;
}
- any.a_char = ilet;
- add_menu(win, obj_to_glyph(otmp), &any, ilet, 0, ATR_NONE,
+ if (wizid)
+ 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);
}
}
}
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) {
- ret = selected[0].item.a_char;
- if (out_cnt)
- *out_cnt = selected[0].count;
+ if (wizid) {
+ int i = n;
+
+ 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);
} else
ret = !n ? '\0' : '\033'; /* cancelled */