aboutsummaryrefslogtreecommitdiff
path: root/src/game/Unit.cpp
diff options
context:
space:
mode:
authormegamage <none@none>2009-04-07 11:26:22 -0500
committermegamage <none@none>2009-04-07 11:26:22 -0500
commitc6b6a72956efdc10da8fac982db734b054984d08 (patch)
tree67b5a5c912206bd022fbc33eae26d94a15d11699 /src/game/Unit.cpp
parent6f3efad8991238d2b4f68b26dced47ae5b2e0bc8 (diff)
*Remove some redundant code.
--HG-- branch : trunk
Diffstat (limited to 'src/game/Unit.cpp')
-rw-r--r--src/game/Unit.cpp61
1 files changed, 23 insertions, 38 deletions
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 228622ecc2f..e08d4c2d43e 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -3201,49 +3201,37 @@ void Unit::_UpdateSpells( uint32 time )
// TODO: Find a better way to prevent crash when multiple auras are removed.
m_removedAuras = 0;
for (AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end(); ++i)
- if ((*i).second)
- (*i).second->SetUpdated(false);
+ i->second->SetUpdated(false);
- for (AuraMap::iterator i = m_Auras.begin(), next; i != m_Auras.end(); i = next)
+ for(AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end();)
{
- next = i;
- ++next;
- if ((*i).second)
+ Aura *aur = i->second;
+
+ // prevent double update
+ if (aur->IsUpdated())
+ continue;
+ aur->SetUpdated(true);
+
+ aur->SetInUse(true);
+ aur->Update( time );
+ aur->SetInUse(false);
+
+ // several auras can be deleted due to update
+ if(m_removedAuras)
{
- // prevent double update
- if ((*i).second->IsUpdated())
- continue;
- (*i).second->SetUpdated(true);
- (*i).second->SetInUse(true);
- (*i).second->Update( time );
- (*i).second->SetInUse(false);
- // several auras can be deleted due to update
- if (m_removedAuras)
- {
- if (m_Auras.empty()) break;
- next = m_Auras.begin();
- m_removedAuras = 0;
- }
+ m_removedAuras = 0;
+ i = m_Auras.begin();
}
+ else
+ ++i;
}
- for (AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end();)
+ for(AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end();)
{
- if ((*i).second)
- {
- if ( !(*i).second->GetAuraDuration() && !((*i).second->IsPermanent() || ((*i).second->IsPassive())) )
- {
- RemoveAura(i, AURA_REMOVE_BY_EXPIRE);
- }
- else
- {
- ++i;
- }
- }
+ if(!i->second->GetAuraDuration() && !(i->second->IsPermanent() || (i->second->IsPassive())))
+ RemoveAura(i, AURA_REMOVE_BY_EXPIRE);
else
- {
++i;
- }
}
if(!m_gameObj.empty())
@@ -4151,10 +4139,7 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode)
statue->UnSummon();
// only way correctly remove all auras from list
- if( m_Auras.empty() )
- i = m_Auras.end();
- else
- i = m_Auras.begin();
+ i = m_Auras.begin();
}
void Unit::RemoveAllAuras()