diff options
| author | maximius <none@none> | 2009-11-01 17:53:07 -0800 |
|---|---|---|
| committer | maximius <none@none> | 2009-11-01 17:53:07 -0800 |
| commit | b257a28fa9a9177df32845db8171d376bd6d4404 (patch) | |
| tree | d1093029c66fc36a705aa0f344ba3a4fb77e36d5 /src/game/Formulas.h | |
| parent | 2b2b2a1d0ec0e8942b27047f6706f29775a00eb8 (diff) | |
*Cleanup, fix many cases of unoptimized loops, potential crashes, excessively large data types, unnecessary or wrong casts, non-standardized function calls, and so on..
*Proper Maexxna Web Spray locations (old locations sent players flying into the air)
--HG--
branch : trunk
Diffstat (limited to 'src/game/Formulas.h')
| -rw-r--r-- | src/game/Formulas.h | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/src/game/Formulas.h b/src/game/Formulas.h index 2ec175f95be..41e75905df2 100644 --- a/src/game/Formulas.h +++ b/src/game/Formulas.h @@ -27,61 +27,61 @@ namespace Trinity { namespace Honor { - inline uint32 hk_honor_at_level(uint32 level, uint32 count=1) + inline uint32 hk_honor_at_level(uint8 level, uint32 count = 1) { - return (uint32)ceil(count*(-0.53177f + 0.59357f * exp((level +23.54042f) / 26.07859f ))); + return uint32(ceil(count*(-0.53177f + 0.59357f * exp((level + 23.54042f) / 26.07859f)))); } } namespace XP { enum XPColorChar { RED, ORANGE, YELLOW, GREEN, GRAY }; - inline uint32 GetGrayLevel(uint32 pl_level) + inline uint8 GetGrayLevel(uint8 pl_level) { - if( pl_level <= 5 ) + if (pl_level <= 5) return 0; - else if( pl_level <= 39 ) + else if (pl_level <= 39) return pl_level - 5 - pl_level/10; - else if( pl_level <= 59 ) + else if (pl_level <= 59) return pl_level - 1 - pl_level/5; else return pl_level - 9; } - inline XPColorChar GetColorCode(uint32 pl_level, uint32 mob_level) + inline XPColorChar GetColorCode(uint8 pl_level, uint8 mob_level) { - if( mob_level >= pl_level + 5 ) + if (mob_level >= pl_level + 5) return RED; - else if( mob_level >= pl_level + 3 ) + else if (mob_level >= pl_level + 3) return ORANGE; - else if( mob_level >= pl_level - 2 ) + else if (mob_level >= pl_level - 2) return YELLOW; - else if( mob_level > GetGrayLevel(pl_level) ) + else if (mob_level > GetGrayLevel(pl_level)) return GREEN; else return GRAY; } - inline uint32 GetZeroDifference(uint32 pl_level) + inline uint8 GetZeroDifference(uint8 pl_level) { - if( pl_level < 8 ) return 5; - if( pl_level < 10 ) return 6; - if( pl_level < 12 ) return 7; - if( pl_level < 16 ) return 8; - if( pl_level < 20 ) return 9; - if( pl_level < 30 ) return 11; - if( pl_level < 40 ) return 12; - if( pl_level < 45 ) return 13; - if( pl_level < 50 ) return 14; - if( pl_level < 55 ) return 15; - if( pl_level < 60 ) return 16; + if (pl_level < 8) return 5; + if (pl_level < 10) return 6; + if (pl_level < 12) return 7; + if (pl_level < 16) return 8; + if (pl_level < 20) return 9; + if (pl_level < 30) return 11; + if (pl_level < 40) return 12; + if (pl_level < 45) return 13; + if (pl_level < 50) return 14; + if (pl_level < 55) return 15; + if (pl_level < 60) return 16; return 17; } - inline uint32 BaseGain(uint32 pl_level, uint32 mob_level, ContentLevels content) + inline uint32 BaseGain(uint8 pl_level, uint8 mob_level, ContentLevels content) { uint32 nBaseExp; - switch(content) + switch (content) { case CONTENT_1_60: nBaseExp = 45; break; case CONTENT_61_70: nBaseExp = 235; break; @@ -91,19 +91,19 @@ namespace Trinity nBaseExp = 45; break; } - if( mob_level >= pl_level ) + if (mob_level >= pl_level) { - uint32 nLevelDiff = mob_level - pl_level; + uint8 nLevelDiff = mob_level - pl_level; if (nLevelDiff > 4) nLevelDiff = 4; return ((pl_level*5 + nBaseExp) * (20 + nLevelDiff)/10 + 1)/2; } else { - uint32 gray_level = GetGrayLevel(pl_level); - if( mob_level > gray_level ) + uint8 gray_level = GetGrayLevel(pl_level); + if (mob_level > gray_level) { - uint32 ZD = GetZeroDifference(pl_level); + uint8 ZD = GetZeroDifference(pl_level); return (pl_level*5 + nBaseExp) * (ZD + mob_level - pl_level)/ZD; } return 0; @@ -112,31 +112,31 @@ namespace Trinity inline uint32 Gain(Player *pl, Unit *u) { - if(u->GetTypeId()==TYPEID_UNIT && ( + if (u->GetTypeId()==TYPEID_UNIT && ( ((Creature*)u)->isTotem() || ((Creature*)u)->isPet() || (((Creature*)u)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP_AT_KILL) )) return 0; - uint32 xp_gain= BaseGain(pl->getLevel(), u->getLevel(), GetContentLevelsForMapAndZone(u->GetMapId(),u->GetZoneId())); - if( xp_gain == 0 ) + uint32 xp_gain = BaseGain(pl->getLevel(), u->getLevel(), GetContentLevelsForMapAndZone(u->GetMapId(),u->GetZoneId())); + if (xp_gain == 0) return 0; - if(u->GetTypeId()==TYPEID_UNIT && ((Creature*)u)->isElite()) + if (u->GetTypeId() == TYPEID_UNIT && ((Creature*)u)->isElite()) xp_gain *= 2; - return (uint32)(xp_gain*sWorld.getRate(RATE_XP_KILL)); + return uint32(xp_gain*sWorld.getRate(RATE_XP_KILL)); } inline float xp_in_group_rate(uint32 count, bool isRaid) { - if(isRaid) + if (isRaid) { // FIX ME: must apply decrease modifiers dependent from raid size return 1.0f; } else { - switch(count) + switch (count) { case 0: case 1: |
