Changeset 998

Show
Ignore:
Timestamp:
10/01/08 01:57:25 (3 months ago)
Author:
takkaria
Message:

Separate out the "calculation" of "bonuses" from the "updating" in player/calcs.c.

Files:

Legend:

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

    r996 r998  
    618618 * damage, since that would affect non-combat things.  These values 
    619619 * are actually added in later, at the appropriate place. 
    620  * 
    621  * This function induces various "status" messages. 
    622620 */ 
    623 static void calc_bonuses(void
     621static void calc_bonuses(object_type inventory[]
    624622{ 
    625623        int i, j, hold; 
    626  
    627         int old_speed; 
    628  
    629         int old_telepathy; 
    630         int old_see_inv; 
    631  
    632         int old_dis_ac; 
    633         int old_dis_to_a; 
    634624 
    635625        int extra_blows; 
     
    637627        int extra_might; 
    638628 
    639         int old_stat_top[A_MAX]; 
    640         int old_stat_use[A_MAX]; 
    641         int old_stat_ind[A_MAX]; 
    642  
    643         bool old_heavy_shoot; 
    644         bool old_heavy_wield; 
    645         bool old_icky_wield; 
    646  
    647629        object_type *o_ptr; 
    648630 
    649631        u32b f1, f2, f3; 
    650  
    651  
    652         /*** Memorize ***/ 
    653  
    654         /* Save the old speed */ 
    655         old_speed = p_ptr->pspeed; 
    656  
    657         /* Save the old vision stuff */ 
    658         old_telepathy = p_ptr->telepathy; 
    659         old_see_inv = p_ptr->see_inv; 
    660  
    661         /* Save the old armor class */ 
    662         old_dis_ac = p_ptr->dis_ac; 
    663         old_dis_to_a = p_ptr->dis_to_a; 
    664  
    665         /* Save the old stats */ 
    666         for (i = 0; i < A_MAX; i++) 
    667         { 
    668                 old_stat_top[i] = p_ptr->stat_top[i]; 
    669                 old_stat_use[i] = p_ptr->stat_use[i]; 
    670                 old_stat_ind[i] = p_ptr->stat_ind[i]; 
    671         } 
    672  
    673         old_heavy_shoot = p_ptr->heavy_shoot; 
    674         old_heavy_wield = p_ptr->heavy_wield; 
    675         old_icky_wield = p_ptr->icky_wield; 
    676632 
    677633 
     
    13311287        } 
    13321288 
    1333  
    1334         /*** Notice changes ***/ 
     1289        return; 
     1290
     1291 
     1292/* 
     1293 * Calculate bonuses, and print various things on changes. 
     1294 */ 
     1295void update_bonuses(void) 
     1296
     1297        int i; 
     1298 
     1299        int old_speed; 
     1300 
     1301        int old_telepathy; 
     1302        int old_see_inv; 
     1303 
     1304        int old_dis_ac; 
     1305        int old_dis_to_a; 
     1306 
     1307        int old_stat_top[A_MAX]; 
     1308        int old_stat_use[A_MAX]; 
     1309        int old_stat_ind[A_MAX]; 
     1310 
     1311        bool old_heavy_shoot; 
     1312        bool old_heavy_wield; 
     1313        bool old_icky_wield; 
     1314 
     1315 
     1316 
     1317        /*** Memorize ***/ 
     1318 
     1319        /* Save the old speed */ 
     1320        old_speed = p_ptr->pspeed; 
     1321 
     1322        /* Save the old vision stuff */ 
     1323        old_telepathy = p_ptr->telepathy; 
     1324        old_see_inv = p_ptr->see_inv; 
     1325 
     1326        /* Save the old armor class */ 
     1327        old_dis_ac = p_ptr->dis_ac; 
     1328        old_dis_to_a = p_ptr->dis_to_a; 
     1329 
     1330        /* Save the old stats */ 
     1331        for (i = 0; i < A_MAX; i++) 
     1332        { 
     1333                old_stat_top[i] = p_ptr->stat_top[i]; 
     1334                old_stat_use[i] = p_ptr->stat_use[i]; 
     1335                old_stat_ind[i] = p_ptr->stat_ind[i]; 
     1336        } 
     1337 
     1338        old_heavy_shoot = p_ptr->heavy_shoot; 
     1339        old_heavy_wield = p_ptr->heavy_wield; 
     1340        old_icky_wield = p_ptr->icky_wield; 
     1341 
     1342 
     1343 
     1344        /*** Calculate bonuses ***/ 
     1345 
     1346        calc_bonuses(inventory); 
     1347 
     1348 
     1349 
     1350        /* Notice changes */ 
    13351351 
    13361352        /* Analyze stats */ 
     
    13801396        } 
    13811397 
     1398 
    13821399        /* Hack -- Telepathy Change */ 
    13831400        if (p_ptr->telepathy != old_telepathy) 
     
    15221539        { 
    15231540                p_ptr->update &= ~(PU_BONUS); 
    1524                 calc_bonuses(); 
     1541                update_bonuses(); 
    15251542        } 
    15261543 
  • trunk/src/player/types.h

    r996 r998  
    142142        s16b stat_top[A_MAX];   /* Maximal modified stats */ 
    143143 
     144 
     145        /* Generation fields (for quick start) */ 
     146        s32b au_birth;          /* Birth gold */ 
     147        s16b stat_birth[A_MAX]; /* Birth "natural" stat values */ 
     148        s16b ht_birth;          /* Birth Height */ 
     149        s16b wt_birth;          /* Birth Weight */ 
     150 
     151 
    144152        /*** Extracted fields ***/ 
     153 
     154        s16b pspeed;            /* Current speed */ 
     155 
     156        s16b num_blow;          /* Number of blows */ 
     157        s16b num_fire;          /* Number of shots */ 
     158 
     159        byte ammo_mult;         /* Ammo multiplier */ 
     160        byte ammo_tval;         /* Ammo variety */ 
    145161 
    146162        s16b stat_add[A_MAX];   /* Equipment stat bonuses */ 
    147163        s16b stat_ind[A_MAX];   /* Indexes into stat tables */ 
     164 
     165        s16b dis_ac;            /* Known base ac */ 
     166        s16b ac;                        /* Base ac */ 
     167 
     168        s16b dis_to_a;          /* Known bonus to ac */ 
     169        s16b to_a;                      /* Bonus to ac */ 
     170 
     171        s16b to_h;                      /* Bonus to hit */ 
     172        s16b dis_to_h;          /* Known bonus to hit */ 
     173 
     174        s16b to_d;                      /* Bonus to dam */ 
     175        s16b dis_to_d;          /* Known bonus to dam */ 
     176 
     177        s16b see_infra;         /* Infravision range */ 
     178 
     179        s16b skills[SKILL_MAX]; /* Skills */ 
     180 
     181        u32b noise;                     /* Derived from stealth */ 
    148182 
    149183        bool vuln_acid; 
     
    199233 
    200234        bool bless_blade;       /* Blessed blade */ 
    201  
    202         s16b dis_to_h;          /* Known bonus to hit */ 
    203         s16b dis_to_d;          /* Known bonus to dam */ 
    204         s16b dis_to_a;          /* Known bonus to ac */ 
    205  
    206         s16b dis_ac;            /* Known base ac */ 
    207  
    208         s16b to_h;                      /* Bonus to hit */ 
    209         s16b to_d;                      /* Bonus to dam */ 
    210         s16b to_a;                      /* Bonus to ac */ 
    211  
    212         s16b ac;                        /* Base ac */ 
    213  
    214         s16b see_infra;         /* Infravision range */ 
    215  
    216         s16b skills[SKILL_MAX]; /* Skills */ 
    217  
    218         u32b noise;                     /* Derived from stealth */ 
    219  
    220         s16b num_blow;          /* Number of blows */ 
    221         s16b num_fire;          /* Number of shots */ 
    222  
    223         byte ammo_mult;         /* Ammo multiplier */ 
    224  
    225         byte ammo_tval;         /* Ammo variety */ 
    226  
    227         s16b pspeed;            /* Current speed */ 
    228  
    229         /* Generation fields (for quick start) */ 
    230         s32b au_birth;          /* Birth gold */ 
    231         s16b stat_birth[A_MAX]; /* Birth "natural" stat values */ 
    232         s16b ht_birth;          /* Birth Height */ 
    233         s16b wt_birth;          /* Birth Weight */ 
    234235}; 
    235236