aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorariel- <ariel-@users.noreply.github.com>2016-12-30 15:59:59 -0300
committerariel- <ariel-@users.noreply.github.com>2016-12-30 15:59:59 -0300
commitee6d1d02c09941e44ff76ed240770f1102f14267 (patch)
tree2f8e4e1f83bfb7c017c5340e19208d6b1ac3c339 /src
parent07fb65a6f2ae490bd74a53c945b4eb166c2ec953 (diff)
Core/Spell: kill old charge restoring system. Mods are fully handled by proc system now.
- Fixes an edge case of spell failing due to out of range and re-adding charges to an existing aura.
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Player/Player.cpp55
-rw-r--r--src/server/game/Entities/Player/Player.h2
-rw-r--r--src/server/game/Spells/Auras/SpellAuras.cpp8
-rw-r--r--src/server/game/Spells/Auras/SpellAuras.h2
-rw-r--r--src/server/game/Spells/Spell.cpp32
5 files changed, 12 insertions, 87 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 32b026da160..6ff813ca9df 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -20846,61 +20846,6 @@ void Player::AddSpellMod(SpellModifier* mod, bool apply)
m_spellMods[mod->op].erase(mod);
}
-// Restore spellmods in case of failed cast
-void Player::RestoreSpellMods(Spell* spell, uint32 ownerAuraId /*= 0*/, Aura* aura /*= nullptr*/)
-{
- if (!spell || spell->m_appliedMods.empty())
- return;
-
- std::list<Aura*> aurasQueue;
- for (uint8 i = 0; i < MAX_SPELLMOD; ++i)
- {
- for (auto itr = m_spellMods[i].begin(); itr != m_spellMods[i].end(); ++itr)
- {
- SpellModifier* mod = *itr;
-
- // Spellmods without charged aura cannot be charged
- if (!mod->ownerAura->IsUsingCharges())
- continue;
-
- // Restore only specific owner aura mods
- if (ownerAuraId && mod->spellId != ownerAuraId)
- continue;
-
- if (aura && mod->ownerAura != aura)
- continue;
-
- // Check if mod affected this spell
- // First, check if the mod aura applied at least one spellmod to this spell
- Spell::UsedSpellMods::iterator iterMod = spell->m_appliedMods.find(mod->ownerAura);
- if (iterMod == spell->m_appliedMods.end())
- continue;
- // Second, check if the current mod is one of those applied by the mod aura
- if (!(mod->mask & spell->m_spellInfo->SpellFamilyFlags))
- continue;
-
- // remove from list - This will be done after all mods have been gone through
- // to ensure we iterate over all mods of an aura before removing said aura
- // from applied mods (Else, an aura with two mods on the current spell would
- // only see the first of its modifier restored)
- aurasQueue.push_back(mod->ownerAura);
-
- // add charges back to aura
- mod->ownerAura->ModCharges(1);
- }
- }
-
- for (Aura* aura : aurasQueue)
- spell->m_appliedMods.erase(aura);
-}
-
-void Player::RestoreAllSpellMods(uint32 ownerAuraId /*= 0*/, Aura* aura /*= nullptr*/)
-{
- for (uint32 i = 0; i < CURRENT_MAX_SPELL; ++i)
- if (Spell* spell = m_currentSpells[i])
- RestoreSpellMods(spell, ownerAuraId, aura);
-}
-
bool Player::HasSpellModApplied(SpellModifier* mod, Spell* spell)
{
if (!spell)
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index 51bfb112b93..291aa31dce3 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -1607,8 +1607,6 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
static bool IsAffectedBySpellmod(SpellInfo const* spellInfo, SpellModifier* mod, Spell* spell = nullptr);
template <SpellModOp op, class T>
void ApplySpellMod(uint32 spellId, T& basevalue, Spell* spell = nullptr) const;
- void RestoreSpellMods(Spell* spell, uint32 ownerAuraId = 0, Aura* aura = nullptr);
- void RestoreAllSpellMods(uint32 ownerAuraId = 0, Aura* aura = nullptr);
static void ApplyModToSpell(SpellModifier* mod, Spell* spell);
static bool HasSpellModApplied(SpellModifier* mod, Spell* spell);
void SetSpellModTakingSpell(Spell* spell, bool apply);
diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp
index 8973a3efd50..232d96a62aa 100644
--- a/src/server/game/Spells/Auras/SpellAuras.cpp
+++ b/src/server/game/Spells/Auras/SpellAuras.cpp
@@ -902,7 +902,6 @@ bool Aura::ModStackAmount(int32 num, AuraRemoveMode removeMode /*= AURA_REMOVE_B
if (refresh)
{
- RefreshSpellMods();
RefreshTimers(resetPeriodicTimer);
// reset charges
@@ -913,13 +912,6 @@ bool Aura::ModStackAmount(int32 num, AuraRemoveMode removeMode /*= AURA_REMOVE_B
return false;
}
-void Aura::RefreshSpellMods()
-{
- for (Aura::ApplicationMap::const_iterator appIter = m_applications.begin(); appIter != m_applications.end(); ++appIter)
- if (Player* player = appIter->second->GetTarget()->ToPlayer())
- player->RestoreAllSpellMods(0, this);
-}
-
bool Aura::HasMoreThanOneEffectForType(AuraType auraType) const
{
uint32 count = 0;
diff --git a/src/server/game/Spells/Auras/SpellAuras.h b/src/server/game/Spells/Auras/SpellAuras.h
index 9cdf84e82cf..f37f7a96a44 100644
--- a/src/server/game/Spells/Auras/SpellAuras.h
+++ b/src/server/game/Spells/Auras/SpellAuras.h
@@ -148,8 +148,6 @@ class TC_GAME_API Aura
void SetStackAmount(uint8 num);
bool ModStackAmount(int32 num, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT, bool resetPeriodicTimer = true);
- void RefreshSpellMods();
-
uint8 GetCasterLevel() const { return m_casterLevel; }
bool HasMoreThanOneEffectForType(AuraType auraType) const;
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 0071aa23f37..810fd9c8a68 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -2979,13 +2979,10 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered
triggeredByAura->GetBase()->SetDuration(0);
}
+ // cleanup after mod system
+ // triggered spell pointer can be not removed in some cases
if (m_caster->GetTypeId() == TYPEID_PLAYER)
- {
- m_caster->ToPlayer()->RestoreSpellMods(this);
- // cleanup after mod system
- // triggered spell pointer can be not removed in some cases
m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
- }
if (param1 || param2)
SendCastResult(result, &param1, &param2);
@@ -3091,8 +3088,6 @@ void Spell::cancel()
{
case SPELL_STATE_PREPARING:
CancelGlobalCooldown();
- if (m_caster->GetTypeId() == TYPEID_PLAYER)
- m_caster->ToPlayer()->RestoreSpellMods(this);
// no break
case SPELL_STATE_DELAYED:
SendInterrupted(0);
@@ -3187,14 +3182,12 @@ void Spell::cast(bool skipCheck)
{
SendCastResult(castResult, &param1, &param2);
SendInterrupted(0);
- //restore spell mods
+
+ // cleanup after mod system
+ // triggered spell pointer can be not removed in some cases
if (m_caster->GetTypeId() == TYPEID_PLAYER)
- {
- m_caster->ToPlayer()->RestoreSpellMods(this);
- // cleanup after mod system
- // triggered spell pointer can be not removed in some cases
m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
- }
+
finish(false);
SetExecutedCurrently(false);
return;
@@ -3214,10 +3207,11 @@ void Spell::cast(bool skipCheck)
my_trade->SetSpell(m_spellInfo->Id, m_CastItem);
SendCastResult(SPELL_FAILED_DONT_REPORT);
SendInterrupted(0);
- m_caster->ToPlayer()->RestoreSpellMods(this);
+
// cleanup after mod system
// triggered spell pointer can be not removed in some cases
m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
+
finish(false);
SetExecutedCurrently(false);
return;
@@ -3240,14 +3234,12 @@ void Spell::cast(bool skipCheck)
if (m_spellState == SPELL_STATE_FINISHED)
{
SendInterrupted(0);
- //restore spell mods
+
+ // cleanup after mod system
+ // triggered spell pointer can be not removed in some cases
if (m_caster->GetTypeId() == TYPEID_PLAYER)
- {
- m_caster->ToPlayer()->RestoreSpellMods(this);
- // cleanup after mod system
- // triggered spell pointer can be not removed in some cases
m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
- }
+
finish(false);
SetExecutedCurrently(false);
return;