Changeset 193
- Timestamp:
- 06/17/07 11:35:10 (1 year ago)
- Files:
-
- trunk/src/cmd4.c (modified) (76 diffs)
- trunk/src/h-basic.h (modified) (5 diffs)
- trunk/src/z-file.c (modified) (1 diff)
- trunk/src/z-term.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/cmd4.c
r191 r193 22 22 23 23 24 25 /* 26 * Code cleanup -- Pete Mack 02/2007 27 * Use proper function tables and database methodology. 28 * Tables are now tables, not multiline conditionals. 29 * Joins are now relational, not ad hoc. 30 * Function tables are used for iteration where reasonable. (C-style class model) 31 */ 24 static void do_cmd_pref_file_hack(long row); 25 32 26 33 27 … … 70 64 typedef struct 71 65 { 72 int maxnum; /* Maximum possible item count for this class */ 73 bool easy_know; /* Items don't need to be IDed to recognize membership */ 74 75 const char *(*name)(int gid); /* name of this group */ 76 77 /* Compare, in group and display order */ 78 /* Optional, if already sorted */ 79 int (*gcomp)(const void *, const void *); /* Compare GroupIDs of two oids */ 80 int (*group)(int oid); /* Group ID for of an oid */ 81 82 /* summary function for the "object" information. */ 66 int maxnum; /* Maximum possible item count for this class */ 67 bool easy_know; /* Items don't need to be IDed to recognize membership */ 68 69 const char *(*name)(int gid); /* Name of this group */ 70 71 /* Compare, in group and display order (optional if already sorted) */ 72 int (*gcomp)(const void *, const void *); /* Compares gids of two oids */ 73 int (*group)(int oid); /* Returns gid for an oid */ 74 75 /* Summary function for the "object" information. */ 83 76 void (*summary)(int gid, const int *object_list, int n, int top, int row, int col); 84 77 … … 87 80 typedef struct 88 81 { 89 /* Print a tabular-formatted description for an oid */ 90 /* This includes things like kill-count, the current graphic, */ 91 /* any tile illumination info. Item id for Wizard mode and */ 92 /* autoinscription are handled by the caller */ 82 /* Displays an entry at specified location, including kill-count and graphics */ 93 83 void (*display_member)(int col, int row, bool cursor, int oid); 94 84 95 void (*lore)(int oid); /* Dump known lore to screen*/85 void (*lore)(int oid); /* Displays lore for an oid */ 96 86 97 87 98 88 /* Required only for objects with modifiable display attributes */ 99 89 /* Unknown 'flavors' return flavor attributes */ 100 char *(*xchar)(int oid); /* get character attr for OID (by address) */ 101 byte *(*xattr)(int oid); /* get color attr for OID (by address) */ 102 103 104 const char *(*xtra_prompt)(int oid); /* For kinds that need extra prompts */ 105 void (*xtra_act)(char ch, int oid); /* For kinds that need extra actions */ 106 107 108 /* extra context for display of members */ 109 bool is_visual; 110 90 char *(*xchar)(int oid); /* Get character attr for OID (by address) */ 91 byte *(*xattr)(int oid); /* Get color attr for OID (by address) */ 92 93 const char *(*xtra_prompt)(int oid); /* Returns optional extra prompt */ 94 void (*xtra_act)(char ch, int oid); /* Handles optional extra actions */ 95 96 bool is_visual; /* Does this kind have visual editing? */ 111 97 112 98 } member_funcs; … … 134 120 135 121 static int *obj_group_order; 122 136 123 /* 137 124 * Description of each monster group. … … 226 213 227 214 /* 228 * Clipboard variables for copy&paste in visual mode215 * Clipboard variables for copy&paste in visual mode 229 216 */ 230 217 static byte attr_idx = 0; … … 237 224 { 238 225 feature_type *f_ptr = &f_info[feat]; 239 switch(f_ptr->d_char) 226 227 switch (f_ptr->d_char) 240 228 { 241 229 case '.': return 0; … … 248 236 249 237 default: 238 { 250 239 if (isdigit(f_ptr->d_char)) return 7; 251 240 return 8; 252 } 253 } 254 255 256 /* HACK */ 257 static const int use_dbltile = 0; 258 static const int use_trptile = 0; 241 } 242 } 243 } 244 259 245 260 246 /* Emit a 'graphical' symbol and a padding character if appropriate */ … … 263 249 Term_putch(col, row, a, c); 264 250 if (!use_bigtile) return; 265 if (a &0x80) Term_putch(col+1, row, 255, -1); 266 else Term_putch(col+1, row, 1, ' '); 267 } 268 269 static int actual_width(int width) { 270 if (use_trptile) width = width * 3; 251 252 if (a & 0x80) 253 Term_putch(col + 1, row, 255, -1); 254 else 255 Term_putch(col + 1, row, 1, ' '); 256 } 257 258 /* Return the actual width of a symbol */ 259 static int actual_width(int width) 260 { 261 #ifdef UNANGBAND 262 if (use_trptile) width *= 3; 271 263 else if (use_dbltile) width *= 2; 264 #endif 265 272 266 if (use_bigtile) width *= 2; 273 return width; 274 } 275 276 static int actual_height(int height) { 277 if (use_bigtile) height *= 2; 267 268 return width; 269 } 270 271 /* Return the actual height of a symbol */ 272 static int actual_height(int height) 273 { 274 #ifdef UNANGBAND 278 275 if (use_trptile) height = height * 3 / 2; 279 276 else if (use_dbltile) height *= 2; 277 #endif 278 279 if (use_bigtile) height *= 2; 280 280 281 return height; 281 282 } 282 283 284 285 /* From an actual width, return the logical width */ 283 286 static int logical_width(int width) 284 287 { 285 288 int div = 1; 289 290 #ifdef UNANGBAND 286 291 if (use_trptile) div = 3; 287 else if (use_dbltile) div *= 2; 292 else if (use_dbltile) div = 2; 293 #endif 294 288 295 if (use_bigtile) div *= 2; 296 289 297 return width / div; 290 298 } 291 299 300 /* From an actual height, return the logical height */ 292 301 static int logical_height(int height) 293 302 { 294 303 int div = 1; 304 305 #ifdef UNANGBAND 295 306 if (use_trptile) 296 307 { … … 299 310 } 300 311 else if (use_dbltile) div = 2; 312 #endif 313 301 314 if (use_bigtile) div *= 2; 315 302 316 return height / div; 303 317 } … … 307 321 bool cursor, int row, int col, int wid) 308 322 { 309 member_funcs *o_funcs = (member_funcs*)menu->menu_data;323 const member_funcs *o_funcs = menu->menu_data; 310 324 byte attr = curs_attrs[CURS_KNOWN][cursor == oid]; 311 325 … … 313 327 o_funcs->display_member(col, row, cursor, oid); 314 328 315 if (p_ptr->wizard) c_put_str(attr, format("%d", oid), row, 60); 329 #if 0 /* Debugging code */ 330 c_put_str(attr, format("%d", oid), row, 60); 331 #endif 316 332 317 333 /* Do visual mode */ … … 320 336 char c = *o_funcs->xchar(oid); 321 337 byte a = *o_funcs->xattr(oid); 338 322 339 c_put_str(attr, format((c & 0x80) ? "%02x/%02x" : "%02x/%d", a, c), row, 60); 323 340 } … … 387 404 int omode = rogue_like_commands; 388 405 406 389 407 /* Get size */ 390 408 Term_get_size(&wid, &hgt); 391 409 browser_rows = hgt - 8; 392 410 411 /* Disable the roguelike commands for the duration */ 412 rogue_like_commands = FALSE; 413 414 415 393 416 /* Do the group by. ang_sort only works on (void **) */ 394 417 /* Maybe should make this a precondition? */ 395 418 if (g_funcs.gcomp) 396 qsort(obj_list, o_count, sizeof(*obj_list), g_funcs.gcomp); 397 398 C_MAKE(g_list, max_group+1, int); 399 C_MAKE(g_offset, max_group+1, int); 419 qsort(obj_list, o_count, sizeof(*obj_list), g_funcs.gcomp); 420 421 422 /* Sort everything into group order */ 423 C_MAKE(g_list, max_group + 1, int); 424 C_MAKE(g_offset, max_group + 1, int); 400 425 401 426 for (i = 0; i < o_count; i++) … … 408 433 } 409 434 } 435 410 436 g_offset[grp_cnt] = o_count; 411 437 g_list[grp_cnt] = -1; 412 438 439 413 440 /* The compact set of group names, in display order */ 414 441 C_MAKE(g_names, grp_cnt, const char **); 442 415 443 for (i = 0; i < grp_cnt; i++) 416 444 { … … 420 448 if (len > g_name_len) g_name_len = len; 421 449 } 450 422 451 /* Reasonable max group name len */ 423 452 if (g_name_len >= 20) g_name_len = 20; 424 453 425 object_region.col = g_name_len +3;454 object_region.col = g_name_len + 3; 426 455 group_region.width = g_name_len; 427 456 428 /* Disable the roguelike commands for the duration */429 rogue_like_commands = FALSE;430 457 431 458 /* Leave room for the group summary information */ 432 459 if (g_funcs.summary) object_region.page_rows = -3; 433 460 461 462 /* Set up the two menus */ 434 463 WIPE(&group_menu, menu_type); 435 464 group_menu.count = grp_cnt; … … 454 483 { 455 484 event_type ke, ke0; 485 456 486 if (redraw) 457 487 { 488 /* Print the title bits */ 458 489 region_erase(&title_area); 459 490 prt(format("Knowledge - %s", title), 2, 0); … … 461 492 prt("Name", 4, g_name_len + 3); 462 493 463 Term_gotoxy(55, 4);464 494 if (otherfields) 465 Term_addstr(-1, TERM_WHITE, otherfields); 466 467 for (i = 0; i < 78; i++) 495 prt(otherfields, 4, 55); 496 497 498 /* Print dividers: horizontal and vertical */ 499 for (i = 0; i < 79; i++) 468 500 Term_putch(i, 5, TERM_WHITE, '='); 469 501 … … 471 503 Term_putch(g_name_len + 1, 6 + i, TERM_WHITE, '|'); 472 504 505 506 /* Reset redraw flag */ 473 507 redraw = FALSE; 474 508 } … … 502 536 oid = obj_list[g_offset[g_cur]+o_cur]; 503 537 504 /* Pr ompt */538 /* Print prompt */ 505 539 { 506 540 const char *pedit = (!o_funcs.xattr) ? "" : 507 541 (!(attr_idx|char_idx) ? ", 'c' to copy" : ", 'c', 'p' to paste"); 508 509 const char *pvs = o_funcs.xattr ? ", 'v' for visuals" : "";510 542 const char *xtra = o_funcs.xtra_prompt ? o_funcs.xtra_prompt(oid) : ""; 511 512 if (visual_list) 513 prt(format("<dir>, 'r' to recall, ENTER to accept%s, ESC", pedit), hgt-1, 0); 514 else 515 prt(format("<dir>, 'r' to recall%s%s%s, ESC", pvs, pedit, xtra), hgt-1, 0); 543 const char *pvs = ""; 544 545 if (visual_list) pvs = ", ENTER to accept"; 546 else if (o_funcs.xattr) pvs = ", 'v' for visuals"; 547 548 prt(format("<dir>, 'r' to recall%s%s%s, ESC", pvs, pedit, xtra), hgt - 1, 0); 516 549 } 517 550 … … 521 554 swap(active_menu, inactive_menu); 522 555 swap(active_cursor, inactive_cursor); 523 panel = 1 -panel;556 panel = 1 - panel; 524 557 } 525 558 526 559 if (g_funcs.summary && !visual_list) 560 { 527 561 g_funcs.summary(g_cur, obj_list, g_o_count, g_offset[g_cur], 528 object_menu.boundary.row + object_menu.boundary.page_rows, object_region.col); 562 object_menu.boundary.row + object_menu.boundary.page_rows, 563 object_region.col); 564 } 565 529 566 menu_refresh(inactive_menu); 530 567 menu_refresh(active_menu); 568 531 569 handle_stuff(); 532 570 … … 551 589 552 590 ke = inkey_ex(); 591 553 592 /* Do visual mode command if needed */ 554 593 if (o_funcs.xattr && o_funcs.xchar && … … 575 614 ke0 = run_event_loop(&active_menu->target, 0, &ke); 576 615 if (ke0.type != EVT_AGAIN) ke = ke0; 577 switch(ke.type) 616 617 switch (ke.type) 578 618 { 579 619 case EVT_KBRD: 620 { 580 621 break; 622 } 623 581 624 case ESCAPE: 625 { 582 626 flag = TRUE; 583 627 continue; 628 } 629 584 630 case EVT_SELECT: 631 { 585 632 if (panel == 1 && oid >= 0 && o_cur == active_menu->cursor) 586 633 { … … 588 635 redraw = TRUE; 589 636 } 637 } 638 590 639 case EVT_MOVE: 640 { 591 641 *active_cursor = active_menu->cursor; 592 642 continue; 643 } 644 593 645 case EVT_BACK: 646 { 594 647 if (panel == 1) 595 648 do_swap = TRUE; 649 } 650 651 /* XXX Handle EVT_RESIZE */ 652 596 653 default: 654 { 597 655 continue; 656 } 598 657 } 599 658 … … 641 700 } 642 701 702 /* Restore roguelike option */ 643 703 rogue_like_commands = omode; 644 704 … … 657 717 static void display_visual_list(int col, int row, int height, int width, byte attr_top, char char_left) 658 718 { 659 int i, j; 660 661 /* Clear the display lines */ 662 for (i = 0; i < height; i++) 663 { 664 Term_erase(col, row + i, width); 665 } 666 667 width = logical_width(width); 668 669 /* Display lines until done */ 670 for (i = 0; i < height; i++) 671 { 672 /* Display columns until done */ 673 for (j = 0; j < width; j++) 674 { 675 byte a; 676 char c; 677 int x = col + actual_width(j); 678 int y = row + actual_width(i); 679 int ia, ic; 680 681 ia = attr_top + i; 682 ic = char_left + j; 683 684 a = (byte)ia; 685 c = (char)ic; 686 687 /* Display symbol */ 688 big_pad(x, y, a, c); 689 } 690 } 719 int i, j; 720 721 /* Clear the display lines */ 722 for (i = 0; i < height; i++) 723 Term_erase(col, row + i, width); 724 725 width = logical_width(width); 726 727 /* Display lines until done */ 728 for (i = 0; i < height; i++) 729 { 730 /* Display columns until done */ 731 for (j = 0; j < width; j++) 732 { 733 byte a; 734 char c; 735 int x = col + actual_width(j); 736 int y = row + actual_width(i); 737 int ia, ic; 738 739 ia = attr_top + i; 740 ic = char_left + j; 741 742 a = (byte)ia; 743 c = (char)ic; 744 745 /* Display symbol */ 746 big_pad(x, y, a, c); 747 } 748 } 691 749 } 692 750 … … 728 786 { 729 787 case ESCAPE: 788 { 730 789 if (*visual_list_ptr) 731 790 { … … 737 796 return TRUE; 738 797 } 798 739 799 break; 800 } 740 801 741 802 case '\n': 742 803 case '\r': 804 { 743 805 if (*visual_list_ptr) 744 806 { 745 807 /* Accept change */ 746 808 *visual_list_ptr = FALSE; 747 748 809 return TRUE; 749 810 } 811 750 812 break; 813 } 751 814 752 815 case 'V': 753 816 case 'v': 817 { 754 818 if (!*visual_list_ptr) 755 819 { … … 761 825 attr_old = *cur_attr_ptr; 762 826 char_old = *cur_char_ptr; 763 764 return TRUE;765 827 } 766 828 else … … 770 832 *cur_char_ptr = char_old; 771 833 *visual_list_ptr = FALSE; 772 773 return TRUE;774 834 } 775 break; 835 836 return TRUE; 837 } 776 838 777 839 case 'C': 778 840 case 'c': 841 { 779 842 /* Set the visual */ 780 843 attr_idx = *cur_attr_ptr; … … 782 845 783 846 return TRUE; 847 } 784 848 785 849 case 'P': 786 850 case 'p': 851 { 787 852 if (attr_idx) 788 853 { … … 800 865 801 866 return TRUE; 867 } 802 868 803 869 default: … … 822 888 if ((my >= 0) && (my < eff_height) && (mx >= 0) && (mx < eff_width) 823 889 && ((ke.index) || (a != *attr_top_ptr + my) 824 || (c != *char_left_ptr + mx)) )890 || (c != *char_left_ptr + mx))) 825 891 { 826 892 /* Set the visual */ … … 846 912 return TRUE; 847 913 } 914 848 915 /* Cancel change */ 849 916 else if (ke.index) … … 922 989 c_prt(attr, r_name + r_ptr->name, row, col); 923 990 991 #ifdef UNANGBAND 924 992 if (use_dbltile || use_trptile) 925 993 return; 994 #endif 926 995 927 996 /* Display symbol */ … … 931 1000 if (r_ptr->flags1 & (RF1_UNIQUE)) 932 1001 put_str(format("%s", (r_ptr->max_num == 0)? " dead" : "alive"), row, 70); 933 else put_str(format("%5d", l_ptr->pkills), row, 70); 934 } 935 936 937 static int m_cmp_race(const void *a, const void *b) { 1002 else 1003 put_str(format("%5d", l_ptr->pkills), row, 70); 1004 } 1005 1006 1007 static int m_cmp_race(const void *a, const void *b) 1008 { 938 1009 monster_race *r_a = &r_info[default_join[*(int*)a].oid]; 939 1010 monster_race *r_b = &r_info[default_join[*(int*)b].oid]; 940 1011 int gid = default_join[*(int*)a].gid; 941 /* group by */ 1012 1013 /* Group by */ 942 1014 int c = gid - default_join[*(int*)b].gid; 943 1015 if (c) return c; 944 /* order results */ 1016 1017 /* Order results */ 945 1018 c = r_a->d_char - r_b->d_char; 946 1019 if (c && gid != 0) … … 953 1026 c = r_a->level - r_b->level; 954 1027 if (c) return c; 1028 955 1029 return strcmp(r_name + r_a->name, r_name + r_b->name); 956 1030 } … … 971 1045 kills += l_list[oid].pkills; 972 1046 } 1047 973 1048 if (gid == 0) 974 1049 { 975 c_prt(TERM_L_BLUE, format(" Known Uniques: %d, Slain Uniques: %d.", n, kills),1050 c_prt(TERM_L_BLUE, format("%d known uniques, %d slain.", n, kills), 976 1051 row, col); 977 1052 } … … 979 1054 { 980 1055 int tkills = 0; 1056 981 1057 for (i = 0; i < z_info->r_max; i++) 982 1058 tkills += l_list[i].pkills; 983 c_prt(TERM_L_BLUE, format("Creatures Slain: %d/%d (in group/in total)", kills, tkills), row, col); 1059 1060 c_prt(TERM_L_BLUE, format("Creatures slain: %d/%d (in group/in total)", kills, tkills), row, col); 984 1061 } 985 1062 } … … 1008 1085 1009 1086 if (r_ptr->flags1 & RF1_UNIQUE) m_count++; 1010 for (j = 1; j < N_ELEMENTS(monster_group)-1; j++) 1087 1088 for (j = 1; j < N_ELEMENTS(monster_group) - 1; j++) 1011 1089 { 1012 1090 const char *pat = monster_group[j].chars; … … 1041 1119 display_knowledge("monsters", monsters, m_count, r_funcs, m_funcs, 1042 1120 " Sym Kills"); 1121 KILL(default_join); 1043 1122 FREE(monsters); 1044 FREE(default_join);1045 default_join = 0;1046 1123 } 1047 1124 … … 1093 1170 /* Make fake artifact */ 1094 1171 make_fake_artifact(o_ptr, a_idx); 1095 o_ptr->ident |= IDENT_STORE | IDENT_KNOWN;1172 o_ptr->ident |= (IDENT_STORE | IDENT_KNOWN); 1096 1173 if (cheat_xtra) o_ptr->ident |= IDENT_MENTAL; 1097 1174 … … 1124 1201 } 1125 1202 1126 static const char *kind_name(int gid) 1127 { return object_text_order[gid].name; } 1203 static const char *kind_name(int gid) { return object_text_order[gid].name; } 1128 1204 static int art2tval(int oid) { return a_info[oid].tval; } 1129 1205 … … 1190 1266 { 1191 1267 /* Hack: dereference the join */ 1192 const char *cursed [] = {"permanently cursed", "heavily cursed", "cursed"};1193 const char *xtra [] = {"sustain", "higher resistance", "ability"};1268 const char *cursed[] = { "permanently cursed", "heavily cursed", "cursed" }; 1269 const char *xtra[] = { "sustain", "higher resistance", "ability" }; 1194 1270 int f3, i; 1195 1271 … … 1208 1284 /* Dump the name */ 1209 1285 c_prt(TERM_L_BLUE, format("%s %s", ego_grp_name(default_group(oid)), 1210 e_name+e_ptr->name), 0, 0);1286 e_name + e_ptr->name), 0, 0); 1211 1287 1212 1288 /* Begin recall */ … … 1226 1302 1227 1303 if (e_ptr->xtra) 1228 {1229 1304 text_out(format("It provides one random %s.", xtra[e_ptr->xtra - 1])); 1230 }1231 1305 1232 1306 for (i = 0, f3 = TR3_PERMA_CURSE; i < 3 ; f3 >>= 1, i++) … … 1251 1325 ego_item_type *ea = &e_info[default_join[*(int*)a].oid]; 1252 1326 ego_item_type *eb = &e_info[default_join[*(int*)b].oid]; 1253 /*group by */ 1327 1328 /* Group by */ 1254 1329 int c = default_join[*(int*)a].gid - default_join[*(int*)b].gid; 1255 1330 if (c) return c; 1256 /* order by */ 1331 1332 /* Order by */ 1257 1333 return strcmp(e_name + ea->name, e_name + eb->name); 1258 1334 } … … 1273 1349 1274 1350 /* HACK: currently no more than 3 tvals for one ego type */ 1275 C_MAKE(egoitems, z_info->e_max*EGO_TVALS_MAX, int); 1276 C_MAKE(default_join, z_info->e_max*EGO_TVALS_MAX, join_t); 1351 C_MAKE(egoitems, z_info->e_max * EGO_TVALS_MAX, int); 1352 C_MAKE(default_join, z_info->e_max * EGO_TVALS_MAX, join_t); 1353 1277 1354 for (i = 0; i < z_info->e_max; i++) 1278 1355 { … … 1282 1359 { 1283 1360 int gid = obj_group_order[e_info[i].tval[j]]; 1361 1284 1362 /* Ignore duplicate gids */ 1285 if (j > 0 && gid == default_join[e_count -1].gid)1286 continue; 1363 if (j > 0 && gid == default_join[e_count - 1].gid) continue; 1364 1287 1365 egoitems[e_count] = e_count; 1288 1366 default_join[e_count].oid = i; … … 1293 1371 1294 1372 display_knowledge("ego items", egoitems, e_count, obj_f, ego_f, ""); 1295 FREE(default_join); 1296 default_join = 0;1373 1374 KILL(default_join); 1297 1375 FREE(egoitems); 1298 1376 } … … 1340 1418 c_put_str(TERM_YELLOW, inscrip, row, 55); 1341 1419 1342 1420 #ifdef UNANGBAND 1343 1421 /* Hack - don't use if double tile */ 1344 1422 if (use_dbltile || use_trptile) 1345 1423 return; 1424 #endif 1346 1425 1347 1426 /* Display symbol */ … … 1387 1466 object_kind *k_a = &k_info[*(int*)a]; 1388 1467 object_kind *k_b = &k_info[*(int*)b]; 1389 /*group by */ 1468 1469 /* Group by */ 1390 1470 int ta = obj_group_order[k_a->tval]; 1391 1471 int tb = obj_group_order[k_b->tval]; 1392 1472 int c = ta - tb; 1393 1473 if (c) return c; 1394 /* order by */ 1474 1475 /* Order by */ 1395 1476 c = k_a->aware - k_b->aware; 1396 1477 if (c) return -c; /* aware has low sort weight */ … … 1402 1483 c = k_a->cost - k_b->cost; 1403 1484 if (c) return c; 1485 1404 1486 return strcmp(k_name + k_a->name, k_name + k_b->name); 1405 1487 } 1488 1406 1489 static int obj2gid(int oid) { return obj_group_order[k_info[oid].tval]; } 1407 static char *o_xchar(int oid) { 1490 1491 static char *o_xchar(int oid) 1492 { 1408 1493 object_kind *k_ptr = &k_info[oid]; 1409 if (!k_ptr->flavor || k_ptr->aware) return &k_ptr->x_char; 1410 else return &flavor_info[k_ptr->flavor].x_char; 1411 } 1412 static byte *o_xattr(int oid) { 1494 1495 if (!k_ptr->flavor || k_ptr->aware) 1496 return &k_ptr->x_char; 1497 else 1498 return &flavor_info[k_ptr->flavor].x_char; 1499 } 1500 1501 static byte *o_xattr(int oid) 1502 { 1413 1503 object_kind *k_ptr = &k_info[oid]; 1414 if (!k_ptr->flavor || k_ptr->aware) return &k_ptr->x_attr; 1415 else return &flavor_info[k_ptr->flavor].x_attr; 1504 1505 if (!k_ptr->flavor || k_ptr->aware) 1506 return &k_ptr->x_attr; 1507 else 1508 return &flavor_info[k_ptr->flavor].x_attr; 1416 1509 } 1417 1510 … … 1543 1636 c_prt(attr, f_name + f_ptr->name, row, col); 1544 1637 1545 1638 #ifdef UNANGBAND 1546 1639 if (use_dbltile || use_trptile) return; 1640 #endif 1547 1641 1548 1642 /* Display symbol */ … … 1554 1648 1555 1649 1556 static int f_cmp_fkind(const void *a, const void *b) { 1650 static int f_cmp_fkind(const void *a, const void *b) 1651 { 1557 1652 feature_type *fa = &f_info[*(int*)a]; 1558 1653 feature_type *fb = &f_info[*(int*)b]; … … 1632 1727 flush(); 1633 1728 1634 if ( 0 !=character_dungeon)1729 if (character_dungeon) 1635 1730 verify_panel(); 1636 1731 … … 2024 2119 2025 2120 2026 /* 2027 * Ask for a "user pref line" and process it 2028 */ 2029 void do_cmd_pref(void) 2030 { 2031 char tmp[80]; 2032 2033 /* Default */ 2034 my_strcpy(tmp, "", sizeof(tmp)); 2035 2036 /* Ask for a "user pref command" */ 2037 if (!get_string("Pref: ", tmp, 80)) return; 2038 2039 /* Process that pref command */ 2040 (void)process_pref_file_command(tmp); 2041 } 2042 2043 2044 /* 2045 * Ask for a "user pref file" and process it. 2046 * 2047 * This function should only be used by standard interaction commands, 2048 * in which a standard "Command:" prompt is present on the given row. 2049 * 2050 * Allow absolute file names? XXX XXX XXX 2051 */ 2052 static void do_cmd_pref_file_hack(long row) 2053 { 2054 char ftmp[80]; 2055 2056 /* Prompt */ 2057 prt("Command: Load a user pref file", row, 0); 2058 2059 /* Prompt */ 2060 prt("File: ", row + 2, 0); 2061 2062 /* Default filename */ 2063 strnfmt(ftmp, sizeof ftmp, "%s.prf", op_ptr->base_name); 2064 2065 /* Ask for a file (or cancel) */ 2066 if (!askfor_aux(ftmp, sizeof ftmp, NULL)) return; 2067 2068 /* Process the given filename */ 2069 if (process_pref_file(ftmp)) 2070 { 2071 /* Mention failure */ 2072 msg_format("Failed to load '%s'!", ftmp); 2073 } 2074 else 2075 { 2076 /* Mention success */ 2077 msg_format("Loaded '%s'.", ftmp); 2078 } 2079 inkey_ex(); 2080 } 2081 2082 2121 2122 /*** Options display and setting ***/ 2123 2124 /* 2125 * Displays an option entry. 2126 */ 2083 2127 static void display_option(menu_type *menu, int oid, 2084 2128 bool cursor, int row, int col, int width) 2085 2129 { 2086 2130 byte attr = curs_attrs[CURS_KNOWN][(int)cursor]; 2087 c_prt(attr, format("%-45s: %s (%s)", 2088 option_desc[oid], 2089 op_ptr->opt[oid] ? "yes" : "no ", 2090 option_text[oid]), 2091 row, col); 2092 } 2093 2131 2132 c_prt(attr, format("%-45s: %s (%s)", option_desc[oid], 2133 op_ptr->opt[oid] ? "yes" : "no ", option_text[oid]), 2134 row, col); 2135 } 2136 2137 /* 2138 * Handle keypresses for an option entry. 2139 */ 2094 2140 static bool update_option(char key, void *pgdb, int oid) 2095 2141 { 2096 switch(toupper(key)) 2097 { 2098 case 'Y': case '6': 2099 op_ptr->opt[oid] = TRUE; 2100 break; 2101 case 'N': case '4': 2102 op_ptr->opt[oid] = FALSE; 2103 break; 2104 case 'T': case '5': case '\xff': 2105 op_ptr->opt[oid] = !op_ptr->opt[oid]; 2106 break; 2107 case '?': 2108 show_file(format("option.txt#%s", option_text[oid]), NULL, 0, 0); 2109 break; 2110 } 2142 switch (toupper((unsigned char) key)) 2143 { 2144 case 'Y': 2145 case '6': 2146 { 2147 op_ptr->opt[oid] = TRUE; 2148 break; 2149 } 2150 2151 case 'N': 2152 case '4': 2153 { 2154 op_ptr->opt[oid] = FALSE; 2155 &
