mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[7730] Some optimizantion and code style.
Signed-off-by: AlexDereka <dereka.alex@gmail.com>
This commit is contained in:
parent
a4373c887d
commit
8144f30199
69 changed files with 536 additions and 536 deletions
|
|
@ -90,7 +90,7 @@ Unit::Unit()
|
|||
m_form = FORM_NONE;
|
||||
m_deathState = ALIVE;
|
||||
|
||||
for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++)
|
||||
for (uint32 i = 0; i < CURRENT_MAX_SPELL; ++i)
|
||||
m_currentSpells[i] = NULL;
|
||||
|
||||
m_addDmgOnce = 0;
|
||||
|
|
@ -160,7 +160,7 @@ Unit::Unit()
|
|||
Unit::~Unit()
|
||||
{
|
||||
// set current spells as deletable
|
||||
for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++)
|
||||
for (uint32 i = 0; i < CURRENT_MAX_SPELL; ++i)
|
||||
{
|
||||
if (m_currentSpells[i])
|
||||
{
|
||||
|
|
@ -332,7 +332,7 @@ bool Unit::canReachWithAttack(Unit *pVictim) const
|
|||
void Unit::RemoveSpellsCausingAura(AuraType auraType)
|
||||
{
|
||||
if (auraType >= TOTAL_AURAS) return;
|
||||
AuraList::iterator iter, next;
|
||||
AuraList::const_iterator iter, next;
|
||||
for (iter = m_modAuras[auraType].begin(); iter != m_modAuras[auraType].end(); iter = next)
|
||||
{
|
||||
next = iter;
|
||||
|
|
@ -757,7 +757,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
|
|||
|
||||
// TODO: Store auras by interrupt flag to speed this up.
|
||||
AuraMap& vAuras = pVictim->GetAuras();
|
||||
for (AuraMap::iterator i = vAuras.begin(), next; i != vAuras.end(); i = next)
|
||||
for (AuraMap::const_iterator i = vAuras.begin(), next; i != vAuras.end(); i = next)
|
||||
{
|
||||
const SpellEntry *se = i->second->GetSpellProto();
|
||||
next = i; ++next;
|
||||
|
|
@ -784,7 +784,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
|
|||
{
|
||||
if( damagetype != DOT )
|
||||
{
|
||||
for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; i++)
|
||||
for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i)
|
||||
{
|
||||
// skip channeled spell (processed differently below)
|
||||
if (i == CURRENT_CHANNELED_SPELL)
|
||||
|
|
@ -851,7 +851,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
|
|||
|
||||
void Unit::CastStop(uint32 except_spellid)
|
||||
{
|
||||
for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; i++)
|
||||
for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i)
|
||||
if (m_currentSpells[i] && m_currentSpells[i]->m_spellInfo->Id!=except_spellid)
|
||||
InterruptSpell(i,false);
|
||||
}
|
||||
|
|
@ -1483,7 +1483,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss)
|
|||
{
|
||||
if(GetTypeId() == TYPEID_PLAYER && pVictim->isAlive())
|
||||
{
|
||||
for(int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; i++)
|
||||
for(int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i)
|
||||
((Player*)this)->CastItemCombatSpell(((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0,i), pVictim, damageInfo->attackType);
|
||||
}
|
||||
|
||||
|
|
@ -1588,7 +1588,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
|
|||
uint32 faq[4] = {24,6,4,6};
|
||||
uint8 m = 0;
|
||||
float Binom = 0.0f;
|
||||
for (uint8 i = 0; i < 4; i++)
|
||||
for (uint8 i = 0; i < 4; ++i)
|
||||
{
|
||||
Binom += 2400 *( powf(tmpvalue2, i) * powf( (1-tmpvalue2), (4-i)))/faq[i];
|
||||
if (ran > Binom )
|
||||
|
|
@ -2618,7 +2618,7 @@ float Unit::MeleeMissChanceCalc(const Unit *pVictim, WeaponAttackType attType) c
|
|||
if (haveOffhandWeapon() && attType != RANGED_ATTACK)
|
||||
{
|
||||
bool isNormal = false;
|
||||
for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; i++)
|
||||
for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i)
|
||||
{
|
||||
if( m_currentSpells[i] && (GetSpellSchoolMask(m_currentSpells[i]->m_spellInfo) & SPELL_SCHOOL_MASK_NORMAL) )
|
||||
{
|
||||
|
|
@ -2874,7 +2874,7 @@ void Unit::_UpdateSpells( uint32 time )
|
|||
_UpdateAutoRepeatSpell();
|
||||
|
||||
// remove finished spells from current pointers
|
||||
for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++)
|
||||
for (uint32 i = 0; i < CURRENT_MAX_SPELL; ++i)
|
||||
{
|
||||
if (m_currentSpells[i] && m_currentSpells[i]->getState() == SPELL_STATE_FINISHED)
|
||||
{
|
||||
|
|
@ -3119,7 +3119,7 @@ void Unit::InterruptNonMeleeSpells(bool withDelayed, uint32 spell_id)
|
|||
|
||||
Spell* Unit::FindCurrentSpellBySpellId(uint32 spell_id) const
|
||||
{
|
||||
for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++)
|
||||
for (uint32 i = 0; i < CURRENT_MAX_SPELL; ++i)
|
||||
if(m_currentSpells[i] && m_currentSpells[i]->m_spellInfo->Id==spell_id)
|
||||
return m_currentSpells[i];
|
||||
return NULL;
|
||||
|
|
@ -3420,7 +3420,7 @@ bool Unit::AddAura(Aura *Aur)
|
|||
|
||||
bool restart = false;
|
||||
AuraList& scAuras = caster->GetSingleCastAuras();
|
||||
for(AuraList::iterator itr = scAuras.begin(); itr != scAuras.end(); ++itr)
|
||||
for(AuraList::const_iterator itr = scAuras.begin(); itr != scAuras.end(); ++itr)
|
||||
{
|
||||
if( (*itr)->GetTarget() != Aur->GetTarget() &&
|
||||
IsSingleTargetSpells((*itr)->GetSpellProto(),aurSpellInfo) )
|
||||
|
|
@ -3463,7 +3463,7 @@ void Unit::RemoveRankAurasDueToSpell(uint32 spellId)
|
|||
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
|
||||
if(!spellInfo)
|
||||
return;
|
||||
AuraMap::iterator i,next;
|
||||
AuraMap::const_iterator i,next;
|
||||
for (i = m_Auras.begin(); i != m_Auras.end(); i = next)
|
||||
{
|
||||
next = i;
|
||||
|
|
@ -3922,7 +3922,7 @@ void Unit::RemoveAllAurasOnDeath()
|
|||
|
||||
void Unit::DelayAura(uint32 spellId, uint32 effindex, int32 delaytime)
|
||||
{
|
||||
AuraMap::iterator iter = m_Auras.find(spellEffectPair(spellId, effindex));
|
||||
AuraMap::const_iterator iter = m_Auras.find(spellEffectPair(spellId, effindex));
|
||||
if (iter != m_Auras.end())
|
||||
{
|
||||
if (iter->second->GetAuraDuration() < delaytime)
|
||||
|
|
@ -3936,7 +3936,7 @@ void Unit::DelayAura(uint32 spellId, uint32 effindex, int32 delaytime)
|
|||
|
||||
void Unit::_RemoveAllAuraMods()
|
||||
{
|
||||
for (AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end(); ++i)
|
||||
for (AuraMap::const_iterator i = m_Auras.begin(); i != m_Auras.end(); ++i)
|
||||
{
|
||||
(*i).second->ApplyModifier(false);
|
||||
}
|
||||
|
|
@ -3944,7 +3944,7 @@ void Unit::_RemoveAllAuraMods()
|
|||
|
||||
void Unit::_ApplyAllAuraMods()
|
||||
{
|
||||
for (AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end(); ++i)
|
||||
for (AuraMap::const_iterator i = m_Auras.begin(); i != m_Auras.end(); ++i)
|
||||
{
|
||||
(*i).second->ApplyModifier(true);
|
||||
}
|
||||
|
|
@ -3952,7 +3952,7 @@ void Unit::_ApplyAllAuraMods()
|
|||
|
||||
Aura* Unit::GetAura(uint32 spellId, uint32 effindex)
|
||||
{
|
||||
AuraMap::iterator iter = m_Auras.find(spellEffectPair(spellId, effindex));
|
||||
AuraMap::const_iterator iter = m_Auras.find(spellEffectPair(spellId, effindex));
|
||||
if (iter != m_Auras.end())
|
||||
return iter->second;
|
||||
return NULL;
|
||||
|
|
@ -4776,7 +4776,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAu
|
|||
|
||||
// Remove any stun effect on target
|
||||
AuraMap& Auras = pVictim->GetAuras();
|
||||
for(AuraMap::iterator iter = Auras.begin(); iter != Auras.end();)
|
||||
for(AuraMap::const_iterator iter = Auras.begin(); iter != Auras.end();)
|
||||
{
|
||||
SpellEntry const *spell = iter->second->GetSpellProto();
|
||||
if( spell->Mechanic == MECHANIC_STUN ||
|
||||
|
|
@ -5539,7 +5539,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAu
|
|||
case 54939:
|
||||
{
|
||||
// Lookup base amount mana restore
|
||||
for (int i=0; i<3;i++)
|
||||
for (int i=0; i<3;++i)
|
||||
if (procSpell->Effect[i] == SPELL_EFFECT_ENERGIZE)
|
||||
{
|
||||
int32 mana = procSpell->EffectBasePoints[i];
|
||||
|
|
@ -7267,7 +7267,7 @@ bool Unit::isAttackingPlayer() const
|
|||
if(charmed && charmed->isAttackingPlayer())
|
||||
return true;
|
||||
|
||||
for (int8 i = 0; i < MAX_TOTEM; i++)
|
||||
for (int8 i = 0; i < MAX_TOTEM; ++i)
|
||||
{
|
||||
if(m_TotemSlot[i])
|
||||
{
|
||||
|
|
@ -7284,7 +7284,7 @@ void Unit::RemoveAllAttackers()
|
|||
{
|
||||
while (!m_attackers.empty())
|
||||
{
|
||||
AttackerSet::iterator iter = m_attackers.begin();
|
||||
AttackerSet::const_iterator iter = m_attackers.begin();
|
||||
if(!(*iter)->AttackStop())
|
||||
{
|
||||
sLog.outError("WORLD: Unit has an attacker that isn't attacking it!");
|
||||
|
|
@ -8458,7 +8458,7 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage,WeaponAttackType attT
|
|||
bool normalized = false;
|
||||
if(spellProto)
|
||||
{
|
||||
for (uint8 i = 0; i<3;i++)
|
||||
for (uint8 i = 0; i<3;++i)
|
||||
{
|
||||
if (spellProto->Effect[i] == SPELL_EFFECT_NORMALIZED_WEAPON_DMG)
|
||||
{
|
||||
|
|
@ -10222,7 +10222,7 @@ CharmInfo::CharmInfo(Unit* unit)
|
|||
void CharmInfo::InitPetActionBar()
|
||||
{
|
||||
// the first 3 SpellOrActions are attack, follow and stay
|
||||
for(uint32 i = 0; i < 3; i++)
|
||||
for(uint32 i = 0; i < 3; ++i)
|
||||
{
|
||||
PetActionBar[i].Type = ACT_COMMAND;
|
||||
PetActionBar[i].SpellOrAction = COMMAND_ATTACK - i;
|
||||
|
|
@ -10230,7 +10230,7 @@ void CharmInfo::InitPetActionBar()
|
|||
PetActionBar[i + 7].Type = ACT_REACTION;
|
||||
PetActionBar[i + 7].SpellOrAction = COMMAND_ATTACK - i;
|
||||
}
|
||||
for(uint32 i=0; i < 4; i++)
|
||||
for(uint32 i=0; i < 4; ++i)
|
||||
{
|
||||
PetActionBar[i + 3].Type = ACT_DISABLED;
|
||||
PetActionBar[i + 3].SpellOrAction = 0;
|
||||
|
|
@ -10312,7 +10312,7 @@ void CharmInfo::InitCharmCreateSpells()
|
|||
|
||||
bool CharmInfo::AddSpellToAB(uint32 oldid, uint32 newid, ActiveStates newstate)
|
||||
{
|
||||
for(uint8 i = 0; i < 10; i++)
|
||||
for(uint8 i = 0; i < 10; ++i)
|
||||
{
|
||||
if((PetActionBar[i].Type == ACT_DISABLED || PetActionBar[i].Type == ACT_ENABLED || PetActionBar[i].Type == ACT_PASSIVE) && PetActionBar[i].SpellOrAction == oldid)
|
||||
{
|
||||
|
|
@ -10379,7 +10379,7 @@ typedef std::list< uint32> RemoveSpellList;
|
|||
// for example SPELL_AURA_MECHANIC_IMMUNITY - need check for mechanic
|
||||
bool InitTriggerAuraData()
|
||||
{
|
||||
for (int i=0;i<TOTAL_AURAS;i++)
|
||||
for (int i=0;i<TOTAL_AURAS;++i)
|
||||
{
|
||||
isTriggerAura[i]=false;
|
||||
isNonTriggerAura[i] = false;
|
||||
|
|
@ -10543,7 +10543,7 @@ void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag
|
|||
return;
|
||||
|
||||
// Handle effects proceed this time
|
||||
for(ProcTriggeredList::iterator i = procTriggered.begin(); i != procTriggered.end(); ++i)
|
||||
for(ProcTriggeredList::const_iterator i = procTriggered.begin(); i != procTriggered.end(); ++i)
|
||||
{
|
||||
// Some auras can be deleted in function called in this loop (except first, ofc)
|
||||
// Until storing auars in std::multimap to hard check deleting by another way
|
||||
|
|
@ -10564,7 +10564,7 @@ void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag
|
|||
{
|
||||
// sLog.outDebug("Spell aura %u (id:%u effect:%u) has been deleted before call spell proc event handler", i->triggeredByAura->GetModifier()->m_auraname, i->triggeredByAura_SpellPair.first, i->triggeredByAura_SpellPair.second);
|
||||
// sLog.outDebug("It can be deleted one from early proccesed auras:");
|
||||
// for(ProcTriggeredList::iterator i2 = procTriggered.begin(); i != i2; ++i2)
|
||||
// for(ProcTriggeredList::const_iterator i2 = procTriggered.begin(); i != i2; ++i2)
|
||||
// sLog.outDebug(" Spell aura %u (id:%u effect:%u)", i->triggeredByAura->GetModifier()->m_auraname,i2->triggeredByAura_SpellPair.first,i2->triggeredByAura_SpellPair.second);
|
||||
// sLog.outDebug(" <end of list>");
|
||||
continue;
|
||||
|
|
@ -10699,7 +10699,7 @@ void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag
|
|||
removedSpells.sort();
|
||||
removedSpells.unique();
|
||||
// Remove auras from removedAuras
|
||||
for(RemoveSpellList::const_iterator i = removedSpells.begin(); i != removedSpells.end();i++)
|
||||
for(RemoveSpellList::const_iterator i = removedSpells.begin(); i != removedSpells.end();++i)
|
||||
RemoveAurasDueToSpell(*i);
|
||||
}
|
||||
}
|
||||
|
|
@ -11060,7 +11060,7 @@ Unit* Unit::SelectNearbyTarget() const
|
|||
|
||||
bool Unit::hasNegativeAuraWithInterruptFlag(uint32 flag)
|
||||
{
|
||||
for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); ++iter)
|
||||
for (AuraMap::const_iterator iter = m_Auras.begin(); iter != m_Auras.end(); ++iter)
|
||||
{
|
||||
if (!iter->second->IsPositive() && iter->second->GetSpellProto()->AuraInterruptFlags & flag)
|
||||
return true;
|
||||
|
|
@ -11107,7 +11107,7 @@ uint32 Unit::GetCastingTimeForBonus( SpellEntry const *spellProto, DamageEffectT
|
|||
bool DirectDamage = false;
|
||||
bool AreaEffect = false;
|
||||
|
||||
for ( uint32 i=0; i<3;i++)
|
||||
for ( uint32 i=0; i<3;++i)
|
||||
{
|
||||
switch ( spellProto->Effect[i] )
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue