Changeset 308

Show
Ignore:
Timestamp:
07/08/07 16:26:33 (1 year ago)
Author:
takkaria
Message:

Make the status bar display all timed effects, left-to-right. (closes #191)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/defines.h

    r305 r308  
    333333 * Player "food" crucial values 
    334334 */ 
     335#define PY_FOOD_UPPER   20000   /* Upper limit on food counter */ 
    335336#define PY_FOOD_MAX             15000   /* Food value (Bloated) */ 
    336337#define PY_FOOD_FULL    10000   /* Food value (Normal) */ 
     
    16011602#define PR_MANA                 0x00000080L     /* Display Mana */ 
    16021603#define PR_GOLD                 0x00000100L     /* Display Gold */ 
    1603 #define PR_DEPTH                0x00000200L     /* Display Depth */ 
    16041604#define PR_EQUIPPY              0x00000400L     /* Display Equippy chars */ 
    16051605#define PR_HEALTH               0x00000800L     /* Display Health Bar */ 
    1606 #define PR_CUT                  0x00001000L     /* Display Extra (Cut) */ 
    1607 #define PR_STUN                 0x00002000L     /* Display Extra (Stun) */ 
    1608 #define PR_HUNGER               0x00004000L     /* Display Extra (Hunger) */ 
    1609 #define PR_DTRAP                0x00008000L /* Display Extra (Trap detection) */ 
    1610 #define PR_BLIND                0x00010000L     /* Display Extra (Blind) */ 
    1611 #define PR_CONFUSED             0x00020000L     /* Display Extra (Confused) */ 
    1612 #define PR_AFRAID               0x00040000L     /* Display Extra (Afraid) */ 
    1613 #define PR_POISONED             0x00080000L     /* Display Extra (Poisoned) */ 
    1614 #define PR_STATE                0x00100000L     /* Display Extra (State) */ 
    1615 #define PR_SPEED                0x00200000L     /* Display Extra (Speed) */ 
    1616 #define PR_STUDY                0x00400000L     /* Display Extra (Study) */ 
    1617 #define PR_MAP                  0x00800000L     /* Display Map */ 
    1618 #define PR_OPPOSE_ELEMENTS      0x01000000L     /* Display temp. resists */ 
    1619 #define PR_TEMP_SPELLS          0x02000000L     /* Display temp. spell effects */ 
     1606#define PR_SPEED                0x00001000L     /* Display Extra (Speed) */ 
     1607#define PR_STUDY                0x00002000L     /* Display Extra (Study) */ 
     1608#define PR_DEPTH                0x00004000L     /* Display Depth */ 
     1609#define PR_STATUS       0x00008000L 
     1610#define PR_DTRAP                0x00010000L /* Trap detection indicator */ 
     1611#define PR_STATE                0x00020000L     /* Display Extra (State) */ 
     1612#define PR_MAP                  0x00040000L     /* Display Map */ 
     1613 
    16201614 
    16211615/* Display Basic Info */ 
     
    16231617        (PR_MISC | PR_TITLE | PR_STATS | PR_LEV |\ 
    16241618         PR_EXP | PR_GOLD | PR_ARMOR | PR_HP |\ 
    1625          PR_MANA | PR_DEPTH | PR_HEALTH | PR_EQUIPPY
     1619         PR_MANA | PR_DEPTH | PR_HEALTH | PR_EQUIPPY | PR_SPEED
    16261620 
    16271621/* Display Extra Info */ 
    16281622#define PR_EXTRA \ 
    1629         (PR_CUT | PR_STUN | PR_HUNGER | PR_BLIND |\ 
    1630          PR_CONFUSED | PR_AFRAID | PR_POISONED | PR_STATE |\ 
    1631          PR_SPEED | PR_STUDY | PR_OPPOSE_ELEMENTS) 
     1623        (PR_STATUS | PR_STATE | PR_STUDY) 
    16321624 
    16331625 
  • trunk/src/xtra1.c

    r305 r308  
    428428 
    429429/* 
    430  * Print cut indicator. 
    431  */ 
    432 static void prt_cut(int row, int col) 
    433 
    434         int c = p_ptr->timed[TMD_CUT]; 
    435  
    436         if (c > 1000) 
    437         { 
    438                 c_put_str(TERM_L_RED, "Mortal wound", row, col); 
    439         } 
    440         else if (c > 200) 
    441         { 
    442                 c_put_str(TERM_RED, "Deep gash   ", row, col); 
    443         } 
    444         else if (c > 100) 
    445         { 
    446                 c_put_str(TERM_RED, "Severe cut  ", row, col); 
    447         } 
    448         else if (c > 50) 
    449         { 
    450                 c_put_str(TERM_ORANGE, "Nasty cut   ", row, col); 
    451         } 
    452         else if (c > 25) 
    453         { 
    454                 c_put_str(TERM_ORANGE, "Bad cut     ", row, col); 
    455         } 
    456         else if (c > 10) 
    457         { 
    458                 c_put_str(TERM_YELLOW, "Light cut   ", row, col); 
    459         } 
    460         else if (c) 
    461         { 
    462                 c_put_str(TERM_YELLOW, "Graze       ", row, col); 
     430 * Prints the speed of a character. 
     431 */ 
     432static void prt_speed(int row, int col) 
     433
     434        int i = p_ptr->pspeed; 
     435 
     436        byte attr = TERM_WHITE; 
     437        const char *type = NULL; 
     438        char buf[32] = ""; 
     439 
     440        /* Hack -- Visually "undo" the Search Mode Slowdown */ 
     441        if (p_ptr->searching) i += 10; 
     442 
     443        /* Fast */ 
     444        if (i > 110) 
     445        { 
     446                attr = TERM_L_GREEN; 
     447                type = "Fast"; 
     448        } 
     449 
     450        /* Slow */ 
     451        else if (i < 110) 
     452        { 
     453                attr = TERM_L_UMBER; 
     454                type = "Slow"; 
     455        } 
     456 
     457        if (type) 
     458                strnfmt(buf, sizeof(buf), "%s (%+d)", type, (i - 110)); 
     459 
     460        /* Display the speed */ 
     461        c_put_str(attr, format("%-10s", buf), row, col); 
     462
     463 
     464 
     465/* 
     466 * Prints depth in stat area 
     467 */ 
     468static void prt_depth(int row, int col) 
     469
     470        char depths[32]; 
     471 
     472        if (!p_ptr->depth) 
     473        { 
     474                my_strcpy(depths, "Town", sizeof(depths)); 
     475        } 
     476        else if (depth_in_feet) 
     477        { 
     478                strnfmt(depths, sizeof(depths), "%d ft", p_ptr->depth * 50); 
    463479        } 
    464480        else 
    465481        { 
    466                 put_str("            ", row, col); 
    467         } 
    468 
    469  
    470  
    471 /* 
    472  * Print stun indicator. 
    473  */ 
    474 static void prt_stun(int row, int col) 
    475 
    476         int s = p_ptr->timed[TMD_STUN]; 
    477  
    478         if (s > 100) 
    479         { 
    480                 c_put_str(TERM_RED, "Knocked out ", row, col); 
    481         } 
    482         else if (s > 50) 
    483         { 
    484                 c_put_str(TERM_ORANGE, "Heavy stun  ", row, col); 
    485         } 
    486         else if (s) 
    487         { 
    488                 c_put_str(TERM_ORANGE, "Stun        ", row, col); 
    489         } 
    490         else 
    491         { 
    492                 put_str("            ", row, col); 
    493         } 
     482                strnfmt(depths, sizeof(depths), "Lev %d", p_ptr->depth); 
     483        } 
     484 
     485        /* Right-Adjust the "depth", and clear old values */ 
     486        put_str(format("%-13s", depths), row, col); 
    494487} 
    495488 
     
    518511} side_handlers[] = 
    519512{ 
    520         { prt_race,      20, PR_MISC }, 
    521         { prt_class,     19, PR_MISC }, 
     513        { prt_race,      19, PR_MISC }, 
    522514        { prt_title,     18, PR_TITLE }, 
     515        { prt_class,     22, PR_MISC }, 
    523516        { prt_level,     10, PR_LEV }, 
    524         { prt_exp,       15, PR_EXP }, 
     517        { prt_exp,       16, PR_EXP }, 
    525518        { prt_gold,      11, PR_GOLD }, 
    526519        { prt_equippy,   17, PR_EQUIPPY }, 
     
    531524        { prt_con,        2, PR_STATS }, 
    532525        { prt_chr,        1, PR_STATS }, 
    533         { NULL,          14, 0 }, 
     526        { NULL,          15, 0 }, 
    534527        { prt_ac,         7, PR_ARMOR }, 
    535528        { prt_hp,         8, PR_HP }, 
    536529        { prt_sp,         9, PR_MANA }, 
     530        { NULL,          21, 0 }, 
     531        { prt_health,    12, PR_HEALTH }, 
     532        { NULL,          20, 0 }, 
    537533        { NULL,          22, 0 }, 
    538         { prt_health,    12, PR_HEALTH }, 
    539         { NULL,          21, 0 }, 
    540         { prt_cut,       13, PR_CUT }, 
    541         { prt_stun,      16, PR_STUN } 
     534        { prt_speed,    -13, PR_SPEED },    /* "Slow (-NN)" or "Fast (+NN)" */ 
     535        { prt_depth,    -14, PR_DEPTH },    /* "Lev NNN" / "NNNN ft" */ 
    542536}; 
    543537 
     
    556550        int max_priority; 
    557551        size_t i; 
    558         u32b to_clear = 0; 
    559552 
    560553 
     
    568561        { 
    569562                const struct side_handler_t *hnd = &side_handlers[i]; 
     563                int priority = hnd->priority; 
     564                bool from_bottom = FALSE; 
     565 
     566                /* Negative means print from bottom */ 
     567                if (priority < 0) 
     568                { 
     569                        priority = -priority; 
     570                        from_bottom = TRUE; 
     571                } 
    570572 
    571573                /* If this is high enough priority, display it */ 
    572                 if (hnd->priority <= max_priority) 
     574                if (priority <= max_priority) 
    573575                { 
    574576                        /* If the redraw flag it set, and there is a hook */ 
    575577                        if ((p_ptr->redraw & hnd->flag) && hnd->hook) 
    576578                        { 
    577                                 /* Mark flag for removal */ 
    578                                 to_clear |= hnd->flag; 
    579  
    580                                 /* Display at the current row */ 
    581                                 hnd->hook(row, 0); 
     579                                if (from_bottom) 
     580                                        hnd->hook(Term->hgt - (N_ELEMENTS(side_handlers) - i), 0); 
     581                                else 
     582                                    hnd->hook(row, 0); 
    582583                        } 
    583584 
    584                         /* Increment for next time */ 
     585                               /* Increment for next time */ 
    585586                        row++; 
    586587                } 
    587588        } 
    588  
    589         /* Clear flags */ 
    590         p_ptr->redraw &= ~(to_clear); 
    591589} 
    592590 
     
    596594/*** Status line display functions ***/ 
    597595 
    598 /* 
    599  * Prints depth in stat area 
    600  */ 
    601 static void prt_depth(int row, int col) 
    602 
    603         char depths[32]; 
    604  
    605         if (!p_ptr->depth) 
    606         { 
    607                 my_strcpy(depths, "Town", sizeof(depths)); 
    608         } 
    609         else if (depth_in_feet) 
    610         { 
    611                 strnfmt(depths, sizeof(depths), "%d ft", p_ptr->depth * 50); 
    612         } 
    613         else 
    614         { 
    615                 strnfmt(depths, sizeof(depths), "Lev %d", p_ptr->depth); 
    616         } 
    617  
    618         /* Right-Adjust the "depth", and clear old values */ 
    619         prt(format("%7s", depths), row, col); 
     596/* Simple macro to initialise structs */ 
     597#define S(s)            s, sizeof(s) 
     598 
     599/* 
     600 * Struct to describe different timed effects 
     601 */ 
     602struct state_info 
     603
     604        size_t value; 
     605        const char *str; 
     606        size_t len; 
     607        byte attr; 
     608}; 
     609 
     610/* TMD_CUT descriptions */ 
     611static const struct state_info cut_data[] = 
     612
     613        { 1000, S("Mortal wound"), TERM_L_RED }, 
     614        {  200, S("Deep gash"),    TERM_RED }, 
     615        {  100, S("Severe cut"),   TERM_RED }, 
     616        {   50, S("Nasty cut"),    TERM_ORANGE }, 
     617        {   25, S("Bad cut"),      TERM_ORANGE }, 
     618        {   10, S("Light cut"),    TERM_YELLOW }, 
     619        {    0, S("Graze"),        TERM_YELLOW }, 
     620}; 
     621 
     622/* TMD_STUN descriptions */ 
     623static const struct state_info stun_data[] = 
     624
     625        {   100, S("Knocked out"), TERM_RED }, 
     626        {    50, S("Heavy stun"),  TERM_ORANGE }, 
     627        {     0, S("Stun"),        TERM_ORANGE }, 
     628}; 
     629 
     630/* p_ptr->hunger descriptions */ 
     631static const struct state_info hunger_data[] = 
     632
     633        { PY_FOOD_FAINT, S("Faint"),    TERM_RED }, 
     634        { PY_FOOD_WEAK,  S("Weak"),     TERM_ORANGE }, 
     635        { PY_FOOD_ALERT, S("Hungry"),   TERM_YELLOW }, 
     636        { PY_FOOD_FULL,  S(""),         TERM_L_GREEN }, 
     637        { PY_FOOD_MAX,   S("Full"),     TERM_L_GREEN }, 
     638        { PY_FOOD_UPPER, S("Gorged"),   TERM_GREEN }, 
     639}; 
     640 
     641/* For the various TMD_* effects */ 
     642static const struct state_info effects[] = 
     643
     644        { TMD_BLIND,     S("Blind"),      TERM_ORANGE }, 
     645        { TMD_PARALYZED, S("Paralyzed!"), TERM_RED }, 
     646        { TMD_CONFUSED,  S("Confused"),   TERM_ORANGE }, 
     647        { TMD_AFRAID,    S("Afraid"),     TERM_ORANGE }, 
     648        { TMD_IMAGE,     S("Halluc"),     TERM_ORANGE }, 
     649        { TMD_POISONED,  S("Poisoned"),   TERM_ORANGE }, 
     650        { TMD_PROTEVIL,  S("ProtEvil"),   TERM_L_GREEN }, 
     651        { TMD_INVULN,    S("Invuln"),     TERM_L_GREEN }, 
     652        { TMD_HERO,      S("Hero"),       TERM_L_GREEN }, 
     653        { TMD_SHERO,     S("Berserk"),    TERM_L_GREEN }, 
     654        { TMD_SHIELD,    S("Shield"),     TERM_L_GREEN }, 
     655        { TMD_BLESSED,   S("Blssd"),      TERM_L_GREEN }, 
     656        { TMD_SINVIS,    S("SInvis"),     TERM_L_GREEN }, 
     657        { TMD_SINFRA,    S("Infra"),      TERM_L_GREEN }, 
     658        { TMD_OPP_ACID,  S("RAcid"),      TERM_SLATE }, 
     659        { TMD_OPP_ELEC,  S("RElec"),      TERM_BLUE }, 
     660        { TMD_OPP_FIRE,  S("RFire"),      TERM_RED }, 
     661        { TMD_OPP_COLD,  S("RCold"),      TERM_WHITE }, 
     662        { TMD_OPP_POIS,  S("RPois"),      TERM_GREEN }, 
     663        { TMD_AMNESIA,   S("Amnesiac"),   TERM_ORANGE }, 
     664}; 
     665 
     666#define PRINT_STATE(sym, data, index, row, col) \ 
     667{ \ 
     668        size_t i; \ 
     669        \ 
     670        for (i = 0; i < N_ELEMENTS(data); i++) \ 
     671        { \ 
     672                if (index sym data[i].value) \ 
     673                { \ 
     674                        if (data[i].str[0]) \ 
     675                        { \ 
     676                                c_put_str(data[i].attr, data[i].str, row, col); \ 
     677                                return data[i].len; \ 
     678                        } \ 
     679                        else \ 
     680                        { \ 
     681                                return 0; \ 
     682                        } \ 
     683                } \ 
     684        } \ 
     685
     686 
     687 
     688/* 
     689 * Print cut indicator. 
     690 */ 
     691static size_t prt_cut(int row, int col) 
     692
     693        PRINT_STATE(>, cut_data, p_ptr->timed[TMD_CUT], row, col); 
     694        return 0; 
     695
     696 
     697 
     698/* 
     699 * Print stun indicator. 
     700 */ 
     701static size_t prt_stun(int row, int col) 
     702
     703        PRINT_STATE(>, stun_data, p_ptr->timed[TMD_STUN], row, col); 
     704        return 0; 
    620705} 
    621706 
     
    624709 * Prints status of hunger 
    625710 */ 
    626 static void prt_hunger(int row, int col) 
    627 
    628         /* Fainting / Starving */ 
    629         if (p_ptr->food < PY_FOOD_FAINT) 
    630         { 
    631                 c_put_str(TERM_RED, "Weak  ", row, col); 
    632         } 
    633  
    634         /* Weak */ 
    635         else if (p_ptr->food < PY_FOOD_WEAK) 
    636         { 
    637                 c_put_str(TERM_ORANGE, "Weak  ", row, col); 
    638         } 
    639  
    640         /* Hungry */ 
    641         else if (p_ptr->food < PY_FOOD_ALERT) 
    642         { 
    643                 c_put_str(TERM_YELLOW, "Hungry", row, col); 
    644         } 
    645  
    646         /* Normal */ 
    647         else if (p_ptr->food < PY_FOOD_FULL) 
    648         { 
    649                 c_put_str(TERM_L_GREEN, "      ", row, col); 
    650         } 
    651  
    652         /* Full */ 
    653         else if (p_ptr->food < PY_FOOD_MAX) 
    654         { 
    655                 c_put_str(TERM_L_GREEN, "Full  ", row, col); 
    656         } 
    657  
    658         /* Gorged */ 
    659         else 
    660         { 
    661                 c_put_str(TERM_GREEN, "Gorged", row, col); 
    662         } 
    663 
    664  
    665  
    666 /* 
    667  * Prints Blind status 
    668  */ 
    669 static void prt_blind(int row, int col) 
    670 
    671         if (p_ptr->timed[TMD_BLIND]) 
    672         { 
    673                 c_put_str(TERM_ORANGE, "Blind", row, col); 
    674         } 
    675         else 
    676         { 
    677                 put_str("     ", row, col); 
    678         } 
    679 
    680  
    681  
    682 /* 
    683  * Prints Confusion status 
    684  */ 
    685 static void prt_confused(int row, int col) 
    686 
    687         bool confused = p_ptr->timed[TMD_CONFUSED] ? TRUE : FALSE; 
    688         bool forget   = p_ptr->timed[TMD_AMNESIA]  ? TRUE : FALSE; 
    689  
    690         const char *text = "        "; 
    691  
    692         if (confused && !forget) 
    693                 text = "Confused"; 
    694         else if (confused && forget) 
    695                 text = "Conf Amn"; 
    696         else if (!confused && forget) 
    697                 text = "Amnesiac"; 
    698  
    699         c_put_str(TERM_ORANGE, text, row, col); 
    700 
    701  
    702  
    703 /* 
    704  * Prints Fear status 
    705  */ 
    706 static void prt_afraid(int row, int col) 
    707 
    708         if (p_ptr->timed[TMD_AFRAID]) 
    709         { 
    710                 c_put_str(TERM_ORANGE, "Afraid", row, col); 
    711         } 
    712         else 
    713         { 
    714                 put_str("      ", row, col); 
    715         } 
    716 
    717  
    718  
    719 /* 
    720  * Prints Poisoned status 
    721  */ 
    722 static void prt_poisoned(int row, int col) 
    723 
    724         if (p_ptr->timed[TMD_POISONED]) 
    725         { 
    726                 c_put_str(TERM_ORANGE, "Poisoned", row, col); 
    727         } 
    728         else 
    729         { 
    730                 put_str("        ", row, col); 
    731         } 
    732 
    733  
    734  
    735 /* 
    736  * Prints Searching, Resting, Paralysis, or 'count' status 
     711static size_t prt_hunger(int row, int col) 
     712
     713        PRINT_STATE(<, hunger_data, p_ptr->food, row, col); 
     714        return 0; 
     715
     716 
     717 
     718 
     719/* 
     720 * Prints Searching, Resting, or 'count' status 
    737721 * Display is always exactly 10 characters wide (see below) 
    738722 * 
     
    740724 * the text formatting code was optimized in place below. 
    741725 */ 
    742 static void prt_state(int row, int col) 
     726static size_t prt_state(int row, int col) 
    743727{ 
    744728        byte attr = TERM_WHITE; 
    745729 
    746         char text[16]; 
    747  
    748  
    749         /* Paralysis */ 
    750         if (p_ptr->timed[TMD_PARALYZED]) 
    751         { 
    752                 attr = TERM_RED; 
    753  
    754                 my_strcpy(text, "Paralyzed!", sizeof(text)); 
    755         } 
     730        char text[16] = ""; 
     731 
    756732 
    757733        /* Resting */ 
    758         else if (p_ptr->resting) 
     734        if (p_ptr->resting) 
    759735        { 
    760736                int i; 
     
    835811        } 
    836812 
    837         /* Nothing interesting */ 
    838         else 
    839         { 
    840                 my_strcpy(text, "          ", sizeof(text)); 
    841         } 
    842  
    843813        /* Display the info (or blanks) */ 
    844814        c_put_str(attr, text, row, col); 
    845 
    846  
    847  
    848 /* 
    849  * Prints the speed of a character. 
    850  */ 
    851 static void prt_speed(int row, int col) 
    852 
    853         int i = p_ptr->pspeed; 
    854  
    855         byte attr = TERM_WHITE; 
    856         const char *type = NULL; 
    857         char buf[32] = ""; 
    858  
    859         /* Hack -- Visually "undo" the Search Mode Slowdown */ 
    860         if (p_ptr->searching) i += 10; 
    861  
    862         /* Fast */ 
    863         if (i > 110) 
    864         { 
    865                 attr = TERM_L_GREEN; 
    866                 type = "Fast"; 
    867         } 
    868  
    869         /* Slow */ 
    870         else if (i < 110) 
    871         { 
    872                 attr = TERM_L_UMBER; 
    873                 type = "Slow"; 
    874         } 
    875  
    876         if (type) 
    877                 strnfmt(buf, sizeof(buf), "%s (%+d)", type, (i - 110)); 
    878  
    879         /* Display the speed */ 
    880         c_put_str(attr, format("%-10s", buf), row, col); 
     815 
     816        return strlen(text); 
    881817} 
    882818 
     
    885821 * Prints trap detection status 
    886822 */ 
    887 static void prt_dtrap(int row, int col) 
     823static size_t prt_dtrap(int row, int col) 
    888824{ 
    889825        byte info = cave_info2[p_ptr->py][p_ptr->px]; 
     
    891827        /* The player is in a trap-detected grid */ 
    892828        if (info & (CAVE2_DTRAP)) 
     829        { 
    893830                c_put_str(TERM_GREEN, "DTrap", row, col); 
    894  
    895         /* Not in a trap-detected grid */ 
    896         else 
    897                put_str("     ", row, col)
     831                return 5; 
     832        } 
     833 
     834        return 0
    898835} 
    899836 
     
    903840 * Print whether a character is studying or not. 
    904841 */ 
    905 static void prt_study(int row, int col) 
     842static size_t prt_study(int row, int col) 
    906843{ 
    907844        if (p_ptr->new_spells) 
    908845        { 
    909                 put_str("Study", row, col); 
    910         } 
    911         else 
    912         { 
    913                 put_str("     ", row, col); 
    914         } 
    915 
    916  
    917  
    918 static void prt_elements(int row, int col) 
    919 
    920         int wid, n; 
    921  
    922         /* Number of resists to display */ 
    923         int count = 5; 
    924  
    925         /* XXX Ignore column setting */ 
    926         col = 80; 
    927         wid = Term->wid - col; 
    928  
    929         /* Print up to 5 letters of the resist */ 
    930         n = MIN(wid / count, 5); 
    931  
    932  
    933         /* Check space */ 
    934         if (n <= 0) return; 
    935  
    936  
    937         if (p_ptr->timed[TMD_OPP_ACID]) 
    938                 Term_putstr(col, row, n, TERM_SLATE, "Acid "); 
    939         else 
    940                 Term_putstr(col, row, n, TERM_SLATE, "     "); 
    941  
    942         col += n; 
    943  
    944         if (p_ptr->timed[TMD_OPP_ELEC]) 
    945                 Term_putstr(col, row, n, TERM_BLUE, "Elec "); 
    946         else 
    947                 Term_putstr(col, row, n, TERM_BLUE, "     "); 
    948  
    949         col += n; 
    950  
    951         if (p_ptr->timed[TMD_OPP_FIRE]) 
    952                 Term_putstr(col, row, n, TERM_RED, "Fire "); 
    953         else 
    954                 Term_putstr(col, row, n, TERM_RED, "     "); 
    955  
    956         col += n; 
    957  
    958         if (p_ptr->timed[TMD_OPP_COLD]) 
    959                 Term_putstr(col, row, n, TERM_WHITE, "Cold "); 
    960         else 
    961                 Term_putstr(col, row, n, TERM_WHITE, "     "); 
    962  
    963         col += n; 
    964  
    965         if (p_ptr->timed[TMD_OPP_POIS]) 
    966                 Term_putstr(col, row, n, TERM_GREEN, "Pois "); 
    967         else 
    968                 Term_putstr(col, row, n, TERM_GREEN, "     "); 
    969 
    970  
    971  
    972  
    973  
    974 /* 
    975  * Struct of status line indicators. 
    976  */ 
    977 static const struct status_handler_t 
    978 
    979         u32b flag;                                                      /* p_ptr->redraw flag this entry is for */ 
    980         int column;                                                     /* Column to display at */ 
    981         void (*hook)(int row, int col);         /* Display function */ 
    982 } status_handlers[] = 
    983 
    984         { PR_HUNGER,    0, prt_hunger },   /* "Weak" / "Hungry" / "Full" / "Gorged" */ 
    985         { PR_BLIND,     7, prt_blind },    /* "Blind" */ 
    986         { PR_CONFUSED, 13, prt_confused }, /* "Confused" */ 
    987         { PR_AFRAID,   22, prt_afraid },   /* "Afraid" */ 
    988         { PR_POISONED, 29, prt_poisoned }, /* "Poisoned" */ 
    989         { PR_STATE,    38, prt_state },    /* <state> */ 
    990         { PR_DTRAP,    49, prt_dtrap },    /* "DTrap" */ 
    991         { PR_SPEED,    55, prt_speed },    /* "Slow (-NN)" or "Fast (+NN)" */ 
    992         { PR_STUDY,    66, prt_study },    /* "Study" */ 
    993         { PR_DEPTH,    72, prt_depth },    /* "Lev NNN" / "NNNN ft" */ 
    994         { PR_OPPOSE_ELEMENTS, 80, prt_elements }, /* Acid Elec Fire Cold Pois */ 
    995 }; 
     846                char *text = format("Study (%d)", p_ptr->new_spells); 
     847                put_str(text, row, col); 
     848                return strlen(text); 
     849        } 
     850 
     851        return 0; 
     852
     853 
     854 
     855 
     856/* 
     857 * Print all timed effects. 
     858 */ 
     859static size_t prt_tmd(int row, int col) 
     860
     861        size_t i, len = 0; 
     862 
     863        for (i = 0; i < N_ELEMENTS(effects); i++) 
     864        { 
     865                if (p_ptr->timed[effects[i].value]) 
     866                { 
     867                        c_put_str(effects[i].attr, effects[i].str, row, col + len); 
     868                        len += effects[i].len; 
     869                } 
     870        } 
     871 
     872        return len; 
     873
     874 
     875 
     876/* Useful typedef */ 
     877typedef size_t status_f(int row, int col); 
     878 
     879status_f *status_handlers[] = 
     880{ prt_state, prt_cut, prt_stun, prt_hunger, prt_study, prt_tmd, prt_dtrap }; 
    996881 
    997882 
     
    1002887{ 
    1003888        int row = Term->hgt - 1; 
     889        int col = 13; 
    1004890        size_t i; 
     891 
     892        /* Don't worry about non-statusline bits */ 
     893        if (!(p_ptr->redraw & (PR_STATE | PR_STUDY | PR_STATUS))) 
     894                return; 
     895 
     896        /* Clear the remainder of the line */ 
     897        prt("", row, col); 
    1005898 
    1006899        /* Display those which need redrawing */ 
    1007900        for (i = 0; i < N_ELEMENTS(status_handlers); i++) 
    1008         { 
    1009                 const struct status_handler_t *hnd = &status_handlers[i]; 
    1010  
    1011                 if (p_ptr->redraw & hnd->flag) 
    1012                 { 
    1013                         p_ptr->redraw &= ~(hnd->flag); 
    1014                         hnd->hook(row, hnd->column); 
    1015                 } 
    1016         } 
    1017  
    1018         return; 
     901                col += status_handlers[i](row, col); 
    1019902} 
    1020903 
     
    1087970        /* Monster health */ 
    1088971        prt_health(row++, col); 
    1089  
    1090         /* Cut */ 
    1091         prt_cut(row++, col); 
    1092  
    1093         /* Stun */ 
    1094         prt_stun(row++, col); 
    1095972} 
    1096973 
     
    11641041                display_koff(p_ptr->object_kind_idx); 
    11651042} 
    1166  
    1167  
    1168 /* 
    1169  * Print the status display subwindow 
    1170  */ 
    1171 static void fix_status(void) 
    1172 { 
    1173         int row = 0; 
    1174         size_t i; 
    1175  
    1176         for (i = 0; i < N_ELEMENTS(status_handlers) - 1; i++) 
    1177         { 
    1178                 status_handlers[i].hook(row, 0); 
    1179                 row++; 
    1180         } 
    1181 } 
    1182  
    11831043 
    11841044 
     
    12061066        { PW_OBJECT, fix_object }, 
    12071067        { PW_MONLIST, display_monlist },        /* Display visible monsters */ 
    1208         { PW_STATUS, fix_status }               /* Display status lines */ 
    12091068}; 
    12101069 
     
    28242683        if (!p_ptr->redraw) return; 
    28252684 
    2826  
    28272685        /* Character is not ready yet, no screen updates */ 
    28282686        if (!character_generated) return; 
    2829  
    28302687 
    28312688        /* Character is in "icky" mode, no screen updates */ 
     
    28362693        if (p_ptr->redraw & (PR_MISC | PR_TITLE | PR_LEV | PR_EXP | 
    28372694                             PR_STATS | PR_ARMOR | PR_HP | PR_MANA | 
    2838                              PR_GOLD | PR_HEALTH | PR_EQUIPPY | PR_CUT | 
    2839                              PR_STUN)) 
     2695                             PR_GOLD | PR_HEALTH | PR_EQUIPPY | PR_DEPTH | PR_SPEED)) 
    28402696        { 
    28412697                p_ptr->window |= PW_PLAYER_2; 
    28422698        } 
    28432699 
    2844         /* HACK - Redraw window "Display status" if necessary */ 
    2845         if (p_ptr->redraw & (PR_HUNGER | PR_BLIND | PR_CONFUSED | PR_AFRAID | 
    2846                              PR_POISONED | PR_STATE | PR_SPEED | PR_STUDY | 
    2847                              PR_DEPTH)) 
    2848         { 
    2849                 p_ptr->window |= PW_STATUS; 
    2850         } 
    2851  
    28522700        if (p_ptr->redraw & (PR_MAP)) 
    28532701        { 
    2854                 p_ptr->redraw &= ~(PR_MAP); 
    28552702                prt_map(); 
    28562703        } 
     
    28762723        display_statusline(); 
    28772724 
    2878         return; 
     2725 
     2726        /* Reset p_ptr->redraw */ 
     2727        p_ptr->redraw = 0; 
    28792728} 
    28802729 
     
    28952744} 
    28962745 
     2746 
  • trunk/src/xtra2.c

    r263 r308  
    4040        { "You feel yourself moving faster!", "You feel yourself slow down.", 0, 0, PU_BONUS, MSG_SPEED }, 
    4141        { "You feel yourself moving slower!", "You feel yourself speed up.", 0, 0, PU_BONUS, MSG_SLOW }, 
    42         { "You are blind.", "You can see again.", (PR_MAP | PR_BLIND), 
    43           (PW_OVERHEAD | PW_MAP), (PU_FORGET_VIEW | PU_UPDATE_VIEW | PU_MONSTERS), MSG_BLIND }, 
    44         { "You are paralyzed!", "You can move again.", PR_STATE, 0, 0, MSG_PARALYZED }, 
    45         { "You are confused!", "You feel less confused now.", PR_CONFUSED, 0, 0, MSG_CONFUSED }, 
    46         { "You are terrified!", "You feel bolder now.", PR_AFRAID, 0, 0, MSG_AFRAID }, 
     42        { "You are blind.", "You can see again.", PR_MAP, (PW_OVERHEAD | PW_MAP), (PU_FORGET_VIEW | PU_UPDATE_VIEW | PU_MONSTERS), MSG_BLIND }, 
     43        { "You are paralyzed!", "You can move again.", 0, 0, 0, MSG_PARALYZED }, 
     44        { "You are confused!", "You feel less confused now.", 0, 0, 0, MSG_CONFUSED }, 
     45        { "You are terrified!", "You feel bolder now.", 0, 0, 0, MSG_AFRAID }, 
    4746        { "You feel drugged!", "You can see clearly again.", PR_MAP, (PW_OVERHEAD | PW_MAP), 0, MSG_DRUGGED }, 
    48         { "You are poisoned!", "You are no longer poisoned.", PR_POISONED, 0, 0, MSG_POISONED }, 
     47        { "You are poisoned!", "You are no longer poisoned.", 0, 0, 0, MSG_POISONED }, 
    4948        { "", "", 0, 0, 0, 0 },  /* TMD_CUT -- handled seperately */ 
    5049        { "", "", 0, 0, 0, 0 },  /* TMD_STUN -- handled seperately */ 
     
    6160        { "", "", 0, 0, 0, 0 },  /* fire -- handled seperately */ 
    6261        { "", "", 0, 0, 0, 0 },  /* cold -- handled seperately */ 
    63         { "You feel resistant to poison!", "You feel less resistant to poison", PR_OPPOSE_ELEMENTS, 0, 0, MSG_RES_POIS }, 
    64         { "You feel your memories fade.", "Your memories come flooding back.", PR_CONFUSED, 0, 0, MSG_GENERIC }, 
     62        { "You feel resistant to poison!", "You feel less resistant to poison", 0, 0, 0, MSG_RES_POIS }, 
     63        { "You feel your memories fade.", "Your memories come flooding back.", 0, 0, 0, MSG_GENERIC }, 
    6564}; 
    6665 
     
    119118        /* Update the visuals, as appropriate. */ 
    120119        p_ptr->update |= effect->flag_update; 
    121         p_ptr->redraw |= effect->flag_redraw
     120        p_ptr->redraw |= (PR_STATUS | effect->flag_redraw)
    122121        p_ptr->window |= effect->flag_window; 
    123122 
     
    197196 
    198197        /* Redraw */ 
    199         p_ptr->redraw |= PR_OPPOSE_ELEMENTS; 
     198        p_ptr->redraw |= PR_STATUS; 
    200199 
    201200        /* Handle stuff */ 
     
    247246 
    248247        /* Redraw */ 
    249         p_ptr->redraw |= PR_OPPOSE_ELEMENTS; 
     248        p_ptr->redraw |= PR_STATUS; 
    250249 
    251250        /* Handle stuff */ 
     
    297296 
    298297        /* Redraw */ 
    299         p_ptr->redraw |= PR_OPPOSE_ELEMENTS; 
     298        p_ptr->redraw |= PR_STATUS; 
    300299 
    301300        /* Handle stuff */ 
     
    347346 
    348347        /* Redraw */ 
    349         p_ptr->redraw |= PR_OPPOSE_ELEMENTS; 
     348        p_ptr->redraw |= PR_STATUS; 
    350349 
    351350        /* Handle stuff */ 
     
    484483 
    485484        /* Redraw the "stun" */ 
    486         p_ptr->redraw |= (PR_STUN); 
     485        p_ptr->redraw |= (PR_STATUS); 
    487486 
    488487        /* Handle stuff */ 
     
    696695 
    697696        /* Redraw the "cut" */ 
    698         p_ptr->redraw |= (PR_CUT); 
     697        p_ptr->redraw |= (PR_STATUS); 
    699698 
    700699        /* Handle stuff */ 
     
    735734 
    736735        /* Hack -- Force good values */ 
    737         v = (v > 20000) ? 20000 : (v < 0) ? 0 : v; 
     736        v = MIN(v, PY_FOOD_UPPER); 
     737        v = MAX(v, 0); 
    738738 
    739739        /* Fainting / Starving */ 
     
    919919 
    920920        /* Redraw hunger */ 
    921         p_ptr->redraw |= (PR_HUNGER); 
     921        p_ptr->redraw |= (PR_STATUS); 
    922922 
    923923        /* Handle stuff */ 
     
    34573457 
    34583458 
     3459