Core/Arenas: Remove pet spell cooldowns on arena join too, fixes issue 1868

--HG--
branch : trunk
This commit is contained in:
Shocker
2010-10-16 17:01:01 +03:00
parent ae213dd580
commit 8154f7243c
3 changed files with 21 additions and 6 deletions
@@ -1104,7 +1104,6 @@ void Battleground::AddPlayer(Player *plr)
// add arena specific auras // add arena specific auras
if (isArena()) if (isArena())
{ {
plr->RemoveArenaSpellCooldowns();
plr->RemoveArenaAuras(); plr->RemoveArenaAuras();
plr->RemoveArenaEnchantments(TEMP_ENCHANTMENT_SLOT); plr->RemoveArenaEnchantments(TEMP_ENCHANTMENT_SLOT);
if (team == ALLIANCE) // gold if (team == ALLIANCE) // gold
+20 -4
View File
@@ -1981,6 +1981,10 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
LeaveBattleground(false); // don't teleport to entry point LeaveBattleground(false); // don't teleport to entry point
} }
// remove arena spell coldowns now to also remove pet's cooldowns before it's temporarily unsummoned
if (mEntry->IsBattleArena())
RemoveArenaSpellCooldowns(true);
// remove pet on map change // remove pet on map change
if (pet) if (pet)
UnsummonPetTemporaryIfAny(); UnsummonPetTemporaryIfAny();
@@ -3896,17 +3900,17 @@ void Player::RemoveSpellCategoryCooldown(uint32 cat, bool update /* = false */)
} }
} }
void Player::RemoveArenaSpellCooldowns() void Player::RemoveArenaSpellCooldowns(bool removeActivePetCooldowns)
{ {
// remove cooldowns on spells that has < 15 min CD // remove cooldowns on spells that have <= 10 min CD
SpellCooldowns::iterator itr, next; SpellCooldowns::iterator itr, next;
// iterate spell cooldowns
for (itr = m_spellCooldowns.begin(); itr != m_spellCooldowns.end(); itr = next) for (itr = m_spellCooldowns.begin(); itr != m_spellCooldowns.end(); itr = next)
{ {
next = itr; next = itr;
++next; ++next;
SpellEntry const * entry = sSpellStore.LookupEntry(itr->first); SpellEntry const * entry = sSpellStore.LookupEntry(itr->first);
// check if spellentry is present and if the cooldown is less than 10 mins // check if spellentry is present and if the cooldown is less or equal to 10 min
if (entry && if (entry &&
entry->RecoveryTime <= 10 * MINUTE * IN_MILLISECONDS && entry->RecoveryTime <= 10 * MINUTE * IN_MILLISECONDS &&
entry->CategoryRecoveryTime <= 10 * MINUTE * IN_MILLISECONDS) entry->CategoryRecoveryTime <= 10 * MINUTE * IN_MILLISECONDS)
@@ -3915,6 +3919,18 @@ void Player::RemoveArenaSpellCooldowns()
RemoveSpellCooldown(itr->first, true); RemoveSpellCooldown(itr->first, true);
} }
} }
// pet cooldowns
if (removeActivePetCooldowns)
if (Pet *pet = GetPet())
{
// notify player
for (CreatureSpellCooldowns::const_iterator itr = pet->m_CreatureSpellCooldowns.begin(); itr != pet->m_CreatureSpellCooldowns.end(); ++itr)
SendClearCooldown(itr->first, pet);
// actually clear cooldowns
pet->m_CreatureSpellCooldowns.clear();
}
} }
void Player::RemoveAllSpellCooldown() void Player::RemoveAllSpellCooldown()
+1 -1
View File
@@ -1630,7 +1630,7 @@ class Player : public Unit, public GridObject<Player>
void SendClearCooldown(uint32 spell_id, Unit* target); void SendClearCooldown(uint32 spell_id, Unit* target);
void RemoveCategoryCooldown(uint32 cat); void RemoveCategoryCooldown(uint32 cat);
void RemoveArenaSpellCooldowns(); void RemoveArenaSpellCooldowns(bool removeActivePetCooldowns = false);
void RemoveAllSpellCooldown(); void RemoveAllSpellCooldown();
void _LoadSpellCooldowns(PreparedQueryResult result); void _LoadSpellCooldowns(PreparedQueryResult result);
void _SaveSpellCooldowns(SQLTransaction& trans); void _SaveSpellCooldowns(SQLTransaction& trans);