diff options
author | Adam Borowski <kilobyte@angband.pl> | 2012-06-18 14:37:51 +0200 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2012-06-19 14:38:30 +0200 |
commit | b47796fe2177b30c3406e2735c2e7b9b4a892292 (patch) | |
tree | 442160799313b0c24a340daa809c1fe718da0039 /crawl-ref/source/ng-wanderer.cc | |
parent | 4835408b6ab43dc3c71c0b594bb414fab33921cf (diff) | |
download | crawl-ref-b47796fe2177b30c3406e2735c2e7b9b4a892292.tar.gz crawl-ref-b47796fe2177b30c3406e2735c2e7b9b4a892292.zip |
Use ARRAYSZ() instead of sizeof division, for readability.
Also, it's not vulnerable to changes to the underlying types.
Diffstat (limited to 'crawl-ref/source/ng-wanderer.cc')
-rw-r--r-- | crawl-ref/source/ng-wanderer.cc | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/crawl-ref/source/ng-wanderer.cc b/crawl-ref/source/ng-wanderer.cc index 467d45a071..fb7eadfa1f 100644 --- a/crawl-ref/source/ng-wanderer.cc +++ b/crawl-ref/source/ng-wanderer.cc @@ -218,13 +218,13 @@ static skill_type _wanderer_role_weapon_select(stat_type role) const skill_type str_weapons[] = { SK_AXES, SK_MACES_FLAILS, SK_BOWS, SK_CROSSBOWS }; - int str_size = sizeof(str_weapons) / sizeof(skill_type); + int str_size = ARRAYSZ(str_weapons); const skill_type dex_weapons[] = { SK_SHORT_BLADES, SK_LONG_BLADES, SK_STAVES, SK_UNARMED_COMBAT, SK_POLEARMS }; - int dex_size = sizeof(dex_weapons) / sizeof(skill_type); + int dex_size = ARRAYSZ(dex_weapons); const skill_type casting_schools[] = { SK_SUMMONINGS, SK_NECROMANCY, SK_TRANSLOCATIONS, @@ -232,7 +232,7 @@ static skill_type _wanderer_role_weapon_select(stat_type role) SK_HEXES, SK_CHARMS, SK_FIRE_MAGIC, SK_ICE_MAGIC, SK_AIR_MAGIC, SK_EARTH_MAGIC }; - int casting_size = sizeof(casting_schools) / sizeof(skill_type); + int casting_size = ARRAYSZ(casting_schools); switch ((int)role) { @@ -519,7 +519,7 @@ static void _wanderer_good_equipment(skill_type & skill, int & slot) SK_SHORT_BLADES, SK_LONG_BLADES, SK_STAVES, SK_UNARMED_COMBAT, SK_POLEARMS }; - int total_weapons = sizeof(combined_weapon_skills) / sizeof(skill_type); + int total_weapons = ARRAYSZ(combined_weapon_skills); // Normalise the input type. if (skill == SK_FIGHTING) @@ -675,7 +675,7 @@ static void _wanderer_decent_equipment(skill_type & skill, SK_SHORT_BLADES, SK_LONG_BLADES, SK_STAVES, SK_UNARMED_COMBAT, SK_POLEARMS }; - int total_weapons = sizeof(combined_weapon_skills) / sizeof(skill_type); + int total_weapons = ARRAYSZ(combined_weapon_skills); // If we already gave an item for this type, just give the player // a consumable. @@ -877,7 +877,7 @@ void create_wanderer(void) { SK_THROWING, SK_STABBING, SK_TRAPS_DOORS, SK_STEALTH, SK_SHIELDS, SK_EVOCATIONS, SK_INVOCATIONS }; - int util_size = sizeof(util_skills) / sizeof(skill_type); + int util_size = ARRAYSZ(util_skills); // No Invocations for demigods. if (you.species == SP_DEMIGOD) |