| 662 | } |
| 663 | |
| 664 | boolean |
| 665 | getpos_menu(coord *ccp, int gloc) |
| 666 | { |
| 667 | coord *garr = DUMMY; |
| 668 | int gcount = 0; |
| 669 | winid tmpwin; |
| 670 | anything any; |
| 671 | int i, pick_cnt; |
| 672 | menu_item *picks = (menu_item *) 0; |
| 673 | char tmpbuf[BUFSZ]; |
| 674 | int clr = NO_COLOR; |
| 675 | |
| 676 | gather_locs(&garr, &gcount, gloc); |
| 677 | |
| 678 | if (gcount < 2) { /* gcount always includes the hero */ |
| 679 | free((genericptr_t) garr); |
| 680 | You("cannot %s %s.", |
| 681 | (iflags.getloc_filter == GFILTER_VIEW) ? "see" : "detect", |
| 682 | gloc_descr[gloc][0]); |
| 683 | return FALSE; |
| 684 | } |
| 685 | |
| 686 | tmpwin = create_nhwindow(NHW_MENU); |
| 687 | start_menu(tmpwin, MENU_BEHAVE_STANDARD); |
| 688 | any = cg.zeroany; |
| 689 | |
| 690 | /* gather_locs returns array[0] == you. skip it. */ |
| 691 | for (i = 1; i < gcount; i++) { |
| 692 | char fullbuf[BUFSZ]; |
| 693 | coord tmpcc; |
| 694 | const char *firstmatch = "unknown"; |
| 695 | int sym = 0; |
| 696 | |
| 697 | any.a_int = i + 1; |
| 698 | tmpcc.x = garr[i].x; |
| 699 | tmpcc.y = garr[i].y; |
| 700 | if (do_screen_description(tmpcc, TRUE, sym, tmpbuf, |
| 701 | &firstmatch, (struct permonst **)0)) { |
| 702 | (void) coord_desc(garr[i].x, garr[i].y, tmpbuf, |
| 703 | iflags.getpos_coords); |
| 704 | Snprintf(fullbuf, sizeof fullbuf, "%s%s%s", firstmatch, |
| 705 | (*tmpbuf ? " " : ""), tmpbuf); |
| 706 | add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, |
| 707 | ATR_NONE, clr, fullbuf, MENU_ITEMFLAGS_NONE); |
| 708 | } |
| 709 | } |
| 710 | |
| 711 | Sprintf(tmpbuf, "Pick %s%s%s", |
| 712 | an(gloc_descr[gloc][1]), |
| 713 | gloc_filtertxt[iflags.getloc_filter], |
| 714 | iflags.getloc_travelmode ? " for travel destination" : ""); |
| 715 | end_menu(tmpwin, tmpbuf); |
| 716 | pick_cnt = select_menu(tmpwin, PICK_ONE, &picks); |
| 717 | destroy_nhwindow(tmpwin); |
| 718 | if (pick_cnt > 0) { |
| 719 | ccp->x = garr[picks->item.a_int - 1].x; |
| 720 | ccp->y = garr[picks->item.a_int - 1].y; |
| 721 | free((genericptr_t) picks); |
no test coverage detected