Changeset 193

Show
Ignore:
Timestamp:
06/17/07 11:35:10 (1 year ago)
Author:
takkaria
Message:
  • Angbandify some of the code in cmd4.c; fix indentation, add more spacing/comments
  • Rearrange cmd4.c a bit so it's a bit less of a jumble
  • add a macro EVENT_EMPTY which can be used as an initialiser for event_types
  • Fix Christer Nyfalt's nits in z-file.c and h-basic.h (#157).
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/cmd4.c

    r191 r193  
    2222 
    2323 
    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  */ 
     24static void do_cmd_pref_file_hack(long row); 
     25 
    3226 
    3327 
     
    7064typedef struct 
    7165{ 
    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. */ 
    8376        void (*summary)(int gid, const int *object_list, int n, int top, int row, int col); 
    8477 
     
    8780typedef struct 
    8881{ 
    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 */ 
    9383        void (*display_member)(int col, int row, bool cursor, int oid); 
    9484 
    95         void (*lore)(int oid); /* Dump known lore to screen*/ 
     85        void (*lore)(int oid);       /* Displays lore for an oid */ 
    9686 
    9787 
    9888        /* Required only for objects with modifiable display attributes */ 
    9989        /* 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? */ 
    11197 
    11298} member_funcs; 
     
    134120 
    135121static int *obj_group_order; 
     122 
    136123/* 
    137124 * Description of each monster group. 
     
    226213 
    227214/* 
    228  * Clipboard variables for copy&paste in visual mode 
     215 * Clipboard variables for copy&paste in visual mode 
    229216 */ 
    230217static byte attr_idx = 0; 
     
    237224{ 
    238225        feature_type *f_ptr = &f_info[feat]; 
    239         switch(f_ptr->d_char) 
     226 
     227        switch (f_ptr->d_char) 
    240228        { 
    241229                case '.':                               return 0; 
     
    248236 
    249237                default: 
     238                { 
    250239                        if (isdigit(f_ptr->d_char)) return 7; 
    251240                        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 
    259245 
    260246/* Emit a 'graphical' symbol and a padding character if appropriate */ 
     
    263249        Term_putch(col, row, a, c); 
    264250        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 */ 
     259static int actual_width(int width) 
     260
     261#ifdef UNANGBAND 
     262        if (use_trptile) width *= 3; 
    271263        else if (use_dbltile) width *= 2; 
     264#endif 
     265 
    272266        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 */ 
     272static int actual_height(int height) 
     273
     274#ifdef UNANGBAND 
    278275        if (use_trptile) height = height * 3 / 2; 
    279276        else if (use_dbltile) height *= 2; 
     277#endif 
     278 
     279        if (use_bigtile) height *= 2; 
     280 
    280281        return height; 
    281282} 
    282283 
     284 
     285/* From an actual width, return the logical width */ 
    283286static int logical_width(int width) 
    284287{ 
    285288        int div = 1; 
     289 
     290#ifdef UNANGBAND 
    286291        if (use_trptile) div = 3; 
    287         else if (use_dbltile) div *= 2; 
     292        else if (use_dbltile) div = 2; 
     293#endif 
     294 
    288295        if (use_bigtile) div *= 2; 
     296 
    289297        return width / div; 
    290298} 
    291299 
     300/* From an actual height, return the logical height */ 
    292301static int logical_height(int height) 
    293302{ 
    294303        int div = 1; 
     304 
     305#ifdef UNANGBAND 
    295306        if (use_trptile) 
    296307        { 
     
    299310        } 
    300311        else if (use_dbltile) div = 2; 
     312#endif 
     313 
    301314        if (use_bigtile) div *= 2; 
     315 
    302316        return height / div; 
    303317} 
     
    307321                                                bool cursor, int row, int col, int wid) 
    308322{ 
    309         member_funcs *o_funcs = (member_funcs*) menu->menu_data; 
     323        const member_funcs *o_funcs = menu->menu_data; 
    310324        byte attr = curs_attrs[CURS_KNOWN][cursor == oid]; 
    311325 
     
    313327        o_funcs->display_member(col, row, cursor, oid); 
    314328 
    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 
    316332 
    317333        /* Do visual mode */ 
     
    320336                char c = *o_funcs->xchar(oid); 
    321337                byte a = *o_funcs->xattr(oid); 
     338 
    322339                c_put_str(attr, format((c & 0x80) ? "%02x/%02x" : "%02x/%d", a, c), row, 60); 
    323340        } 
     
    387404        int omode = rogue_like_commands; 
    388405 
     406 
    389407        /* Get size */ 
    390408        Term_get_size(&wid, &hgt); 
    391409        browser_rows = hgt - 8; 
    392410 
     411        /* Disable the roguelike commands for the duration */ 
     412        rogue_like_commands = FALSE; 
     413 
     414 
     415 
    393416        /* Do the group by. ang_sort only works on (void **) */ 
    394417        /* Maybe should make this a precondition? */ 
    395418        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); 
    400425 
    401426        for (i = 0; i < o_count; i++) 
     
    408433                } 
    409434        } 
     435 
    410436        g_offset[grp_cnt] = o_count; 
    411437        g_list[grp_cnt] = -1; 
    412438 
     439 
    413440        /* The compact set of group names, in display order */ 
    414441        C_MAKE(g_names, grp_cnt, const char **); 
     442 
    415443        for (i = 0; i < grp_cnt; i++) 
    416444        { 
     
    420448                if (len > g_name_len) g_name_len = len; 
    421449        } 
     450 
    422451        /* Reasonable max group name len */ 
    423452        if (g_name_len >= 20) g_name_len = 20; 
    424453 
    425         object_region.col = g_name_len+3; 
     454        object_region.col = g_name_len + 3; 
    426455        group_region.width = g_name_len; 
    427456 
    428         /* Disable the roguelike commands for the duration */ 
    429         rogue_like_commands = FALSE; 
    430457 
    431458        /* Leave room for the group summary information */ 
    432459        if (g_funcs.summary) object_region.page_rows = -3; 
    433460 
     461 
     462        /* Set up the two menus */ 
    434463        WIPE(&group_menu, menu_type); 
    435464        group_menu.count = grp_cnt; 
     
    454483        { 
    455484                event_type ke, ke0; 
     485 
    456486                if (redraw) 
    457487                { 
     488                        /* Print the title bits */ 
    458489                        region_erase(&title_area); 
    459490                        prt(format("Knowledge - %s", title), 2, 0); 
     
    461492                        prt("Name", 4, g_name_len + 3); 
    462493 
    463                         Term_gotoxy(55, 4); 
    464494                        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++) 
    468500                                Term_putch(i, 5, TERM_WHITE, '='); 
    469501 
     
    471503                                Term_putch(g_name_len + 1, 6 + i, TERM_WHITE, '|'); 
    472504 
     505 
     506                        /* Reset redraw flag */ 
    473507                        redraw = FALSE; 
    474508                } 
     
    502536                oid = obj_list[g_offset[g_cur]+o_cur]; 
    503537 
    504                 /* Prompt */ 
     538                /* Print prompt */ 
    505539                { 
    506540                        const char *pedit = (!o_funcs.xattr) ? "" : 
    507541                                        (!(attr_idx|char_idx) ? ", 'c' to copy" : ", 'c', 'p' to paste"); 
    508  
    509                         const char *pvs =  o_funcs.xattr       ? ", 'v' for visuals"      : ""; 
    510542                        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); 
    516549                } 
    517550 
     
    521554                        swap(active_menu, inactive_menu); 
    522555                        swap(active_cursor, inactive_cursor); 
    523                         panel = 1-panel; 
     556                        panel = 1 - panel; 
    524557                } 
    525558 
    526559                if (g_funcs.summary && !visual_list) 
     560                { 
    527561                        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 
    529566                menu_refresh(inactive_menu); 
    530567                menu_refresh(active_menu); 
     568 
    531569                handle_stuff(); 
    532570 
     
    551589 
    552590                ke = inkey_ex(); 
     591 
    553592                /* Do visual mode command if needed */ 
    554593                if (o_funcs.xattr && o_funcs.xchar && 
     
    575614                ke0 = run_event_loop(&active_menu->target, 0, &ke); 
    576615                if (ke0.type != EVT_AGAIN) ke = ke0; 
    577                 switch(ke.type) 
     616 
     617                switch (ke.type) 
    578618                { 
    579619                        case EVT_KBRD: 
     620                        { 
    580621                                break; 
     622                        } 
     623 
    581624                        case ESCAPE: 
     625                        { 
    582626                                flag = TRUE; 
    583627                                continue; 
     628                        } 
     629 
    584630                        case EVT_SELECT: 
     631                        { 
    585632                                if (panel == 1 && oid >= 0 && o_cur == active_menu->cursor) 
    586633                                { 
     
    588635                                        redraw = TRUE; 
    589636                                } 
     637                        } 
     638 
    590639                        case EVT_MOVE: 
     640                        { 
    591641                                *active_cursor = active_menu->cursor; 
    592642                                continue; 
     643                        } 
     644 
    593645                        case EVT_BACK: 
     646                        { 
    594647                                if (panel == 1) 
    595648                                        do_swap = TRUE; 
     649                        } 
     650 
     651                        /* XXX Handle EVT_RESIZE */ 
     652 
    596653                        default: 
     654                        { 
    597655                                continue; 
     656                        } 
    598657                } 
    599658 
     
    641700        } 
    642701 
     702        /* Restore roguelike option */ 
    643703        rogue_like_commands = omode; 
    644704 
     
    657717static void display_visual_list(int col, int row, int height, int width, byte attr_top, char char_left) 
    658718{ 
    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        } 
    691749} 
    692750 
     
    728786        { 
    729787                case ESCAPE: 
     788                { 
    730789                        if (*visual_list_ptr) 
    731790                        { 
     
    737796                                return TRUE; 
    738797                        } 
     798 
    739799                        break; 
     800                } 
    740801 
    741802                case '\n': 
    742803                case '\r': 
     804                { 
    743805                        if (*visual_list_ptr) 
    744806                        { 
    745807                                /* Accept change */ 
    746808                                *visual_list_ptr = FALSE; 
    747  
    748809                                return TRUE; 
    749810                        } 
     811 
    750812                        break; 
     813                } 
    751814 
    752815                case 'V': 
    753816                case 'v': 
     817                { 
    754818                        if (!*visual_list_ptr) 
    755819                        { 
     
    761825                                attr_old = *cur_attr_ptr; 
    762826                                char_old = *cur_char_ptr; 
    763  
    764                                 return TRUE; 
    765827                        } 
    766828                        else 
     
    770832                                *cur_char_ptr = char_old; 
    771833                                *visual_list_ptr = FALSE; 
    772  
    773                                 return TRUE; 
    774834                        } 
    775                         break; 
     835 
     836                        return TRUE; 
     837                } 
    776838 
    777839                case 'C': 
    778840                case 'c': 
     841                { 
    779842                        /* Set the visual */ 
    780843                        attr_idx = *cur_attr_ptr; 
     
    782845 
    783846                        return TRUE; 
     847                } 
    784848 
    785849                case 'P': 
    786850                case 'p': 
     851                { 
    787852                        if (attr_idx) 
    788853                        { 
     
    800865 
    801866                        return TRUE; 
     867                } 
    802868 
    803869                default: 
     
    822888                                        if ((my >= 0) && (my < eff_height) && (mx >= 0) && (mx < eff_width) 
    823889                                                && ((ke.index) || (a != *attr_top_ptr + my) 
    824                                                         || (c != *char_left_ptr + mx))
     890                                                        || (c != *char_left_ptr + mx))
    825891                                        { 
    826892                                                /* Set the visual */ 
     
    846912                                                return TRUE; 
    847913                                        } 
     914 
    848915                                        /* Cancel change */ 
    849916                                        else if (ke.index) 
     
    922989        c_prt(attr, r_name + r_ptr->name, row, col); 
    923990 
     991#ifdef UNANGBAND 
    924992        if (use_dbltile || use_trptile) 
    925993                return; 
     994#endif 
    926995 
    927996        /* Display symbol */ 
     
    9311000        if (r_ptr->flags1 & (RF1_UNIQUE)) 
    9321001                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 
     1007static int m_cmp_race(const void *a, const void *b) 
     1008
    9381009        monster_race *r_a = &r_info[default_join[*(int*)a].oid]; 
    9391010        monster_race *r_b = &r_info[default_join[*(int*)b].oid]; 
    9401011        int gid = default_join[*(int*)a].gid; 
    941         /* group by */ 
     1012 
     1013        /* Group by */ 
    9421014        int c = gid - default_join[*(int*)b].gid; 
    9431015        if (c) return c; 
    944         /* order results */ 
     1016 
     1017        /* Order results */ 
    9451018        c = r_a->d_char - r_b->d_char; 
    9461019        if (c && gid != 0) 
     
    9531026        c = r_a->level - r_b->level; 
    9541027        if (c) return c; 
     1028 
    9551029        return strcmp(r_name + r_a->name, r_name + r_b->name); 
    9561030} 
     
    9711045                kills += l_list[oid].pkills; 
    9721046        } 
     1047 
    9731048        if (gid == 0) 
    9741049        { 
    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), 
    9761051                                        row, col); 
    9771052        } 
     
    9791054        { 
    9801055                int tkills = 0; 
     1056 
    9811057                for (i = 0; i < z_info->r_max; i++)  
    9821058                        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); 
    9841061        } 
    9851062} 
     
    10081085 
    10091086                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++) 
    10111089                { 
    10121090                        const char *pat = monster_group[j].chars; 
     
    10411119        display_knowledge("monsters", monsters, m_count, r_funcs, m_funcs, 
    10421120                                                "          Sym  Kills"); 
     1121        KILL(default_join); 
    10431122        FREE(monsters); 
    1044         FREE(default_join); 
    1045         default_join = 0; 
    10461123} 
    10471124 
     
    10931170        /* Make fake artifact */ 
    10941171        make_fake_artifact(o_ptr, a_idx); 
    1095         o_ptr->ident |= IDENT_STORE | IDENT_KNOWN
     1172        o_ptr->ident |= (IDENT_STORE | IDENT_KNOWN)
    10961173        if (cheat_xtra) o_ptr->ident |= IDENT_MENTAL; 
    10971174 
     
    11241201} 
    11251202 
    1126 static const char *kind_name(int gid) 
    1127 { return object_text_order[gid].name; } 
     1203static const char *kind_name(int gid) { return object_text_order[gid].name; } 
    11281204static int art2tval(int oid) { return a_info[oid].tval; } 
    11291205 
     
    11901266{ 
    11911267        /* 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" }; 
    11941270        int f3, i; 
    11951271 
     
    12081284        /* Dump the name */ 
    12091285        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); 
    12111287 
    12121288        /* Begin recall */ 
     
    12261302 
    12271303        if (e_ptr->xtra) 
    1228         { 
    12291304                text_out(format("It provides one random %s.", xtra[e_ptr->xtra - 1])); 
    1230         } 
    12311305 
    12321306        for (i = 0, f3 = TR3_PERMA_CURSE; i < 3 ; f3 >>= 1, i++) 
     
    12511325        ego_item_type *ea = &e_info[default_join[*(int*)a].oid]; 
    12521326        ego_item_type *eb = &e_info[default_join[*(int*)b].oid]; 
    1253         /*group by */ 
     1327 
     1328        /* Group by */ 
    12541329        int c = default_join[*(int*)a].gid - default_join[*(int*)b].gid; 
    12551330        if (c) return c; 
    1256         /* order by */ 
     1331 
     1332        /* Order by */ 
    12571333        return strcmp(e_name + ea->name, e_name + eb->name); 
    12581334} 
     
    12731349 
    12741350        /* 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 
    12771354        for (i = 0; i < z_info->e_max; i++) 
    12781355        { 
     
    12821359                        { 
    12831360                                int gid = obj_group_order[e_info[i].tval[j]]; 
     1361 
    12841362                                /* 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 
    12871365                                egoitems[e_count] = e_count; 
    12881366                                default_join[e_count].oid = i; 
     
    12931371 
    12941372        display_knowledge("ego items", egoitems, e_count, obj_f, ego_f, ""); 
    1295         FREE(default_join); 
    1296         default_join = 0
     1373 
     1374        KILL(default_join)
    12971375        FREE(egoitems); 
    12981376} 
     
    13401418                c_put_str(TERM_YELLOW, inscrip, row, 55); 
    13411419 
    1342  
     1420#ifdef UNANGBAND 
    13431421        /* Hack - don't use if double tile */ 
    13441422        if (use_dbltile || use_trptile) 
    13451423                return; 
     1424#endif 
    13461425 
    13471426        /* Display symbol */ 
     
    13871466        object_kind *k_a = &k_info[*(int*)a]; 
    13881467        object_kind *k_b = &k_info[*(int*)b]; 
    1389         /*group by */ 
     1468 
     1469        /* Group by */ 
    13901470        int ta = obj_group_order[k_a->tval]; 
    13911471        int tb = obj_group_order[k_b->tval]; 
    13921472        int c = ta - tb; 
    13931473        if (c) return c; 
    1394         /* order by */ 
     1474 
     1475        /* Order by */ 
    13951476        c = k_a->aware - k_b->aware; 
    13961477        if (c) return -c; /* aware has low sort weight */ 
     
    14021483        c = k_a->cost - k_b->cost; 
    14031484        if (c) return c; 
     1485 
    14041486        return strcmp(k_name + k_a->name, k_name + k_b->name); 
    14051487} 
     1488 
    14061489static int obj2gid(int oid) { return obj_group_order[k_info[oid].tval]; } 
    1407 static char *o_xchar(int oid) { 
     1490 
     1491static char *o_xchar(int oid) 
     1492
    14081493        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 
     1501static byte *o_xattr(int oid) 
     1502
    14131503        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; 
    14161509} 
    14171510 
     
    15431636        c_prt(attr, f_name + f_ptr->name, row, col); 
    15441637 
    1545  
     1638#ifdef UNANGBAND 
    15461639        if (use_dbltile || use_trptile) return; 
     1640#endif 
    15471641 
    15481642        /* Display symbol */ 
     
    15541648 
    15551649 
    1556 static int f_cmp_fkind(const void *a, const void *b) { 
     1650static int f_cmp_fkind(const void *a, const void *b) 
     1651
    15571652        feature_type *fa = &f_info[*(int*)a]; 
    15581653        feature_type *fb = &f_info[*(int*)b]; 
     
    16321727        flush(); 
    16331728         
    1634         if (0 != character_dungeon) 
     1729        if (character_dungeon) 
    16351730                verify_panel(); 
    16361731 
     
    20242119 
    20252120 
    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 */ 
    20832127static void display_option(menu_type *menu, int oid, 
    20842128                                                        bool cursor, int row, int col, int width) 
    20852129{ 
    20862130        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 */ 
    20942140static bool update_option(char key, void *pgdb, int oid) 
    20952141{ 
    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            &