aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2013-08-15 16:37:18 +0200
committerShauren <shauren.trinity@gmail.com>2013-08-15 16:37:18 +0200
commitc52f9aa3157bddc7dffb67ac03b3bfdf7977c55c (patch)
treecffd68d7f524fa79d8da7fc117c385f6a984d290 /src
parentd1bb6da668c15e6b359c7b1ef0287d1004fcbe58 (diff)
Core/Spells: Refactored SpellInfo::CalcCastTime() to prevent accidental mod charge losses caused by its incorrect usage
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Spells/Spell.cpp22
-rw-r--r--src/server/game/Spells/SpellInfo.cpp6
-rw-r--r--src/server/game/Spells/SpellInfo.h2
3 files changed, 16 insertions, 14 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 82460b7b218..be88179b168 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -3050,18 +3050,20 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered
// Prepare data for triggers
prepareDataForTriggerSystem(triggeredByAura);
- if (m_caster->GetTypeId() == TYPEID_PLAYER)
- m_caster->ToPlayer()->SetSpellModTakingSpell(this, true);
- // calculate cast time (calculated after first CheckCast check to prevent charge counting for first CheckCast fail)
- m_casttime = m_spellInfo->CalcCastTime(m_caster, this);
- if (m_caster->GetTypeId() == TYPEID_PLAYER)
+ if (Player* player = m_caster->ToPlayer())
{
- m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
-
- // Set casttime to 0 if .cheat casttime is enabled.
- if (m_caster->ToPlayer()->GetCommandStatus(CHEAT_CASTTIME))
- m_casttime = 0;
+ if (!m_caster->ToPlayer()->GetCommandStatus(CHEAT_CASTTIME))
+ {
+ m_caster->ToPlayer()->SetSpellModTakingSpell(this, true);
+ // calculate cast time (calculated after first CheckCast check to prevent charge counting for first CheckCast fail)
+ m_casttime = m_spellInfo->CalcCastTime(this);
+ m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
+ }
+ else
+ m_casttime = 0; // Set cast time to 0 if .cheat casttime is enabled.
}
+ else
+ m_casttime = m_spellInfo->CalcCastTime(this);
// don't allow channeled spells / spells with cast time to be casted while moving
// (even if they are interrupted on moving, spells with almost immediate effect get to have their effect processed before movement interrupter kicks in)
diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp
index 3ac1351c135..04437b82f2d 100644
--- a/src/server/game/Spells/SpellInfo.cpp
+++ b/src/server/game/Spells/SpellInfo.cpp
@@ -2057,7 +2057,7 @@ int32 SpellInfo::GetMaxDuration() const
return (DurationEntry->Duration[2] == -1) ? -1 : abs(DurationEntry->Duration[2]);
}
-uint32 SpellInfo::CalcCastTime(Unit* caster, Spell* spell) const
+uint32 SpellInfo::CalcCastTime(Spell* spell /*= NULL*/) const
{
// not all spells have cast time index and this is all is pasiive abilities
if (!CastTimeEntry)
@@ -2065,8 +2065,8 @@ uint32 SpellInfo::CalcCastTime(Unit* caster, Spell* spell) const
int32 castTime = CastTimeEntry->CastTime;
- if (caster)
- caster->ModSpellCastTime(this, castTime, spell);
+ if (spell)
+ spell->GetCaster()->ModSpellCastTime(this, castTime, spell);
if (Attributes & SPELL_ATTR0_REQ_AMMO && (!IsAutoRepeatRangedSpell()))
castTime += 500;
diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h
index 82fa1129429..6acde5afa74 100644
--- a/src/server/game/Spells/SpellInfo.h
+++ b/src/server/game/Spells/SpellInfo.h
@@ -444,7 +444,7 @@ public:
uint32 GetMaxTicks() const;
- uint32 CalcCastTime(Unit* caster = NULL, Spell* spell = NULL) const;
+ uint32 CalcCastTime(Spell* spell = NULL) const;
uint32 GetRecoveryTime() const;
int32 CalcPowerCost(Unit const* caster, SpellSchoolMask schoolMask) const;