Changeset 125

Show
Ignore:
Timestamp:
05/08/07 21:04:38 (1 year ago)
Author:
pmac
Message:

Code cleanup.

Files:

Legend:

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

    r120 r125  
    2929#define MISSING -17 
    3030 
    31 #define LOAD_PREF       100 
    3231#define APP_MACRO       101 
    3332#define ASK_MACRO       103 
     
    3938#define NEW_KEYMAP      109 
    4039#define ENTER_ACT       110 
     40#define LOAD_PREF       111 
     41#define DUMP_MON        112 
     42#define DUMP_OBJ        113 
     43#define DUMP_FEAT       114 
     44#define DUMP_FLAV       115 
     45#define MOD_MON         116 
     46#define MOD_OBJ         117 
     47#define MOD_FEAT        118 
     48#define MOD_FLAV        119 
     49#define DUMP_COL        120 
     50#define MOD_COL         121 
     51#define RESET_VIS       122 
     52 
     53#define OPTION_MENU 140 
     54#define VISUAL_MENU 141 
     55#define COLOR_MENU      142 
     56#define KNOWLEDGE_MENU 143 
     57#define MACRO_MENU      144 
    4158 
    4259 
     
    4562 
    4663 
    47 typedef struct { 
     64typedef struct 
     65
    4866                int maxnum; /* Maximum possible item count for this class */ 
    4967                bool easy_know; /* Items don't need to be IDed to recognize membership */ 
     
    6179} group_funcs; 
    6280 
    63 typedef struct { 
     81typedef struct 
     82
    6483 
    6584                /* Print a tabular-formatted description for an oid */ 
     
    89108 
    90109/* Helper class for generating joins */ 
    91 typedef struct join { 
     110typedef struct join 
     111
    92112                int oid; 
    93113                int gid; 
     
    111131 * Description of each monster group. 
    112132 */ 
    113 static struct { 
     133static struct 
     134
    114135                cptr chars; 
    115136                cptr name; 
     
    235256{ 
    236257        Term_putch(col, row, a, c); 
    237         if(!use_bigtile) return; 
     258        if (!use_bigtile) return; 
    238259        if (a &0x80) Term_putch(col+1, row, 255, -1); 
    239260        else Term_putch(col+1, row, 1, ' '); 
     
    242263static int actual_width(int width) { 
    243264        if (use_trptile) width = width * 3; 
    244         else if(use_dbltile) width *= 2; 
    245         if(use_bigtile) width *= 2; 
     265        else if (use_dbltile) width *= 2; 
     266        if (use_bigtile) width *= 2; 
    246267                return width; 
    247268} 
    248269 
    249270static int actual_height(int height) { 
    250         if(use_bigtile) height *= 2; 
     271        if (use_bigtile) height *= 2; 
    251272        if (use_trptile) height = height * 3 / 2; 
    252         else if(use_dbltile) height *= 2; 
     273        else if (use_dbltile) height *= 2; 
    253274        return height; 
    254275} 
     
    257278{ 
    258279        int div = 1; 
    259         if(use_trptile) div = 3; 
    260         else if(use_dbltile) div *= 2; 
    261         if(use_bigtile) div *= 2; 
     280        if (use_trptile) div = 3; 
     281        else if (use_dbltile) div *= 2; 
     282        if (use_bigtile) div *= 2; 
    262283        return width / div; 
    263284} 
     
    266287{ 
    267288        int div = 1; 
    268         if(use_trptile) { 
     289        if (use_trptile) 
     290        { 
    269291                height *= 2; 
    270292                div = 3; 
    271293        } 
    272         else if(use_dbltile) div = 2; 
    273         if(use_bigtile) div *= 2; 
     294        else if (use_dbltile) div = 2; 
     295        if (use_bigtile) div *= 2; 
    274296        return height / div; 
    275297} 
     
    341363 
    342364        /* Show inscription, if applicable, aware and existing */ 
    343         if(o_funcs->note && o_funcs->note(oid) && *o_funcs->note(oid)) { 
     365        if (o_funcs->note && o_funcs->note(oid) && *o_funcs->note(oid)) 
     366        { 
    344367                c_put_str(TERM_YELLOW,quark_str(*o_funcs->note(oid)), row, 65); 
    345368        } 
     
    350373 
    351374        /* Do visual mode */ 
    352         if(o_funcs->is_visual && o_funcs->xattr) { 
     375        if (o_funcs->is_visual && o_funcs->xattr) 
     376        { 
    353377                char c = *o_funcs->xchar(oid); 
    354378                byte a = *o_funcs->xattr(oid); 
     
    385409        int oid = -1;                           /* object identifiers */ 
    386410 
    387         region title_area = {0, 0, 0, 4}; 
    388         region group_region = {0, 6, MISSING, -2}; 
    389         region object_region = {MISSING, 6, 0, -2}; 
     411        region title_area = { 0, 0, 0, 4 }; 
     412        region group_region = { 0, 6, MISSING, -2 }; 
     413        region object_region = { MISSING, 6, 0, -2 }; 
    390414 
    391415        /* display state variables */ 
     
    427451        /* Do the group by. ang_sort only works on (void **) */ 
    428452        /* Maybe should make this a precondition? */ 
    429         if(g_funcs.gcomp) 
     453        if (g_funcs.gcomp) 
    430454                        qsort(obj_list, o_count, sizeof(*obj_list), g_funcs.gcomp); 
    431455 
     
    433457        C_MAKE(g_offset, max_group+1, int); 
    434458 
    435         for(i = 0; i < o_count; i++) { 
    436                 if(prev_g != g_funcs.group(obj_list[i])) { 
     459        for (i = 0; i < o_count; i++) 
     460        { 
     461                if (prev_g != g_funcs.group(obj_list[i])) 
     462                { 
    437463                        prev_g = g_funcs.group(obj_list[i]); 
    438464                        g_offset[grp_cnt] = i; 
     
    443469        g_list[grp_cnt] = -1; 
    444470 
    445  
    446  
    447471        /* The compact set of group names, in display order */ 
    448472        C_MAKE(g_names, grp_cnt, const char **); 
    449         for (i = 0; i < grp_cnt; i++) { 
     473        for (i = 0; i < grp_cnt; i++) 
     474        { 
    450475                int len; 
    451476                g_names[i] = g_funcs.name(g_list[i]); 
    452477                len = strlen(g_names[i]); 
    453                 if(len > g_name_len) g_name_len = len; 
    454         } 
    455         if(g_name_len >= 20) g_name_len = 20; 
     478                if (len > g_name_len) g_name_len = len; 
     479        } 
     480        /* Reasonable max group name len */ 
     481        if (g_name_len >= 20) g_name_len = 20; 
    456482 
    457483        object_region.col = g_name_len+3; 
     
    462488 
    463489        /* Leave room for the group summary information */ 
    464         if(g_funcs.summary) object_region.page_rows = -3; 
     490        if (g_funcs.summary) object_region.page_rows = -3; 
    465491 
    466492        WIPE(&group_menu, menu_type); 
     
    483509        /* Panels are -- text panels, two menus, and visual browser */ 
    484510        /* with "pop-up menu" for lore */ 
    485         while((!flag) && (grp_cnt)) { 
     511        while ((!flag) && (grp_cnt)) 
     512        { 
    486513                event_type ke, ke0; 
    487                 if(redraw) { 
     514                if (redraw) 
     515                { 
    488516                        region_erase(&title_area); 
    489517                        prt(format("Knowledge - %s", title), 2, 0); 
     
    491519                        prt("Name", 4, g_name_len + 3); 
    492520                        Term_gotoxy(65, 4); 
    493                         if(o_funcs.note) 
     521                        if (o_funcs.note) 
    494522                                Term_addstr(-1, TERM_WHITE, "Inscribed "); 
    495                         if(otherfields) 
     523                        if (otherfields) 
    496524                                Term_addstr(-1, TERM_WHITE, otherfields); 
    497525                        for (i = 0; i < 78; i++) 
     
    503531                } 
    504532 
    505                 if(g_cur != grp_old) { 
     533                if (g_cur != grp_old) 
     534                { 
    506535                        grp_old = g_cur; 
    507536                        o_cur = 0; 
     
    512541                } 
    513542                /* HACK ... */ 
    514                 if(!visual_list) { 
     543                if (!visual_list) 
     544                { 
    515545                        /* ... The object menu may be browsing the entire group... */ 
    516546                        o_funcs.is_visual = FALSE; 
     
    518548                        object_menu.cursor = o_cur; 
    519549                } 
    520                 else { 
     550                else 
     551                { 
    521552                        /* ... or just a single element in the group. */ 
    522553                        o_funcs.is_visual = TRUE; 
     
    538569                        const char *pvs = (!o_funcs.xattr) ? "" : ", 'v' for visuals"; 
    539570 
    540                         if(visual_list) 
     571                        if (visual_list) 
    541572                                prt(format("<dir>, 'r' to recall, ENTER to accept%s, ESC", pedit), hgt-1, 0); 
    542573                        else  
     
    544575                                                                                pvs, pedit, pnote, pnote1), hgt-1, 0); 
    545576                } 
    546                 if(do_swap) { 
     577                if (do_swap) 
     578                { 
    547579                        do_swap = FALSE; 
    548580                        swap(active_menu, inactive_menu); 
     
    551583                } 
    552584 
    553                 if(g_funcs.summary && !visual_list) 
     585                if (g_funcs.summary && !visual_list) 
    554586                        g_funcs.summary(g_cur, obj_list, g_o_count, g_offset[g_cur], 
    555587                        object_menu.boundary.row + object_menu.boundary.page_rows, object_region.col); 
     
    590622                } 
    591623 
    592                 if(ke.type == EVT_MOUSE) { 
     624                if (ke.type == EVT_MOUSE) 
     625                { 
    593626                        /* Change active panels */ 
    594                         if(region_inside(&inactive_menu->boundary, &ke)) { 
     627                        if (region_inside(&inactive_menu->boundary, &ke)) 
     628                        { 
    595629                                swap(active_menu, inactive_menu); 
    596630                                swap(active_cursor, inactive_cursor); 
     
    599633                } 
    600634                ke0 = run_event_loop(&active_menu->target, 0, &ke); 
    601                 if(ke0.type != EVT_AGAIN) ke = ke0; 
     635                if (ke0.type != EVT_AGAIN) ke = ke0; 
    602636                switch(ke.type) { 
    603637                        case EVT_KBRD: 
     
    607641                                continue; 
    608642                        case EVT_SELECT: 
    609                                 if(panel == 1 && oid >= 0 && o_cur == active_menu->cursor) { 
     643                                if (panel == 1 && oid >= 0 && o_cur == active_menu->cursor) 
     644                                { 
    610645                                        o_funcs.lore(oid); 
    611646                                        redraw = TRUE; 
     
    615650                                continue; 
    616651                        case EVT_BACK: 
    617                                 if(panel == 1) 
     652                                if (panel == 1) 
    618653                                        do_swap = TRUE; 
    619654                        default: 
     
    633668                        { 
    634669                                /* Recall on screen */ 
    635                                 if(oid >= 0) 
     670                                if (oid >= 0) 
    636671                                        o_funcs.lore(oid); 
    637672 
     
    694729                                        /* Auto-inscribe */ 
    695730                                        if (g_funcs.aware(i_ptr) || cheat_peek) 
    696                                         i_ptr->note = note_idx; 
     731                                               i_ptr->note = note_idx; 
    697732                                } 
    698733 
     
    704739                                int d = target_dir(ke.key); 
    705740                                /* Handle key-driven motion between panels */ 
    706                                 if(ddx[d] && ((ddx[d] < 0) == (panel == 1))) { 
     741                                if (ddx[d] && ((ddx[d] < 0) == (panel == 1))) 
     742                                { 
    707743                                        /* Silly hack -- diagonal arithmetic */ 
    708744                                        *inactive_cursor += ddy[d]; 
    709                                         if(*inactive_cursor < 0) *inactive_cursor = 0; 
    710                                         else if(g_cur >= grp_cnt) g_cur = grp_cnt -1; 
    711                                         else if(o_cur >= g_o_count) o_cur = g_o_count-1; 
     745                                        if (*inactive_cursor < 0) *inactive_cursor = 0; 
     746                                        else if (g_cur >= grp_cnt) g_cur = grp_cnt -1; 
     747                                        else if (o_cur >= g_o_count) o_cur = g_o_count-1; 
    712748                                        do_swap = TRUE; 
    713749                                } 
    714                                 else if(o_funcs.note && o_funcs.note(oid)) { 
     750                                else if (o_funcs.note && o_funcs.note(oid)) 
     751                                { 
    715752                                        note_idx = auto_note_modify(*o_funcs.note(oid), ke.key); 
    716753                                        *o_funcs.note(oid) = note_idx; 
     
    10211058        /* group by */ 
    10221059        int c = gid - default_join[*(int*)b].gid; 
    1023         if(c) return c; 
     1060        if (c) return c; 
    10241061        /* order results */ 
    10251062        c = r_a->d_char - r_b->d_char; 
    1026         if(c && gid != 0) { 
     1063        if (c && gid != 0) 
     1064        { 
    10271065                /* UNIQUE group is ordered by level & name only */ 
    10281066                /* Others by order they appear in the group symbols */ 
     
    10311069        } 
    10321070        c = r_a->level - r_b->level; 
    1033         if(c) return c; 
     1071        if (c) return c; 
    10341072        return strcmp(r_name + r_a->name, r_name + r_b->name); 
    10351073} 
    10361074 
    1037 static char *m_xchar(int oid)  
    1038 { return &r_info[default_join[oid].oid].x_char; } 
    1039 static byte *m_xattr(int oid) 
    1040 { return &r_info[default_join[oid].oid].x_attr; } 
     1075static char *m_xchar(int oid) { return &r_info[default_join[oid].oid].x_char; } 
     1076static byte *m_xattr(int oid) { return &r_info[default_join[oid].oid].x_attr; } 
    10411077static const char *race_name(int gid) { return monster_group[gid].name; } 
    10421078static void mon_lore(int oid) { screen_roff(default_join[oid].oid); inkey_ex(); } 
     
    10471083        int kills = 0; 
    10481084 
    1049         for(i = 0; i < n; i++) { 
     1085        for (i = 0; i < n; i++) 
     1086        { 
    10501087                int oid = default_join[object_list[i+top]].oid; 
    10511088                kills += l_list[oid].pkills; 
    10521089        } 
    1053         if(gid == 0) { 
     1090        if (gid == 0) 
     1091        { 
    10541092                c_prt(TERM_L_BLUE, format("Known Uniques: %d, Slain Uniques: %d.", n, kills), 
    10551093                                        row, col); 
    10561094        } 
    1057         else  { 
     1095        else 
     1096        { 
    10581097                int tkills = 0; 
    1059                 for(i = 0; i < z_info->r_max; i++)  
     1098                for (i = 0; i < z_info->r_max; i++)  
    10601099                        tkills += l_list[i].pkills; 
    10611100                c_prt(TERM_L_BLUE, format("Creatures Slain: %d/%d (in group/in total)", kills, tkills), row, col); 
     
    10791118        size_t j; 
    10801119 
    1081         for(i = 0; i < z_info->r_max; i++) { 
     1120        for (i = 0; i < z_info->r_max; i++) 
     1121        { 
    10821122                monster_race *r_ptr = &r_info[i]; 
    1083                 if(!cheat_know && !l_list[i].sights) continue; 
    1084                 if(!r_ptr->name) continue; 
    1085  
    1086                 if(r_ptr->flags1 & RF1_UNIQUE) m_count++; 
    1087                 for(j = 1; j < N_ELEMENTS(monster_group)-1; j++) { 
     1123                if (!cheat_know && !l_list[i].sights) continue; 
     1124                if (!r_ptr->name) continue; 
     1125 
     1126                if (r_ptr->flags1 & RF1_UNIQUE) m_count++; 
     1127                for (j = 1; j < N_ELEMENTS(monster_group)-1; j++) 
     1128                { 
    10881129                        const char *pat = monster_group[j].chars; 
    1089                         if(strchr(pat, r_ptr->d_char)) m_count++; 
     1130                        if (strchr(pat, r_ptr->d_char)) m_count++; 
    10901131                } 
    10911132        } 
     
    10951136 
    10961137        m_count = 0; 
    1097         for(i = 0; i < z_info->r_max; i++) { 
     1138        for (i = 0; i < z_info->r_max; i++) 
     1139        { 
    10981140                monster_race *r_ptr = &r_info[i]; 
    1099                 if(!cheat_know && !l_list[i].sights) continue; 
    1100                 if(!r_ptr->name) continue; 
     1141                if (!cheat_know && !l_list[i].sights) continue; 
     1142                if (!r_ptr->name) continue; 
    11011143         
    1102                 for(j = 0; j < N_ELEMENTS(monster_group)-1; j++) { 
     1144                for (j = 0; j < N_ELEMENTS(monster_group)-1; j++) 
     1145                { 
    11031146                        const char *pat = monster_group[j].chars; 
    1104                         if(j == 0 && !(r_ptr->flags1 & RF1_UNIQUE))  
     1147                        if (j == 0 && !(r_ptr->flags1 & RF1_UNIQUE))  
    11051148                                continue; 
    1106                         else if(j > 0 && !strchr(pat, r_ptr->d_char)) 
     1149                        else if (j > 0 && !strchr(pat, r_ptr->d_char)) 
    11071150                                continue; 
    11081151 
     
    11681211        make_fake_artifact(o_ptr, a_idx); 
    11691212        o_ptr->ident |= IDENT_STORE | IDENT_KNOWN; 
    1170         if(cheat_xtra) o_ptr->ident |= IDENT_MENTAL; 
     1213        if (cheat_xtra) o_ptr->ident |= IDENT_MENTAL; 
    11711214 
    11721215        /* Hack -- Handle stuff */ 
     
    11901233        int tb = obj_group_order[a_b->tval]; 
    11911234        int c = ta - tb; 
    1192         if(c) return c; 
     1235        if (c) return c; 
    11931236 
    11941237        /* order by */ 
    11951238        c = a_a->sval - a_b->sval; 
    1196         if(c) return c; 
     1239        if (c) return c; 
    11971240        return strcmp(a_name+a_a->name, a_name+a_b->name); 
    11981241} 
     
    12191262         
    12201263        /* Collect valid artifacts */ 
    1221         for(i = 0; i < z_info->a_max; i++) { 
    1222                 if((cheat_xtra || a_info[i].cur_num) && a_info[i].name) 
     1264        for (i = 0; i < z_info->a_max; i++) 
     1265        { 
     1266                if ((cheat_xtra || a_info[i].cur_num) && a_info[i].name) 
    12231267                        artifacts[a_count++] = i; 
    12241268        } 
    1225         for(i = 0; !cheat_xtra && i < z_info->o_max; i++) { 
     1269        for (i = 0; !cheat_xtra && i < z_info->o_max; i++) 
     1270        { 
    12261271                int a = o_list[i].name1; 
    1227                 if(a && !object_known_p(&o_list[i])) { 
    1228                         for(j = 0; j < a_count && a != artifacts[j]; j++); 
     1272                if (a && !object_known_p(&o_list[i])) 
     1273                { 
     1274                        for (j = 0; j < a_count && a != artifacts[j]; j++); 
    12291275                        a_count -= 1; 
    1230                         for(; j < a_count; j++)  
     1276                        for (; j < a_count; j++)  
    12311277                                artifacts[j] = artifacts[j+1]; 
    12321278                } 
     
    12831329        /* Begin recall */ 
    12841330        Term_gotoxy(0, 1); 
    1285         if(e_ptr->text) { 
     1331        if (e_ptr->text) 
     1332        { 
    12861333                int x, y; 
    12871334                text_out(e_text + e_ptr->text); 
     
    12951342        object_info_out(&dummy); 
    12961343 
    1297         if(e_ptr->xtra) { 
     1344        if (e_ptr->xtra) 
     1345        { 
    12981346                text_out(format("It provides one random %s.", xtra[e_ptr->xtra - 1])); 
    12991347        } 
    13001348 
    1301         for(i = 0, f3 = TR3_PERMA_CURSE; i < 3 ; f3 >>= 1, i++) { 
    1302                 if(e_ptr->flags3 & f3) { 
     1349        for (i = 0, f3 = TR3_PERMA_CURSE; i < 3 ; f3 >>= 1, i++) 
     1350        { 
     1351                if (e_ptr->flags3 & f3) 
     1352                { 
    13031353                        text_out_c(TERM_RED, format("It is %s.", cursed[i])); 
    13041354                        break; 
     
    13201370        /*group by */ 
    13211371        int c = default_join[*(int*)a].gid - default_join[*(int*)b].gid; 
    1322         if(c) return c; 
     1372        if (c) return c; 
    13231373        /* order by */ 
    13241374        return strcmp(e_name + ea->name, e_name + eb->name); 
     
    13421392        C_MAKE(egoitems, z_info->e_max*EGO_TVALS_MAX, int); 
    13431393        C_MAKE(default_join, z_info->e_max*EGO_TVALS_MAX, join_t); 
    1344         for(i = 0; i < z_info->e_max; i++) { 
    1345                 if(e_info[i].everseen || cheat_xtra) { 
    1346                         for(j = 0; j < EGO_TVALS_MAX && e_info[i].tval[j]; j++) 
     1394        for (i = 0; i < z_info->e_max; i++) 
     1395        { 
     1396                if (e_info[i].everseen || cheat_xtra) 
     1397                { 
     1398                        for (j = 0; j < EGO_TVALS_MAX && e_info[i].tval[j]; j++) 
    13471399                        { 
    13481400                                int gid = obj_group_order[e_info[i].tval[j]]; 
    13491401                                /* Ignore duplicate gids */ 
    1350                                 if(j > 0 && gid == default_join[e_count-1].gid) 
     1402                                if (j > 0 && gid == default_join[e_count-1].gid) 
    13511403                                        continue; 
    13521404                                egoitems[e_count] = e_count; 
     
    14501502        int tb = obj_group_order[k_b->tval]; 
    14511503        int c = ta - tb; 
    1452         if(c) return c; 
     1504        if (c) return c; 
    14531505        /* order by */ 
    14541506        c = k_a->aware - k_b->aware; 
    1455         if(c) return -c; /* aware has low sort weight */ 
    1456         if(!k_a->aware) { 
     1507        if (c) return -c; /* aware has low sort weight */ 
     1508        if (!k_a->aware) 
     1509        { 
    14571510                return strcmp(flavor_text + flavor_info[k_a->flavor].text, 
    14581511                                                                        flavor_text +flavor_info[k_b->flavor].text); 
    14591512        } 
    14601513        c = k_a->cost - k_b->cost; 
    1461         if(c) return c; 
     1514        if (c) return c; 
    14621515        return strcmp(k_name + k_a->name, k_name + k_b->name); 
    14631516} 
     
    14651518static char *o_xchar(int oid) { 
    14661519        object_kind *k_ptr = &k_info[oid]; 
    1467         if(!k_ptr->flavor || k_ptr->aware) return &k_ptr->x_char; 
     1520        if (!k_ptr->flavor || k_ptr->aware) return &k_ptr->x_char; 
    14681521        else return &flavor_info[k_ptr->flavor].x_char; 
    14691522} 
    14701523static byte *o_xattr(int oid) { 
    14711524        object_kind *k_ptr = &k_info[oid]; 
    1472         if(!k_ptr->flavor || k_ptr->aware) return &k_ptr->x_attr; 
     1525        if (!k_ptr->flavor || k_ptr->aware) return &k_ptr->x_attr; 
    14731526        else return &flavor_info[k_ptr->flavor].x_attr; 
    14741527} 
     
    14771530        object_kind *k_ptr = &k_info[oid]; 
    14781531        int ind = get_autoinscription_index(oid); 
    1479         if(!k_ptr->flavor || k_ptr->aware) return (u16b*) &inscriptions[ind].inscription_idx; 
     1532        if (!k_ptr->flavor || k_ptr->aware) return (u16b*) &inscriptions[ind].inscription_idx; 
    14801533        else return 0; 
    14811534} 
     
    14951548        C_MAKE(objects, z_info->k_max, int); 
    14961549 
    1497         for(i = 0; i < z_info->k_max; i++) { 
    1498                 if(k_info[i].everseen || k_info[i].flavor || cheat_xtra) { 
     1550        for (i = 0; i < z_info->k_max; i++) 
     1551        { 
     1552                if (k_info[i].everseen || k_info[i].flavor || cheat_xtra) 
     1553                { 
    14991554                        int c = obj_group_order[k_info[i].tval]; 
    1500                         if(c >= 0) objects[o_count++] = i; 
     1555                        if (c >= 0) objects[o_count++] = i; 
    15011556                } 
    15021557        } 
     
    15411596        /* group by */ 
    15421597        int c = feat_order(*(int*)a) - feat_order(*(int*)b); 
    1543         if(c) return c; 
     1598        if (c) return c; 
    15441599        /* order by feature name */ 
    15451600        return strcmp(f_name + fa->name, f_name + fb->name); 
     
    15661621        C_MAKE(features, z_info->f_max, int); 
    15671622 
    1568         for(i = 0; i < z_info->f_max; i++) { 
    1569                 if(f_info[i].name == 0) continue; 
     1623        for (i = 0; i < z_info->f_max; i++) 
     1624        { 
     1625                if (f_info[i].name == 0) continue; 
    15701626                features[f_count++] = i; /* Currently no filter for features */ 
    15711627        } 
     
    21342190        menu_layout(menu, &SCREEN_REGION); 
    21352191 
    2136         for(;;) 
     2192        for (;;) 
    21372193        { 
    21382194                event_type cx; 
    21392195                cx = menu_select(menu, &cursor_pos, EVT_MOVE); 
    21402196                if (cx.type == EVT_BACK || ESCAPE == cx.key) break; 
    2141                 if(cx.type == EVT_MOVE) cursor_pos = cx.index; 
    2142                 if(cx.type == EVT_SELECT && strchr("YN", toupper(cx.key))) 
     2197                if (cx.type == EVT_MOVE) cursor_pos = cx.index; 
     2198                if (cx.type == EVT_SELECT && strchr("YN", toupper(cx.key))) 
    21432199                        cursor_pos++; 
    21442200                cursor_pos = (cursor_pos+n)%n; 
     
    25212577 
    25222578        /* Failure */ 
    2523         if (!fff) { 
     2579        if (!fff) 
     2580        { 
    25242581                msg_print("Failed"); 
    25252582                return; 
     
    29152972                c = menu_select(&macro_menu, &cursor, EVT_CMD); 
    29162973 
    2917                 if(ESCAPE == c.key)  
     2974                if (ESCAPE == c.key)  
    29182975                        break; 
    29192976                evt = macro_actions[cursor].id; 
     
    33543411event_action visual_menu_items [] = 
    33553412{ 
    3356         {'lupf', "Load a user pref file", 0, 0}, 
    3357         {'vdmx',  "Dump monster attr/chars", 0, 0}, 
    3358         {'vdox',  "Dump object attr/chars", 0, 0}, 
    3359         {'vdfx',  "Dump feature attr/chars", 0, 0}, 
    3360         {'vdxx',  "Dump flavor attr/chars", 0, 0}, 
    3361         {'vemx',  "Change monster attr/chars", 0, 0}, 
    3362         {'veox',  "Change object attr/chars", 0, 0}, 
    3363         {'vefx',  "Change feature attr/chars", 0, 0}, 
    3364         {'vexx',  "Change flavor attr/chars", 0, 0}, 
    3365         {'vrst', "Reset visuals", 0, 0}, 
     3413        {LOAD_PREF, "Load a user pref file", 0, 0}, 
     3414        {DUMP_MON,  "Dump monster attr/chars", 0, 0}, 
     3415        {DUMP_OBJ,  "Dump object attr/chars", 0, 0}, 
     3416        {DUMP_FEAT,  "Dump feature attr/chars", 0, 0}, 
     3417        {DUMP_FLAV,  "Dump flavor attr/chars", 0, 0}, 
     3418        {MOD_MON,  "Change monster attr/chars", 0, 0}, 
     3419        {MOD_OBJ,  "Change object attr/chars", 0, 0}, 
     3420        {MOD_FEAT,  "Change feature attr/chars", 0, 0}, 
     3421        {MOD_FLAV,  "Change flavor attr/chars", 0, 0}, 
     3422        {RESET_VIS, "Reset visuals", 0, 0}, 
    33663423}; 
    33673424 
     
    33883445                Term_clear(); 
    33893446                key = menu_select(&visual_menu, &cursor, EVT_CMD); 
    3390                 if(key.key == ESCAPE)  
     3447                if (key.key == ESCAPE)  
    33913448                        break; 
    33923449 
     
    33953452                evt = visual_menu_items[cursor].id; 
    33963453 
    3397                 if (evt == 'lupf'
     3454                if (evt == LOAD_PREF
    33983455                { 
    33993456                        /* Ask for and load a user pref file */ 
     
    34033460#ifdef ALLOW_VISUALS 
    34043461 
    3405                 else if (evt == 'vdmx'
     3462                else if (evt == DUMP_MON
    34063463                { 
    34073464                        dump_pref_file(dump_monsters, "Dump Monster attr/chars"); 
    34083465                } 
    34093466 
    3410                 else if (evt == 'vdox'
     3467                else if (evt == DUMP_OBJ
    34113468                { 
    34123469                        dump_pref_file(dump_objects, "Dump Object attr/chars"); 
    34133470                } 
    34143471 
    3415                 else if (evt == 'vdfx'
     3472                else if (evt == DUMP_FEAT
    34163473                { 
    34173474                        dump_pref_file(dump_features, "Dump Feature attr/chars"); 
     
    34193476 
    34203477                /* Dump flavor attr/chars */ 
    3421                 else if (evt == 'vdxx') 
     3478                else if (evt == DUMP_FLAV)  
    34223479                { 
    34233480                        dump_pref_file(dump_flavors, "Dump Flavor attr/chars"); 
     
    34253482 
    34263483                /* Modify monster attr/chars */ 
    3427                 else if (evt == 'vemx'
     3484                else if (evt == MOD_MON
    34283485                { 
    34293486                        static int r = 0; 
     
    34503507 
    34513508                /* Modify object attr/chars */ 
    3452                 else if (evt == 'veox'
     3509                else if (evt == MOD_OBJ
    34533510                { 
    34543511                        static int k = 0; 
     
    34703527 
    34713528                /* Modify feature attr/chars */ 
    3472                 else if (evt == 'vefx'
     3529                else if (evt == MOD_FEAT
    34733530                { 
    34743531                        static int f = 0; 
     
    34883545                } 
    34893546                /* Modify flavor attr/chars */ 
    3490                 else if (evt == 'vexx'
     3547                else if (evt == MOD_FLAV
    34913548                { 
    34923549                        static int f = 0; 
     
    35093566 
    35103567                /* Reset visuals */ 
    3511                 else if (evt == 'vrst'
     3568                else if (evt == RESET_VIS
    35123569                { 
    35133570                        /* Reset */ 
     
    35263583static event_action color_events [] = 
    35273584{ 
    3528         {'lupf', "Load a user pref file", 0, 0}, 
     3585        {LOAD_PREF, "Load a user pref file", 0, 0}, 
    35293586#ifdef ALLOW_COLORS 
    3530         {'vdco', "Dump colors", 0, 0}, 
    3531         {'veco', "Modify colors", 0, 0} 
     3587        {DUMP_COL, "Dump colors", 0, 0}, 
     3588        {MOD_COL, "Modify colors", 0, 0} 
    35323589#endif 
    35333590}; 
     
    35653622 
    35663623                /* Load a user pref file */ 
    3567                 if (evt == 'lupf'
     3624                if (evt == LOAD_PREF
    35683625                { 
    35693626                        /* Ask for and load a user pref file */ 
     
    35823639 
    35833640                /* Dump colors */ 
    3584                 else if (evt == 'vdco'
     3641                else if (evt == DUMP_COL
    35853642                { 
    35863643                        dump_pref_file(dump_colors, "Dump Colors"); 
     
    35883645 
    35893646                /* Edit colors */ 
    3590                 else if (evt == 'veco'
     3647                else if (evt == MOD_COL
    35913648                { 
    35923649                        static byte a = 0; 
     
    39554012 
    39564013        /* Ask for a file */ 
    3957         if(mode == 0) my_strcpy(tmp_val, "dump.html", sizeof(tmp_val)); 
     4014        if (mode == 0) my_strcpy(tmp_val, "dump.html", sizeof(tmp_val)); 
    39584015        else my_strcpy(tmp_val, "dump.txt", sizeof(tmp_val)); 
    39594016        if (!get_string("File: ", tmp_val, sizeof(tmp_val))) return; 
     
    39974054{ 
    39984055        msg_print("Dump type [(t)ext; (h)tml; (f)orum embedded html]:"); 
    3999         for(;;) { 
     4056        for (;;) 
     4057        { 
    40004058                int c = inkey(); 
    40014059                switch(c) { 
     
    41164174        menu = &option_menu; 
    41174175        WIPE(menu, menu_type); 
    4118         menu_set_id(menu, 'opti'); 
     4176        menu_set_id(menu, OPTION_MENU); 
    41194177        menu->title = "Options Menu"; 
    41204178        menu->count = N_ELEMENTS(option_actions); 
     
    41254183        menu = &macro_menu; 
    41264184        WIPE(menu, menu_type); 
    4127         menu_set_id(menu, 'macr'); 
     4185        menu_set_id(menu, MACRO_MENU); 
    41284186        menu->count = N_ELEMENTS(macro_actions); 
    41294187        menu->menu_data = macro_actions; 
     
    41344192        menu = &knowledge_menu; 
    41354193        WIPE(menu, menu_type); 
    4136         menu_set_id(menu, 'know'); 
     4194        menu_set_id(menu, KNOWLEDGE_MENU); 
    41374195        menu->title = "Display current knowledge"; 
    41384196        menu->count = N_ELEMENTS(knowledge_actions), 
     
    41434201        menu = &visual_menu; 
    41444202        WIPE(menu, menu_type); 
    4145         menu_set_id(menu, 'visu'); 
     4203        menu_set_id(menu, VISUAL_MENU); 
    41464204        menu->title = "Interact with visuals"; 
    41474205        menu->selections = default_choice; 
     
    41534211        menu = &color_menu; 
    41544212        WIPE(menu, menu_type); 
    4155         menu_set_id(menu, 'colr'); 
     4213        menu_set_id(menu, COLOR_MENU); 
    41564214        menu->title = "Interact with colors"; 
    41574215        menu->selections = default_choice; 
     
    41754233                for (i = 0; 0 != object_text_order[i].tval; i++) 
    41764234                { 
    4177                         if(object_text_order[i].name) gid = i; 
     4235                        if (object_text_order[i].name) gid = i; 
    41784236                        obj_group_order[object_text_order[i].tval] = gid; 
    41794237                }