Permalink
Browse files

Replaced some C-like casts with static_cast, and note to the previous…

… commit: that wasn't an added bug, just method itself was doing something, that it wasn't supposed to do (counting base_dmg in while returning bonus_damage) for ages, tried to blame, to find out when it popped out - it was there 3 years ago, after that I got lost in revisions log.
  • Loading branch information...
1 parent 1effe06 commit 9a9b43d8a19ff01625c79ff492cb3b1dde6d6c91 @neo-mat committed Feb 28, 2012
Showing with 77 additions and 74 deletions.
  1. +17 −17 src/arcemu-world/Object.cpp
  2. +18 −18 src/arcemu-world/SpellAuras.cpp
  3. +42 −39 src/arcemu-world/Unit.cpp
@@ -1627,12 +1627,12 @@ void Object::SpellNonMeleeDamageLog(Unit* pVictim, uint32 spellID, uint32 damage
if(spellInfo == NULL)
return;
- if(this->IsPlayer() && ! TO_PLAYER(this)->canCast(spellInfo))
+ if(this->IsPlayer() && ! TO< Player* >(this)->canCast(spellInfo))
return;
//==========================================================================================
//==============================Variables Initialization====================================
//==========================================================================================
- float res = float(damage);
+ float res = static_cast< float >(damage);
bool critical = false;
uint32 aproc = PROC_ON_ANY_HOSTILE_ACTION; /*| PROC_ON_SPELL_HIT;*/
@@ -1673,15 +1673,15 @@ void Object::SpellNonMeleeDamageLog(Unit* pVictim, uint32 spellID, uint32 damage
caster->RemoveAurasByInterruptFlag(AURA_INTERRUPT_ON_START_ATTACK);
- res += static_cast< float >(caster->GetSpellDmgBonus(pVictim, spellInfo, damage, false));
+ res += static_cast< float >( caster->GetSpellDmgBonus(pVictim, spellInfo, damage, false) );
if(res < 0.0f)
res = 0.0f;
}
//==========================================================================================
//==============================Post +SpellDamage Bonus Modifications=======================
//==========================================================================================
- if(res > 0.0f && !(spellInfo->AttributesExB & ATTRIBUTESEXB_CANT_CRIT))
+ if( res > 0.0f && !(spellInfo->AttributesExB & ATTRIBUTESEXB_CANT_CRIT) )
{
critical = this->IsCriticalDamageForSpell(pVictim, spellInfo);
@@ -1726,7 +1726,7 @@ void Object::SpellNonMeleeDamageLog(Unit* pVictim, uint32 spellID, uint32 damage
if( this->IsUnit() )
res += TO< Unit* >(this)->CalcSpellDamageReduction(pVictim, spellInfo, res);
//------------------------------absorption--------------------------------------------------
- uint32 ress = (uint32)res;
+ uint32 ress = static_cast< uint32 >(res);
uint32 abs_dmg = pVictim->AbsorbDamage(spellInfo->School, &ress);
uint32 ms_abs_dmg = pVictim->ManaShieldAbsorb(ress);
if(ms_abs_dmg)
@@ -1743,7 +1743,7 @@ void Object::SpellNonMeleeDamageLog(Unit* pVictim, uint32 spellID, uint32 damage
vproc |= PROC_ON_ABSORB;
// Incanter's Absorption
- if(pVictim->IsPlayer() && pVictim->HasAurasWithNameHash(SPELL_HASH_INCANTER_S_ABSORPTION))
+ if( pVictim->IsPlayer() && pVictim->HasAurasWithNameHash(SPELL_HASH_INCANTER_S_ABSORPTION) )
{
float pctmod = 0.0f;
Player* pl = TO< Player* >(pVictim);
@@ -1754,8 +1754,8 @@ void Object::SpellNonMeleeDamageLog(Unit* pVictim, uint32 spellID, uint32 damage
else if(pl->HasAura(44396))
pctmod = 0.15f;
- uint32 hp = static_cast<uint32>(0.05f * pl->GetUInt32Value(UNIT_FIELD_MAXHEALTH));
- uint32 spellpower = static_cast<uint32>(pctmod * pl->GetPosDamageDoneMod(SCHOOL_NORMAL));
+ uint32 hp = static_cast< uint32 >( 0.05f * pl->GetUInt32Value(UNIT_FIELD_MAXHEALTH) );
+ uint32 spellpower = static_cast< uint32 >( pctmod * pl->GetPosDamageDoneMod(SCHOOL_NORMAL) );
if(spellpower > hp)
spellpower = hp;
@@ -1773,7 +1773,7 @@ void Object::SpellNonMeleeDamageLog(Unit* pVictim, uint32 spellID, uint32 damage
if(ress < 0) ress = 0;
- res = (float)ress;
+ res = static_cast< float >(ress);
dealdamage dmg;
dmg.school_type = spellInfo->School;
dmg.full_damage = ress;
@@ -1789,12 +1789,12 @@ void Object::SpellNonMeleeDamageLog(Unit* pVictim, uint32 spellID, uint32 damage
if((int32)dmg.resisted_damage > dmg.full_damage)
res = 0;
else
- res = float(dmg.full_damage - dmg.resisted_damage);
+ res = static_cast< float >(dmg.full_damage - dmg.resisted_damage);
}
//------------------------------special states----------------------------------------------
if(pVictim->IsPlayer() && TO< Player* >(pVictim)->GodModeCheat == true)
{
- res = float(dmg.full_damage);
+ res = static_cast< float >(dmg.full_damage);
dmg.resisted_damage = dmg.full_damage;
}
@@ -1807,12 +1807,12 @@ void Object::SpellNonMeleeDamageLog(Unit* pVictim, uint32 spellID, uint32 damage
//==========================================================================================
//==============================Data Sending ProcHandling===================================
//==========================================================================================
- SendSpellNonMeleeDamageLog(this, pVictim, spellID, float2int32(res), static_cast<uint8>(spellInfo->School), abs_dmg, dmg.resisted_damage, false, 0, critical, IsPlayer());
- DealDamage(pVictim, float2int32(res), 2, 0, spellID);
+ SendSpellNonMeleeDamageLog(this, pVictim, spellID, static_cast< int32 >(res), static_cast< uint8 >(spellInfo->School), abs_dmg, dmg.resisted_damage, false, 0, critical, IsPlayer());
+ DealDamage(pVictim, static_cast< int32 >(res), 2, 0, spellID);
if(IsUnit())
{
- int32 dmg2 = float2int32(res);
+ int32 dmg2 = static_cast< int32 >(res);
pVictim->HandleProc(vproc, TO< Unit* >(this), spellInfo, !allowProc, dmg2, abs_dmg);
pVictim->m_procCounter = 0;
@@ -1844,7 +1844,7 @@ void Object::SpellNonMeleeDamageLog(Unit* pVictim, uint32 spellID, uint32 damage
Player* pl = TO< Player* >(pVictim);
uint32 maxmana = pl->GetMaxPower(POWER_TYPE_MANA);
- uint32 amount = uint32(maxmana * pl->m_RegenManaOnSpellResist);
+ uint32 amount = static_cast< uint32 >(maxmana * pl->m_RegenManaOnSpellResist);
pVictim->Energize(pVictim, 29442, amount, POWER_TYPE_MANA);
}
@@ -1861,10 +1861,10 @@ void Object::SpellNonMeleeDamageLog(Unit* pVictim, uint32 spellID, uint32 damage
//Shadow Word:Death
if(spellID == 32379 || spellID == 32996 || spellID == 48157 || spellID == 48158)
{
- uint32 damage2 = uint32(res + abs_dmg);
+ uint32 damage2 = static_cast< uint32 >(res + abs_dmg);
uint32 absorbed = TO< Unit* >(this)->AbsorbDamage(spellInfo->School, &damage2);
DealDamage(TO< Unit* >(this), damage2, 2, 0, spellID);
- SendSpellNonMeleeDamageLog(this, this, spellID, damage2, static_cast<uint8>(spellInfo->School), absorbed, 0, false, 0, false, IsPlayer());
+ SendSpellNonMeleeDamageLog(this, this, spellID, damage2, static_cast< uint8 >(spellInfo->School), absorbed, 0, false, 0, false, IsPlayer());
}
}
}
@@ -1788,19 +1788,19 @@ void Aura::SpellAuraPeriodicDamage(bool apply)
void Aura::EventPeriodicDamage(uint32 amount)
{
//DOT
- if(! m_target->isAlive())
+ if( !m_target->isAlive() )
return;
if(m_target->SchoolImmunityList[GetSpellProto()->School])
{
if(GetUnitCaster() != NULL)
- SendTickImmune(m_target, GetUnitCaster());
+ SendTickImmune( m_target, GetUnitCaster() );
return;
}
- float res = float(amount);
+ float res = static_cast< float >(amount);
uint32 abs_dmg = 0;
- int bonus = 0;
+ int32 bonus = 0;
uint32 school = GetSpellProto()->School;
Unit* c = GetUnitCaster();
uint32 aproc = PROC_ON_ANY_HOSTILE_ACTION;
@@ -1811,7 +1811,7 @@ void Aura::EventPeriodicDamage(uint32 amount)
{
if(c != NULL)
{
- int amp = m_spellProto->EffectAmplitude[mod->i];
+ uint32 amp = m_spellProto->EffectAmplitude[mod->i];
if(!amp)
amp = event_GetEventPeriod(EVENT_AURA_PERIODIC_DAMAGE);
@@ -1841,7 +1841,7 @@ void Aura::EventPeriodicDamage(uint32 amount)
res = 0.0f;
}
- if(DotCanCrit())
+ if( DotCanCrit() )
{
is_critical = c->IsCriticalDamageForSpell(m_target, GetSpellProto());
@@ -1855,7 +1855,7 @@ void Aura::EventPeriodicDamage(uint32 amount)
}
}
- uint32 ress = (uint32)res;
+ uint32 ress = static_cast< uint32 >(res);
abs_dmg = m_target->AbsorbDamage(school, &ress);
uint32 ms_abs_dmg = m_target->ManaShieldAbsorb(ress);
if(ms_abs_dmg)
@@ -1870,41 +1870,41 @@ void Aura::EventPeriodicDamage(uint32 amount)
if(ress < 0) ress = 0;
- res = (float)ress;
+ res = static_cast< float >(ress);
dealdamage dmg;
dmg.school_type = school;
dmg.full_damage = ress;
dmg.resisted_damage = 0;
- if(res <= 0)
+ if(res <= 0.0f)
dmg.resisted_damage = dmg.full_damage;
- if(res > 0 && c && m_spellProto->MechanicsType != MECHANIC_BLEEDING)
+ if(res > 0.0f && c && m_spellProto->MechanicsType != MECHANIC_BLEEDING)
{
c->CalculateResistanceReduction(m_target, &dmg, m_spellProto, 0);
- if((int32)dmg.resisted_damage > dmg.full_damage)
- res = 0;
+ if(static_cast< int32 >(dmg.resisted_damage) > dmg.full_damage)
+ res = 0.0f;
else
- res = float(dmg.full_damage - dmg.resisted_damage);
+ res = static_cast< float >(dmg.full_damage - dmg.resisted_damage);
}
- m_target->SendPeriodicAuraLog(m_casterGuid, m_target->GetNewGUID(), GetSpellProto()->Id, school, float2int32(res), abs_dmg, dmg.resisted_damage, FLAG_PERIODIC_DAMAGE, is_critical);
+ m_target->SendPeriodicAuraLog(m_casterGuid, m_target->GetNewGUID(), GetSpellProto()->Id, school, static_cast< int32 >(res), abs_dmg, dmg.resisted_damage, FLAG_PERIODIC_DAMAGE, is_critical);
}
// grep: this is hack.. some auras seem to delete this shit.
SpellEntry* sp = m_spellProto;
if(m_target->m_damageSplitTarget)
- res = (float)m_target->DoDamageSplitTarget((uint32)res, GetSpellProto()->School, false);
+ res = static_cast< float >( m_target->DoDamageSplitTarget(static_cast< uint32 >(res), GetSpellProto()->School, false) );
if(c != NULL)
- c->DealDamage(m_target, float2int32(res), 2, 0, GetSpellId());
+ c->DealDamage(m_target, static_cast< int32 >(res), 2, 0, GetSpellId());
else
- m_target->DealDamage(m_target, float2int32(res), 2, 0, GetSpellId());
+ m_target->DealDamage(m_target, static_cast< int32 >(res), 2, 0, GetSpellId());
if(m_target->GetGUID() != m_casterGuid && c != NULL) //don't use resist when cast on self-- this is some internal stuff
{
- int32 dmg = float2int32(res);
+ int32 dmg = static_cast< int32 >(res);
if(abs_dmg)
vproc |= PROC_ON_ABSORB;
Oops, something went wrong.

0 comments on commit 9a9b43d

Please sign in to comment.