From 04c303a7e5bc8bc27dedfdb99bc893f6d55da1de Mon Sep 17 00:00:00 2001 From: Keader Date: Sat, 1 Jul 2017 16:56:30 -0300 Subject: Core/Custom: Fixed Duel Reset Exploits Close #17419 *Fixed exploit with SPELLMOD_COOLDOWN *Fixed exploit with some items (like Sylvanas' Music Box) *Little cleanup (cherry picked from commit 0048d4b618e6503a5f1607f3503fcf2d48e6a385) --- src/server/scripts/World/duel_reset.cpp | 37 ++++++++++----------------------- 1 file changed, 11 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/server/scripts/World/duel_reset.cpp b/src/server/scripts/World/duel_reset.cpp index 7ad9fb596e7..c2255893704 100644 --- a/src/server/scripts/World/duel_reset.cpp +++ b/src/server/scripts/World/duel_reset.cpp @@ -90,33 +90,18 @@ class DuelResetScript : public PlayerScript static void ResetSpellCooldowns(Player* player, bool onStartDuel) { - if (onStartDuel) + // remove cooldowns on spells that have < 10 min CD, has no onHold and Aura + player->GetSpellHistory()->ResetCooldowns([player, onStartDuel](SpellHistory::CooldownStorageType::iterator itr) -> bool { - // remove cooldowns on spells that have < 10 min CD > 30 sec and has no onHold - player->GetSpellHistory()->ResetCooldowns([](SpellHistory::CooldownStorageType::iterator itr) -> bool - { - SpellHistory::Clock::time_point now = GameTime::GetGameTimeSystemPoint(); - uint32 cooldownDuration = itr->second.CooldownEnd > now ? std::chrono::duration_cast(itr->second.CooldownEnd - now).count() : 0; - SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(itr->first, DIFFICULTY_NONE); - return spellInfo->RecoveryTime < 10 * MINUTE * IN_MILLISECONDS - && spellInfo->CategoryRecoveryTime < 10 * MINUTE * IN_MILLISECONDS - && !itr->second.OnHold - && cooldownDuration > 0 - && ( spellInfo->RecoveryTime - cooldownDuration ) > (MINUTE / 2) * IN_MILLISECONDS - && ( spellInfo->CategoryRecoveryTime - cooldownDuration ) > (MINUTE / 2) * IN_MILLISECONDS; - }, true); - } - else - { - // remove cooldowns on spells that have < 10 min CD and has no onHold - player->GetSpellHistory()->ResetCooldowns([](SpellHistory::CooldownStorageType::iterator itr) -> bool - { - SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(itr->first, DIFFICULTY_NONE); - return spellInfo->RecoveryTime < 10 * MINUTE * IN_MILLISECONDS - && spellInfo->CategoryRecoveryTime < 10 * MINUTE * IN_MILLISECONDS - && !itr->second.OnHold; - }, true); - } + SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(itr->first, DIFFICULTY_NONE); + uint32 remainingCooldown = player->GetSpellHistory()->GetRemainingCooldown(spellInfo); + return remainingCooldown > 0 + && !itr->second.OnHold + && Milliseconds(spellInfo->RecoveryTime) < Minutes(10) + && Milliseconds(spellInfo->CategoryRecoveryTime) < Minutes(10) + && Milliseconds(remainingCooldown) < Minutes(10) + && (onStartDuel ? !player->HasAura(spellInfo->Id) : true); + }, true); // pet cooldowns if (Pet* pet = player->GetPet()) -- cgit v1.2.3