Core/Spells: Refactor SpellHistory ModifyCoooldowns and ResetCooldowns callbacks to use CooldownEntry argument instead of internal iterator

(cherry picked from commit ace6342aea)

# Conflicts:
#	src/server/scripts/Spells/spell_dh.cpp
This commit is contained in:
Shauren
2025-01-30 18:27:38 +01:00
committed by Ovahlord
parent 1547fd0d8a
commit 9f084cd749
6 changed files with 117 additions and 113 deletions

View File

@@ -91,9 +91,9 @@ class DuelResetScript : public PlayerScript
static void ResetSpellCooldowns(Player* player, bool onStartDuel)
{
// remove cooldowns on spells that have < 10 min CD > 30 sec and has no onHold
player->GetSpellHistory()->ResetCooldowns([player, onStartDuel](SpellHistory::CooldownStorageType::iterator itr) -> bool
player->GetSpellHistory()->ResetCooldowns([player, onStartDuel](SpellHistory::CooldownEntry const& cooldown) -> bool
{
SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(itr->first, DIFFICULTY_NONE);
SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(cooldown.SpellId, DIFFICULTY_NONE);
Milliseconds remainingCooldown = player->GetSpellHistory()->GetRemainingCooldown(spellInfo);
Milliseconds totalCooldown = Milliseconds(spellInfo->RecoveryTime);
Milliseconds categoryCooldown = Milliseconds(spellInfo->CategoryRecoveryTime);
@@ -114,7 +114,7 @@ class DuelResetScript : public PlayerScript
applySpellMod(categoryCooldown);
return remainingCooldown > 0ms
&& !itr->second.OnHold
&& !cooldown.OnHold
&& Milliseconds(totalCooldown) < 10min
&& Milliseconds(categoryCooldown) < 10min
&& Milliseconds(remainingCooldown) < 10min