Changeset 130
- Timestamp:
- 05/12/07 09:39:43 (2 years ago)
- Files:
-
- trunk/src/dungeon.c (modified) (2 diffs)
- trunk/src/monster2.c (modified) (2 diffs)
- trunk/src/z-file.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/dungeon.c
r120 r130 1190 1190 } 1191 1191 1192 static void do_cmd_monlist(void) 1193 { 1194 /* Save the screen and display the list */ 1195 screen_save(); 1196 display_monlist(); 1197 1198 /* Wait */ 1199 inkey(); 1200 1201 /* Return */ 1202 screen_load(); 1203 } 1204 1192 1205 /* 1193 1206 * Useful typedef. … … 1297 1310 { "Identify symbol", '/', do_cmd_query_symbol }, 1298 1311 { "Character description", 'C', do_cmd_change_name }, 1312 { "Display monster list", '[', do_cmd_monlist }, 1299 1313 1300 1314 trunk/src/monster2.c
r48 r130 554 554 void display_monlist(void) 555 555 { 556 int idx, n; 557 int line = 0; 556 int i, n; 557 int line = 1, x = 0; 558 unsigned total_count = 0; 559 560 byte attr; 558 561 559 562 char *m_name; … … 563 566 monster_race *r_ptr; 564 567 565 u16b *race_counts; 566 568 u16b *race_count; 569 570 571 /* Clear the term if in a subwindow, set x otherwise */ 572 if (Term != angband_term[0]) 573 clear_from(0); 574 else 575 x = 13; 567 576 568 577 /* Allocate the array */ 569 C_MAKE(race_count s, z_info->r_max, u16b);570 571 /* Iterate over mon_list */572 for (i dx = 1; idx < mon_max; idx++)573 { 574 m_ptr = &mon_list[i dx];578 C_MAKE(race_count, z_info->r_max, u16b); 579 580 /* Scan the monster list */ 581 for (i = 1; i < mon_max; i++) 582 { 583 m_ptr = &mon_list[i]; 575 584 576 585 /* Only visible monsters */ 577 586 if (!m_ptr->ml) continue; 578 587 579 /* Bump the count for this race */ 580 race_counts[m_ptr->r_idx]++; 581 } 582 583 584 /* Iterate over mon_list ( again :-/ ) */ 585 for (idx = 1; idx < mon_max; idx++) 586 { 587 m_ptr = &mon_list[idx]; 588 589 /* Only visible monsters */ 590 if (!m_ptr->ml) continue; 591 592 /* Do each race only once */ 593 if (!race_counts[m_ptr->r_idx]) continue; 594 595 /* Get monster race */ 596 r_ptr = &r_info[m_ptr->r_idx]; 597 598 /* Get the monster name */ 588 /* Bump the count for this race, and the total count */ 589 race_count[m_ptr->r_idx]++; 590 total_count++; 591 } 592 593 /* Note no visible monsters */ 594 if (!total_count) 595 { 596 /* Clear display and print note */ 597 c_prt(TERM_SLATE, "You see no monsters.", 0, 0); 598 if (Term == angband_term[0]) 599 Term_addstr(-1, TERM_WHITE, " (Press any key to continue.)"); 600 601 /* Free up memory */ 602 FREE(race_count); 603 604 /* Done */ 605 return; 606 } 607 608 /* Go over */ 609 for (i = 1; i < z_info->r_max; i++) 610 { 611 /* No monsters of this race are visible */ 612 if (!race_count[i]) continue; 613 614 /* Get monster race and name */ 615 r_ptr = &r_info[i]; 599 616 m_name = r_name + r_ptr->name; 600 617 601 /* Obtain the length of the description */ 602 n = strlen(m_name); 603 604 /* Display the entry itself */ 605 Term_putstr(0, line, n, TERM_WHITE, m_name); 606 607 /* Append the "standard" attr/char info */ 608 Term_addstr(-1, TERM_WHITE, " ('"); 609 Term_addch(r_ptr->d_attr, r_ptr->d_char); 610 Term_addstr(-1, TERM_WHITE, "')"); 611 n += 6; 612 613 /* Append the "optional" attr/char info */ 614 Term_addstr(-1, TERM_WHITE, "/('"); 615 616 Term_addch(r_ptr->x_attr, r_ptr->x_char); 617 618 if (use_bigtile) 619 { 620 if (r_ptr->x_attr & 0x80) 621 Term_addch(255, -1); 622 else 623 Term_addch(0, ' '); 624 625 n++; 626 } 627 628 Term_addstr(-1, TERM_WHITE, "'):"); 629 n += 7; 630 631 /* Add race count */ 632 sprintf(buf, "%d", race_counts[m_ptr->r_idx]); 633 Term_addch(TERM_WHITE, '['); 634 Term_addstr(strlen(buf), TERM_WHITE, buf); 635 Term_addch(TERM_WHITE, ']'); 636 n += strlen(buf) + 2; 637 638 /* Don't do this race again */ 639 race_counts[m_ptr->r_idx] = 0; 640 641 /* Erase the rest of the line */ 642 Term_erase(n, line, 255); 643 644 /* Bump line counter */ 618 /* Display uniques in a special colour */ 619 if (r_ptr->flags1 & RF1_UNIQUE) 620 attr = TERM_VIOLET; 621 else 622 attr = TERM_WHITE; 623 624 /* Build the monster name */ 625 if (race_count[i] == 1) 626 my_strcpy(buf, m_name, sizeof(buf)); 627 else 628 strnfmt(buf, sizeof(buf), "%s (x%d) ", m_name, race_count[i]); 629 630 /* Display the pict */ 631 Term_putch(x, line, r_ptr->x_attr, r_ptr->x_char); 632 Term_putch(x + 1, line, TERM_WHITE, ' '); 633 634 /* Print and bump line counter */ 635 c_prt(attr, buf, line, x + 2); 645 636 line++; 646 637 } 647 638 639 /* Clear a line for main-term display */ 640 prt("", line, x); 641 642 /* Message */ 643 prt(format("You can see %d monster%s:", 644 total_count, (total_count > 1 ? "s" : "")), 0, 0); 645 if (Term == angband_term[0]) 646 Term_addstr(-1, TERM_WHITE, " (Press any key to continue.)"); 647 648 648 /* Free the race counters */ 649 FREE(race_counts); 650 651 /* Erase the rest of the window */ 652 for (idx = line; idx < Term->hgt; idx++) 653 { 654 /* Erase the line */ 655 Term_erase(0, idx, 255); 656 } 649 FREE(race_count); 657 650 } 658 651 trunk/src/z-file.c
r128 r130 827 827 { 828 828 WIN32_FIND_DATA fd; 829 HANDLE h; 829 830 ang_dir *dir; 830 831 832 /* Try to open it */ 833 h = FindFirstFile(format("%s\\*", dirname), &fd); 834 835 /* Abort */ 836 if (h == INVALID_HANDLE_VALUE) 837 return NULL; 838 839 /* Allocate for the handle */ 831 840 dir = ralloc(sizeof dir); 832 841 if (!dir) return NULL; 833 842 834 /* Try to open it */ 835 dir->h = FindFirstFile(format("%s\\*", dirname), &fd); 836 837 /* Abort */ 838 if (dir->h == INVALID_HANDLE_VALUE) 839 { 840 FREE(dir); 841 return NULL; 842 } 843 844 /* Remember this one */ 843 /* Remember details */ 844 dir->h = h; 845 845 dir->first_file = string_make(fd.cFileName); 846 846 … … 917 917 { 918 918 ang_dir *dir; 919 919 DIR d; 920 921 /* Try to open the directory */ 922 d = opendir(dirname); 923 if (!dir->d) return NULL; 924 925 /* Allocate memory for the handle */ 920 926 dir = ralloc(sizeof dir); 921 927 if (!dir) return NULL; 922 928 923 /* Try to open the directory */ 924 dir->d = opendir(dirname); 925 if (!dir->d) 926 { 927 FREE(dir); 928 return NULL; 929 } 929 /* Set up the handle */ 930 dir->d = d; 930 931 931 932 /* Success */
