From 04aac67970b2ac9aecac02dda5a8151e67ac199e Mon Sep 17 00:00:00 2001 From: UltraNix <80540499+UltraNix@users.noreply.github.com> Date: Tue, 26 Oct 2021 10:17:00 +0200 Subject: [PATCH] fix(Scripts/Hunter): Fixed freeze while using Readiness. (#8709) Fixes #8513 --- src/server/scripts/Spells/spell_hunter.cpp | 34 ++++++++++------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/server/scripts/Spells/spell_hunter.cpp b/src/server/scripts/Spells/spell_hunter.cpp index 32318361d..9e5def3bd 100644 --- a/src/server/scripts/Spells/spell_hunter.cpp +++ b/src/server/scripts/Spells/spell_hunter.cpp @@ -786,25 +786,23 @@ public: Player* caster = GetCaster()->ToPlayer(); // immediately finishes the cooldown on your other Hunter abilities except Bestial Wrath - PlayerSpellMap const& spellMap = caster->GetSpellMap(); - for (PlayerSpellMap::const_iterator itr = spellMap.begin(); itr != spellMap.end(); ++itr) - { - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first); - if (spellInfo->SpellFamilyName == SPELLFAMILY_HUNTER && - spellInfo->Id != SPELL_HUNTER_READINESS && - spellInfo->Id != SPELL_HUNTER_BESTIAL_WRATH && - spellInfo->Id != SPELL_DRAENEI_GIFT_OF_THE_NAARU && - spellInfo->GetRecoveryTime() > 0) - { - SpellCooldowns::iterator citr = caster->GetSpellCooldownMap().find(spellInfo->Id); - if (citr != caster->GetSpellCooldownMap().end() && citr->second.needSendToClient) - caster->RemoveSpellCooldown(spellInfo->Id, true); - else - caster->RemoveSpellCooldown(spellInfo->Id, false); - } + // force removal of the disarm cooldown + caster->RemoveSpellCooldown(SPELL_HUNTER_CHIMERA_SHOT_SCORPID); - // force removal of the disarm cooldown - caster->RemoveSpellCooldown(SPELL_HUNTER_CHIMERA_SHOT_SCORPID, false); + SpellCooldowns& cooldowns = caster->GetSpellCooldownMap(); + + SpellCooldowns::iterator itr, next; + for (itr = cooldowns.begin(); itr != cooldowns.end(); itr = next) + { + next = itr; + ++next; + + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first); + if (spellInfo->SpellFamilyName == SPELLFAMILY_HUNTER && spellInfo->Id != SPELL_HUNTER_READINESS && spellInfo->Id != SPELL_HUNTER_BESTIAL_WRATH && + spellInfo->Id != SPELL_DRAENEI_GIFT_OF_THE_NAARU && spellInfo->GetRecoveryTime() > 0) + { + caster->RemoveSpellCooldown(spellInfo->Id, itr->second.needSendToClient); + } } }