[8125] Optimized spell cooldowns remove.

Traverse only active cooldowns instead of whole player spell map.

Signed-off-by: ApoC <apoc@nymfe.net>
This commit is contained in:
ApoC 2009-07-05 17:31:26 +02:00
parent f064ef9c49
commit 60fe792866
2 changed files with 19 additions and 19 deletions

View file

@ -1191,21 +1191,19 @@ void Spell::EffectDummy(uint32 i)
return; return;
// immediately finishes the cooldown on Frost spells // immediately finishes the cooldown on Frost spells
const PlayerSpellMap& sp_list = ((Player *)m_caster)->GetSpellMap(); const SpellCooldowns& cm = ((Player *)m_caster)->GetSpellCooldownMap();
for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr) for (SpellCooldowns::const_iterator itr = cm.begin(); itr != cm.end();)
{ {
if (itr->second->state == PLAYERSPELL_REMOVED) SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
continue;
uint32 classspell = itr->first;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(classspell);
if( spellInfo->SpellFamilyName == SPELLFAMILY_MAGE && if( spellInfo->SpellFamilyName == SPELLFAMILY_MAGE &&
(GetSpellSchoolMask(spellInfo) & SPELL_SCHOOL_MASK_FROST) && (GetSpellSchoolMask(spellInfo) & SPELL_SCHOOL_MASK_FROST) &&
spellInfo->Id != 11958 && GetSpellRecoveryTime(spellInfo) > 0 ) spellInfo->Id != 11958 && GetSpellRecoveryTime(spellInfo) > 0 )
{ {
((Player*)m_caster)->RemoveSpellCooldown(classspell, true); ((Player*)m_caster)->RemoveSpellCooldown((itr++)->first, true);
} }
else
++itr;
} }
return; return;
} }
@ -1440,14 +1438,15 @@ void Spell::EffectDummy(uint32 i)
return; return;
//immediately finishes the cooldown on certain Rogue abilities //immediately finishes the cooldown on certain Rogue abilities
const PlayerSpellMap& sp_list = ((Player *)m_caster)->GetSpellMap(); const SpellCooldowns& cm = ((Player *)m_caster)->GetSpellCooldownMap();
for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr) for (SpellCooldowns::const_iterator itr = cm.begin(); itr != cm.end();)
{ {
uint32 classspell = itr->first; SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
SpellEntry const *spellInfo = sSpellStore.LookupEntry(classspell);
if (spellInfo->SpellFamilyName == SPELLFAMILY_ROGUE && (spellInfo->SpellFamilyFlags & UI64LIT(0x0000024000000860))) if (spellInfo->SpellFamilyName == SPELLFAMILY_ROGUE && (spellInfo->SpellFamilyFlags & UI64LIT(0x0000024000000860)))
((Player*)m_caster)->RemoveSpellCooldown(classspell,true); ((Player*)m_caster)->RemoveSpellCooldown((itr++)->first,true);
else
++itr;
} }
return; return;
} }
@ -1491,14 +1490,15 @@ void Spell::EffectDummy(uint32 i)
return; return;
//immediately finishes the cooldown for hunter abilities //immediately finishes the cooldown for hunter abilities
const PlayerSpellMap& sp_list = ((Player *)m_caster)->GetSpellMap(); const SpellCooldowns& cm = ((Player*)m_caster)->GetSpellCooldownMap();
for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr) for (SpellCooldowns::const_iterator itr = cm.begin(); itr != cm.end();)
{ {
uint32 classspell = itr->first; SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
SpellEntry const *spellInfo = sSpellStore.LookupEntry(classspell);
if (spellInfo->SpellFamilyName == SPELLFAMILY_HUNTER && spellInfo->Id != 23989 && GetSpellRecoveryTime(spellInfo) > 0 ) if (spellInfo->SpellFamilyName == SPELLFAMILY_HUNTER && spellInfo->Id != 23989 && GetSpellRecoveryTime(spellInfo) > 0 )
((Player*)m_caster)->RemoveSpellCooldown(classspell,true); ((Player*)m_caster)->RemoveSpellCooldown((itr++)->first,true);
else
++itr;
} }
return; return;
} }

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "8124" #define REVISION_NR "8125"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__