the #known command - show discovered object types */
| 761 | |
| 762 | /* the #known command - show discovered object types */ |
| 763 | int |
| 764 | dodiscovered(void) /* free after Robert Viduya */ |
| 765 | { |
| 766 | winid tmpwin; |
| 767 | char *s, oclass, prev_class, |
| 768 | classes[MAXOCLASSES], buf[BUFSZ], |
| 769 | *sorted_lines[NUM_OBJECTS]; /* overkill */ |
| 770 | const char *p; |
| 771 | int i, dis, ct, uniq_ct, arti_ct, sorted_ct, uidx; |
| 772 | long sortindx; // should be ptrdiff_t, but we don't require that exists |
| 773 | boolean alphabetized, alphabyclass, lootsort; |
| 774 | |
| 775 | if (!flags.discosort || !(p = strchr(disco_order_let, flags.discosort))) |
| 776 | flags.discosort = 'o'; |
| 777 | |
| 778 | if (iflags.menu_requested) { |
| 779 | if (choose_disco_sort(1) < 0) |
| 780 | return ECMD_OK; |
| 781 | } |
| 782 | alphabyclass = (flags.discosort == 'c'); |
| 783 | alphabetized = (flags.discosort == 'a' || alphabyclass); |
| 784 | lootsort = (flags.discosort == 's'); |
| 785 | sortindx = strchr(disco_order_let, flags.discosort) - disco_order_let; |
| 786 | |
| 787 | tmpwin = create_nhwindow(NHW_TEXT); |
| 788 | Sprintf(buf, "Discoveries, %s", disco_orders_descr[sortindx]); |
| 789 | putstr(tmpwin, 0, buf); |
| 790 | putstr(tmpwin, 0, ""); |
| 791 | |
| 792 | /* |
| 793 | * FIXME? |
| 794 | * relics and artifacts don't obey player's sort order even though |
| 795 | * the header line states that they're shown in such-and-such order. |
| 796 | */ |
| 797 | |
| 798 | /* gather "unique objects", also called "relics", into a pseudo-class; |
| 799 | they'll also be displayed individually within their regular class */ |
| 800 | uniq_ct = 0; |
| 801 | for (i = dis = 0; i < SIZE(uniq_objs); i++) { |
| 802 | uidx = uniq_objs[i]; |
| 803 | if (objects[uidx].oc_name_known |
| 804 | || (objects[uidx].oc_encountered && uidx != AMULET_OF_YENDOR)) { |
| 805 | if (!dis++) |
| 806 | putstr(tmpwin, iflags.menu_headings.attr, |
| 807 | "Unique items or Relics"); |
| 808 | ++uniq_ct; |
| 809 | disco_fmt_uniq(uidx, buf); |
| 810 | putstr(tmpwin, 0, buf); |
| 811 | } |
| 812 | } |
| 813 | /* display any known artifacts as another pseudo-class */ |
| 814 | arti_ct = disp_artifact_discoveries(tmpwin); |
| 815 | |
| 816 | /* several classes are omitted from packorder; one is of interest here */ |
| 817 | Strcpy(classes, flags.inv_order); |
| 818 | if (!strchr(classes, VENOM_CLASS)) |
| 819 | (void) strkitten(classes, VENOM_CLASS); /* append char to string */ |
| 820 |
nothing calls this directly
no test coverage detected