MCPcopy Create free account
hub / github.com/NetHack/NetHack / menu_identify

Function menu_identify

src/invent.c:2659–2695  ·  view source on GitHub ↗

menu of unidentified objects; select and identify up to id_limit of them */

Source from the content-addressed store, hash-verified

2657
2658/* menu of unidentified objects; select and identify up to id_limit of them */
2659staticfn void
2660menu_identify(int id_limit)
2661{
2662 menu_item *pick_list;
2663 int n, i, first = 1, tryct = 5;
2664 char buf[BUFSZ];
2665 /* assumptions: id_limit > 0 and at least one unID'd item is present */
2666
2667 while (id_limit) {
2668 Sprintf(buf, "What would you like to identify %s?",
2669 first ? "first" : "next");
2670 n = query_objlist(buf, &gi.invent, (SIGNAL_NOMENU | SIGNAL_ESCAPE
2671 | USE_INVLET | INVORDER_SORT),
2672 &pick_list, PICK_ANY, not_fully_identified);
2673
2674 if (n > 0) {
2675 if (n > id_limit)
2676 n = id_limit;
2677 for (i = 0; i < n; i++, id_limit--)
2678 (void) identify(pick_list[i].item.a_obj);
2679 free((genericptr_t) pick_list);
2680 if (id_limit)
2681 wait_synch(); /* Before we loop to pop open another menu */
2682 first = 0;
2683 } else if (n == -2) { /* player used ESC to quit menu */
2684 break;
2685 } else if (n == -1) { /* no eligible items found */
2686 pline("That was all.");
2687 break;
2688 } else if (!--tryct) { /* stop re-prompting */
2689 pline1(thats_enough_tries);
2690 break;
2691 } else { /* try again */
2692 pline("Choose an item; use ESC to decline.");
2693 }
2694 }
2695}
2696/* count the unidentified items */
2697int
2698count_unidentified(struct obj *objchn)

Callers 1

identify_packFunction · 0.85

Calls 4

query_objlistFunction · 0.85
identifyFunction · 0.85
wait_synchFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected