[8125] Optimized spell cooldowns remove. Author: ApoC
Traverse only active cooldowns instead of whole player spell map. --HG-- branch : trunk
This commit is contained in:
+17
-35
@@ -3472,6 +3472,7 @@ void Player::RemoveSpellCooldown( uint32 spell_id, bool update /* = false */ )
|
||||
SendClearCooldown(spell_id, this);
|
||||
}
|
||||
|
||||
// I am not sure which one is more efficient
|
||||
void Player::RemoveCategoryCooldown( uint32 cat )
|
||||
{
|
||||
SpellCategoryStore::const_iterator i_scstore = sSpellCategoryStore.find(cat);
|
||||
@@ -3480,6 +3481,22 @@ void Player::RemoveCategoryCooldown( uint32 cat )
|
||||
RemoveSpellCooldown(*i_scset, true);
|
||||
}
|
||||
|
||||
void Player::RemoveSpellCategoryCooldown(uint32 cat, bool update /* = false */)
|
||||
{
|
||||
SpellCategoryStore::const_iterator ct = sSpellCategoryStore.find(cat);
|
||||
if (ct == sSpellCategoryStore.end())
|
||||
return;
|
||||
|
||||
const SpellCategorySet& ct_set = ct->second;
|
||||
for (SpellCooldowns::const_iterator i = m_spellCooldowns.begin(); i != m_spellCooldowns.end();)
|
||||
{
|
||||
if (ct_set.find(i->first) != ct_set.end())
|
||||
RemoveSpellCooldown((i++)->first, update);
|
||||
else
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
void Player::RemoveArenaSpellCooldowns()
|
||||
{
|
||||
// remove cooldowns on spells that has < 15 min CD
|
||||
@@ -17966,42 +17983,7 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint
|
||||
return false;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD:src/game/Player.cpp
|
||||
uint8 bag = 0; // init for case invalid bagGUID
|
||||
|
||||
if (bagguid != NULL_BAG && slot != NULL_SLOT)
|
||||
{
|
||||
if( bagguid == GetGUID() )
|
||||
{
|
||||
bag = INVENTORY_SLOT_BAG_0;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END;i++)
|
||||
{
|
||||
if( Bag *pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0,i) )
|
||||
{
|
||||
if( bagguid == pBag->GetGUID() )
|
||||
{
|
||||
// slot is counted from 0 but BagSize from 1
|
||||
if(slot+1 > pBag->GetBagSize())
|
||||
{
|
||||
sLog.outDebug("CHEATING ATTEMPT slot > bagSize in BuyItemFromVendor playerGUID: "I64FMT" name: %s slot: %u", GetGUID(), GetName(), slot);
|
||||
return false;
|
||||
}
|
||||
if(slot < pBag->GetBagSlot() && !pBag->GetItemByPos(slot))
|
||||
bag = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( IsInventoryPos( bag, slot ) || (bagguid == NULL_BAG && slot == NULL_SLOT) )
|
||||
=======
|
||||
if ((bag == NULL_BAG && slot == NULL_SLOT) || IsInventoryPos(bag, slot))
|
||||
>>>>>>> 03c14bd3ebd8da13b803d18cf147d3ea8b8b5620:src/game/Player.cpp
|
||||
{
|
||||
ItemPosCountVec dest;
|
||||
uint8 msg = CanStoreNewItem( bag, slot, dest, item, pProto->BuyCount * count );
|
||||
|
||||
@@ -1437,6 +1437,8 @@ class TRINITY_DLL_SPEC Player : public Unit
|
||||
PlayerSpellMap const& GetSpellMap() const { return m_spells; }
|
||||
PlayerSpellMap & GetSpellMap() { return m_spells; }
|
||||
|
||||
SpellCooldowns const& GetSpellCooldownMap() const { return m_spellCooldowns; }
|
||||
|
||||
void AddSpellMod(SpellModifier* mod, bool apply);
|
||||
bool IsAffectedBySpellmod(SpellEntry const *spellInfo, SpellModifier *mod, Spell * spell = NULL);
|
||||
template <class T> T ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell * spell = NULL);
|
||||
@@ -1463,6 +1465,7 @@ class TRINITY_DLL_SPEC Player : public Unit
|
||||
void SendCooldownEvent(SpellEntry const *spellInfo, uint32 itemId = 0, Spell* spell = NULL);
|
||||
void ProhibitSpellScholl(SpellSchoolMask idSchoolMask, uint32 unTimeMs );
|
||||
void RemoveSpellCooldown(uint32 spell_id, bool update = false);
|
||||
void RemoveSpellCategoryCooldown(uint32 cat, bool update = false);
|
||||
void SendClearCooldown( uint32 spell_id, Unit* target );
|
||||
|
||||
void RemoveCategoryCooldown(uint32 cat);
|
||||
|
||||
+18
-18
@@ -1328,21 +1328,19 @@ void Spell::EffectDummy(uint32 i)
|
||||
return;
|
||||
|
||||
// immediately finishes the cooldown on Frost spells
|
||||
const PlayerSpellMap& sp_list = ((Player *)m_caster)->GetSpellMap();
|
||||
for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr)
|
||||
const SpellCooldowns& cm = ((Player *)m_caster)->GetSpellCooldownMap();
|
||||
for (SpellCooldowns::const_iterator itr = cm.begin(); itr != cm.end();)
|
||||
{
|
||||
if (itr->second->state == PLAYERSPELL_REMOVED)
|
||||
continue;
|
||||
|
||||
uint32 classspell = itr->first;
|
||||
SpellEntry const *spellInfo = sSpellStore.LookupEntry(classspell);
|
||||
SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
|
||||
|
||||
if( spellInfo->SpellFamilyName == SPELLFAMILY_MAGE &&
|
||||
(GetSpellSchoolMask(spellInfo) & SPELL_SCHOOL_MASK_FROST) &&
|
||||
spellInfo->Id != 11958 && GetSpellRecoveryTime(spellInfo) > 0 )
|
||||
{
|
||||
((Player*)m_caster)->RemoveSpellCooldown(classspell, true);
|
||||
((Player*)m_caster)->RemoveSpellCooldown((itr++)->first, true);
|
||||
}
|
||||
else
|
||||
++itr;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -1619,14 +1617,15 @@ void Spell::EffectDummy(uint32 i)
|
||||
return;
|
||||
|
||||
//immediately finishes the cooldown on certain Rogue abilities
|
||||
const PlayerSpellMap& sp_list = ((Player *)m_caster)->GetSpellMap();
|
||||
for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr)
|
||||
const SpellCooldowns& cm = ((Player *)m_caster)->GetSpellCooldownMap();
|
||||
for (SpellCooldowns::const_iterator itr = cm.begin(); itr != cm.end();)
|
||||
{
|
||||
uint32 classspell = itr->first;
|
||||
SpellEntry const *spellInfo = sSpellStore.LookupEntry(classspell);
|
||||
SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
|
||||
|
||||
if (spellInfo->SpellFamilyName == SPELLFAMILY_ROGUE && (spellInfo->SpellFamilyFlags[1] & 0x00000240 || spellInfo->SpellFamilyFlags[0] & 0x00000860))
|
||||
((Player*)m_caster)->RemoveSpellCooldown(classspell,true);
|
||||
((Player*)m_caster)->RemoveSpellCooldown((itr++)->first,true);
|
||||
else
|
||||
++itr;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -1646,14 +1645,15 @@ void Spell::EffectDummy(uint32 i)
|
||||
return;
|
||||
|
||||
//immediately finishes the cooldown for hunter abilities
|
||||
const PlayerSpellMap& sp_list = ((Player *)m_caster)->GetSpellMap();
|
||||
for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr)
|
||||
const SpellCooldowns& cm = ((Player*)m_caster)->GetSpellCooldownMap();
|
||||
for (SpellCooldowns::const_iterator itr = cm.begin(); itr != cm.end();)
|
||||
{
|
||||
uint32 classspell = itr->first;
|
||||
SpellEntry const *spellInfo = sSpellStore.LookupEntry(classspell);
|
||||
SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
+2
-2
@@ -7792,9 +7792,9 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig
|
||||
// Sword and Board
|
||||
case 50227:
|
||||
{
|
||||
// remove cooldown of Shield Slam
|
||||
// Remove cooldown on Shield Slam
|
||||
if (GetTypeId()==TYPEID_PLAYER)
|
||||
((Player*)this)->RemoveCategoryCooldown(1209);
|
||||
((Player*)this)->RemoveSpellCategoryCooldown(1209, true);
|
||||
break;
|
||||
}
|
||||
case 63375: // Improved Stormstrike
|
||||
|
||||
Reference in New Issue
Block a user