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

Function doclassdisco

src/o_init.c:890–1127  ·  view source on GitHub ↗

the #knownclass command - show discovered object types for one class; in addition to actual object classes, supports pseudo-class 'a' for discovered artifacts and 'u' (or 'r', for "relics") for unique items */

Source from the content-addressed store, hash-verified

888 in addition to actual object classes, supports pseudo-class 'a' for
889 discovered artifacts and 'u' (or 'r', for "relics") for unique items */
890int
891doclassdisco(void)
892{
893 static NEARDATA const char
894 prompt[] = "View discoveries for which sort of objects?",
895 havent_discovered_any[] = "haven't discovered any %s yet.",
896 unique_items[] = "unique items or relics",
897 artifact_items[] = "artifacts";
898 winid tmpwin = WIN_ERR;
899 menu_item *pick_list = 0;
900 anything any;
901 char *s, c, oclass, menulet, allclasses[MAXOCLASSES],
902 discosyms[3 + MAXOCLASSES + 1], buf[BUFSZ],
903 *sorted_lines[NUM_OBJECTS]; /* overkill */
904 const char *p;
905 int i, ct, dis, xtras, sorted_ct, uidx;
906 boolean traditional, alphabetized, lootsort;
907 int clr = NO_COLOR;
908
909 if (!flags.discosort || !(p = strchr(disco_order_let, flags.discosort)))
910 flags.discosort = 'o';
911
912 if (iflags.menu_requested) {
913 if (choose_disco_sort(2) < 0)
914 return ECMD_OK;
915 }
916 alphabetized = (flags.discosort == 'a' || flags.discosort == 'c');
917 lootsort = (flags.discosort == 's');
918
919 discosyms[0] = '\0';
920 traditional = (flags.menu_style == MENU_TRADITIONAL
921 || flags.menu_style == MENU_COMBINATION);
922 if (!traditional) {
923 tmpwin = create_nhwindow(NHW_MENU);
924 start_menu(tmpwin, MENU_BEHAVE_STANDARD);
925 }
926 any = cg.zeroany;
927 menulet = 'a';
928
929 /*
930 * FIXME?
931 * relics and artifacts don't obey player's sort order even though
932 * the header line states that they're shown in such-and-such order.
933 */
934
935 /* check whether we've discovered any unique objects (primarily the
936 invocation items; the Guidebook calls unique items "relics" but the
937 Amulet of Yendor is unique too so we haven't made a blanket change
938 from 'u' to 'r') */
939 for (i = 0; i < SIZE(uniq_objs); i++) {
940 uidx = uniq_objs[i];
941 if (objects[uidx].oc_name_known
942 || (objects[uidx].oc_encountered && uidx != AMULET_OF_YENDOR)) {
943 Strcat(discosyms, "u");
944 if (!traditional) {
945 any.a_int = 'u';
946 /* FIXME: having 'r' as an accelerator to provide an unseen
947 synonym works but doesn't make much sense since the main

Callers

nothing calls this directly

Calls 15

choose_disco_sortFunction · 0.85
add_menuFunction · 0.85
strkittenFunction · 0.85
interesting_to_discoverFunction · 0.85
oclass_to_nameFunction · 0.85
YouFunction · 0.85
yn_functionFunction · 0.85
select_menuFunction · 0.85
upstartFunction · 0.85
disco_fmt_uniqFunction · 0.85
dump_artifact_infoFunction · 0.85

Tested by

no test coverage detected