aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2011-07-27 12:35:59 +0200
committerShauren <shauren.trinity@gmail.com>2011-07-27 12:35:59 +0200
commitb9a6e2333c86d575a1470c9c65f7612ffd73d478 (patch)
treea42f087bc18c68e1c6ba4c47035bb693effefa13 /src
parentb2a84d9f1edb5bf7df83e05f83ccccbdfca3b7b2 (diff)
Core/Spells: Removed implicit casts from SpellImplicitTargetInfo, fixed copypaste mistakes and one crash
Diffstat (limited to 'src')
-rwxr-xr-xsrc/server/game/AI/CoreAI/UnitAI.cpp2
-rwxr-xr-xsrc/server/game/Conditions/ConditionMgr.cpp40
-rwxr-xr-xsrc/server/game/Entities/GameObject/GameObject.cpp2
-rwxr-xr-xsrc/server/game/Globals/ObjectMgr.cpp4
-rwxr-xr-xsrc/server/game/Scripting/ScriptMgr.cpp50
-rwxr-xr-xsrc/server/game/Server/Protocol/Handlers/PetHandler.cpp2
-rwxr-xr-xsrc/server/game/Spells/Auras/SpellAuras.cpp4
-rwxr-xr-xsrc/server/game/Spells/Spell.cpp70
-rwxr-xr-xsrc/server/game/Spells/SpellEffects.cpp6
-rw-r--r--src/server/game/Spells/SpellInfo.cpp25
-rw-r--r--src/server/game/Spells/SpellInfo.h2
-rwxr-xr-xsrc/server/game/Spells/SpellMgr.cpp6
-rwxr-xr-xsrc/server/game/Spells/SpellScript.cpp2
13 files changed, 110 insertions, 105 deletions
diff --git a/src/server/game/AI/CoreAI/UnitAI.cpp b/src/server/game/AI/CoreAI/UnitAI.cpp
index 88f88e60279..0a89820defd 100755
--- a/src/server/game/AI/CoreAI/UnitAI.cpp
+++ b/src/server/game/AI/CoreAI/UnitAI.cpp
@@ -203,7 +203,7 @@ void UnitAI::FillAISpellInfo()
{
for (uint32 j = 0; j < MAX_SPELL_EFFECTS; ++j)
{
- uint32 targetType = spellInfo->Effects[j].TargetA;
+ uint32 targetType = spellInfo->Effects[j].TargetA.GetTarget();
if (targetType == TARGET_UNIT_TARGET_ENEMY
|| targetType == TARGET_DST_TARGET_ENEMY)
diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp
index aca10df1ebe..4067d5fc7de 100755
--- a/src/server/game/Conditions/ConditionMgr.cpp
+++ b/src/server/game/Conditions/ConditionMgr.cpp
@@ -864,22 +864,22 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
bool targetfound = false;
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
- if (spellProto->Effects[i].TargetA == TARGET_UNIT_AREA_ENTRY_SRC ||
- spellProto->Effects[i].TargetB == TARGET_UNIT_AREA_ENTRY_SRC ||
- spellProto->Effects[i].TargetA == TARGET_UNIT_AREA_ENTRY_DST ||
- spellProto->Effects[i].TargetB == TARGET_UNIT_AREA_ENTRY_DST ||
- spellProto->Effects[i].TargetA == TARGET_UNIT_NEARBY_ENTRY ||
- spellProto->Effects[i].TargetB == TARGET_UNIT_NEARBY_ENTRY ||
- spellProto->Effects[i].TargetA == TARGET_GAMEOBJECT_NEARBY_ENTRY ||
- spellProto->Effects[i].TargetB == TARGET_GAMEOBJECT_NEARBY_ENTRY ||
- spellProto->Effects[i].TargetA == TARGET_GAMEOBJECT_AREA_SRC ||
- spellProto->Effects[i].TargetB == TARGET_GAMEOBJECT_AREA_SRC ||
- spellProto->Effects[i].TargetA == TARGET_GAMEOBJECT_AREA_DST ||
- spellProto->Effects[i].TargetB == TARGET_GAMEOBJECT_AREA_DST ||
- spellProto->Effects[i].TargetA == TARGET_DST_NEARBY_ENTRY ||
- spellProto->Effects[i].TargetB == TARGET_DST_NEARBY_ENTRY ||
- spellProto->Effects[i].TargetA == TARGET_UNIT_CONE_ENTRY ||
- spellProto->Effects[i].TargetB == TARGET_UNIT_CONE_ENTRY)
+ if (spellProto->Effects[i].TargetA.GetTarget() == TARGET_UNIT_AREA_ENTRY_SRC ||
+ spellProto->Effects[i].TargetB.GetTarget() == TARGET_UNIT_AREA_ENTRY_SRC ||
+ spellProto->Effects[i].TargetA.GetTarget() == TARGET_UNIT_AREA_ENTRY_DST ||
+ spellProto->Effects[i].TargetB.GetTarget() == TARGET_UNIT_AREA_ENTRY_DST ||
+ spellProto->Effects[i].TargetA.GetTarget() == TARGET_UNIT_NEARBY_ENTRY ||
+ spellProto->Effects[i].TargetB.GetTarget() == TARGET_UNIT_NEARBY_ENTRY ||
+ spellProto->Effects[i].TargetA.GetTarget() == TARGET_GAMEOBJECT_NEARBY_ENTRY ||
+ spellProto->Effects[i].TargetB.GetTarget() == TARGET_GAMEOBJECT_NEARBY_ENTRY ||
+ spellProto->Effects[i].TargetA.GetTarget() == TARGET_GAMEOBJECT_AREA_SRC ||
+ spellProto->Effects[i].TargetB.GetTarget() == TARGET_GAMEOBJECT_AREA_SRC ||
+ spellProto->Effects[i].TargetA.GetTarget() == TARGET_GAMEOBJECT_AREA_DST ||
+ spellProto->Effects[i].TargetB.GetTarget() == TARGET_GAMEOBJECT_AREA_DST ||
+ spellProto->Effects[i].TargetA.GetTarget() == TARGET_DST_NEARBY_ENTRY ||
+ spellProto->Effects[i].TargetB.GetTarget() == TARGET_DST_NEARBY_ENTRY ||
+ spellProto->Effects[i].TargetA.GetTarget() == TARGET_UNIT_CONE_ENTRY ||
+ spellProto->Effects[i].TargetB.GetTarget() == TARGET_UNIT_CONE_ENTRY)
{
targetfound = true;
//break;
@@ -954,10 +954,10 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
for (int j = 0; j < MAX_SPELL_EFFECTS; ++j)
{
- if (pSpellInfo->Effects[j].TargetA == TARGET_UNIT_TARGET_ENEMY ||
- pSpellInfo->Effects[j].TargetB == TARGET_UNIT_TARGET_ENEMY ||
- pSpellInfo->Effects[j].TargetA == TARGET_UNIT_TARGET_ANY ||
- pSpellInfo->Effects[j].TargetB == TARGET_UNIT_TARGET_ANY)
+ if (pSpellInfo->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_ENEMY ||
+ pSpellInfo->Effects[j].TargetB.GetTarget() == TARGET_UNIT_TARGET_ENEMY ||
+ pSpellInfo->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_ANY ||
+ pSpellInfo->Effects[j].TargetB.GetTarget() == TARGET_UNIT_TARGET_ANY)
{
bIsItemSpellValid = true;
break;
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index 81f738bec27..10e7367bf0b 100755
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -1608,7 +1608,7 @@ void GameObject::CastSpell(Unit* target, uint32 spellId)
bool self = false;
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
- if (spellInfo->Effects[i].TargetA == TARGET_UNIT_CASTER)
+ if (spellInfo->Effects[i].TargetA.GetTarget() == TARGET_UNIT_CASTER)
{
self = true;
break;
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 06200ca9316..4e37508b7d2 100755
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -8259,8 +8259,8 @@ void ObjectMgr::AddSpellToTrainer(uint32 entry, uint32 spell, uint32 spellCost,
if (trainerSpell.learnedSpell[0] == spell)
trainerSpell.learnedSpell[0] = 0;
// player must be able to cast spell on himself
- if (spellinfo->Effects[i].TargetA != 0 && spellinfo->Effects[i].TargetA != TARGET_UNIT_TARGET_ALLY
- && spellinfo->Effects[i].TargetA != TARGET_UNIT_TARGET_ANY && spellinfo->Effects[i].TargetA != TARGET_UNIT_CASTER)
+ if (spellinfo->Effects[i].TargetA.GetTarget() != 0 && spellinfo->Effects[i].TargetA.GetTarget() != TARGET_UNIT_TARGET_ALLY
+ && spellinfo->Effects[i].TargetA.GetTarget() != TARGET_UNIT_TARGET_ANY && spellinfo->Effects[i].TargetA.GetTarget() != TARGET_UNIT_CASTER)
{
sLog->outErrorDb("Table `npc_trainer` has spell %u for trainer entry %u with learn effect which has incorrect target type, ignoring learn effect!", spell, entry);
continue;
diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp
index b7ecb909653..af301738f20 100755
--- a/src/server/game/Scripting/ScriptMgr.cpp
+++ b/src/server/game/Scripting/ScriptMgr.cpp
@@ -227,49 +227,49 @@ void ScriptMgr::FillSpellSummary()
for (uint32 j = 0; j < MAX_SPELL_EFFECTS; ++j)
{
//Spell targets self
- if (pTempSpell->Effects[j].TargetA == TARGET_UNIT_CASTER)
+ if (pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_CASTER)
SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SELF-1);
//Spell targets a single enemy
- if (pTempSpell->Effects[j].TargetA == TARGET_UNIT_TARGET_ENEMY ||
- pTempSpell->Effects[j].TargetA == TARGET_DST_TARGET_ENEMY)
+ if (pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_ENEMY ||
+ pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_DST_TARGET_ENEMY)
SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SINGLE_ENEMY-1);
//Spell targets AoE at enemy
- if (pTempSpell->Effects[j].TargetA == TARGET_UNIT_AREA_ENEMY_SRC ||
- pTempSpell->Effects[j].TargetA == TARGET_UNIT_AREA_ENEMY_DST ||
- pTempSpell->Effects[j].TargetA == TARGET_SRC_CASTER ||
- pTempSpell->Effects[j].TargetA == TARGET_DEST_DYNOBJ_ENEMY)
+ if (pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_AREA_ENEMY_SRC ||
+ pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_AREA_ENEMY_DST ||
+ pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_SRC_CASTER ||
+ pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_DEST_DYNOBJ_ENEMY)
SpellSummary[i].Targets |= 1 << (SELECT_TARGET_AOE_ENEMY-1);
//Spell targets an enemy
- if (pTempSpell->Effects[j].TargetA == TARGET_UNIT_TARGET_ENEMY ||
- pTempSpell->Effects[j].TargetA == TARGET_DST_TARGET_ENEMY ||
- pTempSpell->Effects[j].TargetA == TARGET_UNIT_AREA_ENEMY_SRC ||
- pTempSpell->Effects[j].TargetA == TARGET_UNIT_AREA_ENEMY_DST ||
- pTempSpell->Effects[j].TargetA == TARGET_SRC_CASTER ||
- pTempSpell->Effects[j].TargetA == TARGET_DEST_DYNOBJ_ENEMY)
+ if (pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_ENEMY ||
+ pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_DST_TARGET_ENEMY ||
+ pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_AREA_ENEMY_SRC ||
+ pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_AREA_ENEMY_DST ||
+ pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_SRC_CASTER ||
+ pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_DEST_DYNOBJ_ENEMY)
SpellSummary[i].Targets |= 1 << (SELECT_TARGET_ANY_ENEMY-1);
//Spell targets a single friend(or self)
- if (pTempSpell->Effects[j].TargetA == TARGET_UNIT_CASTER ||
- pTempSpell->Effects[j].TargetA == TARGET_UNIT_TARGET_ALLY ||
- pTempSpell->Effects[j].TargetA == TARGET_UNIT_TARGET_PARTY)
+ if (pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_CASTER ||
+ pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_ALLY ||
+ pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_PARTY)
SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SINGLE_FRIEND-1);
//Spell targets aoe friends
- if (pTempSpell->Effects[j].TargetA == TARGET_UNIT_PARTY_CASTER ||
- pTempSpell->Effects[j].TargetA == TARGET_UNIT_TARGET_ALLY_PARTY ||
- pTempSpell->Effects[j].TargetA == TARGET_SRC_CASTER)
+ if (pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_PARTY_CASTER ||
+ pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_ALLY_PARTY ||
+ pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_SRC_CASTER)
SpellSummary[i].Targets |= 1 << (SELECT_TARGET_AOE_FRIEND-1);
//Spell targets any friend(or self)
- if (pTempSpell->Effects[j].TargetA == TARGET_UNIT_CASTER ||
- pTempSpell->Effects[j].TargetA == TARGET_UNIT_TARGET_ALLY ||
- pTempSpell->Effects[j].TargetA == TARGET_UNIT_TARGET_PARTY ||
- pTempSpell->Effects[j].TargetA == TARGET_UNIT_PARTY_CASTER ||
- pTempSpell->Effects[j].TargetA == TARGET_UNIT_TARGET_ALLY_PARTY ||
- pTempSpell->Effects[j].TargetA == TARGET_SRC_CASTER)
+ if (pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_CASTER ||
+ pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_ALLY ||
+ pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_PARTY ||
+ pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_PARTY_CASTER ||
+ pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_ALLY_PARTY ||
+ pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_SRC_CASTER)
SpellSummary[i].Targets |= 1 << (SELECT_TARGET_ANY_FRIEND-1);
//Make sure that this spell includes a damage effect
diff --git a/src/server/game/Server/Protocol/Handlers/PetHandler.cpp b/src/server/game/Server/Protocol/Handlers/PetHandler.cpp
index a00aaf312ce..48ddba2694c 100755
--- a/src/server/game/Server/Protocol/Handlers/PetHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/PetHandler.cpp
@@ -302,7 +302,7 @@ void WorldSession::HandlePetActionHelper(Unit *pet, uint64 guid1, uint16 spellid
for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
- if (spellInfo->Effects[i].TargetA == TARGET_UNIT_AREA_ENEMY_SRC || spellInfo->Effects[i].TargetA == TARGET_UNIT_AREA_ENEMY_DST || spellInfo->Effects[i].TargetA == TARGET_DEST_DYNOBJ_ENEMY)
+ if (spellInfo->Effects[i].TargetA.GetTarget() == TARGET_UNIT_AREA_ENEMY_SRC || spellInfo->Effects[i].TargetA.GetTarget() == TARGET_UNIT_AREA_ENEMY_DST || spellInfo->Effects[i].TargetA.GetTarget() == TARGET_DEST_DYNOBJ_ENEMY)
return;
}
diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp
index b8012a32458..0d0c6c4e86e 100755
--- a/src/server/game/Spells/Auras/SpellAuras.cpp
+++ b/src/server/game/Spells/Auras/SpellAuras.cpp
@@ -2384,8 +2384,8 @@ void DynObjAura::FillTargetMap(std::map<Unit *, uint8> & targets, Unit* /*caster
if (!HasEffect(effIndex))
continue;
UnitList targetList;
- if (GetSpellInfo()->Effects[effIndex].TargetB == TARGET_DEST_DYNOBJ_ALLY
- || GetSpellInfo()->Effects[effIndex].TargetB == TARGET_UNIT_AREA_ALLY_DST)
+ if (GetSpellInfo()->Effects[effIndex].TargetB.GetTarget() == TARGET_DEST_DYNOBJ_ALLY
+ || GetSpellInfo()->Effects[effIndex].TargetB.GetTarget() == TARGET_UNIT_AREA_ALLY_DST)
{
Trinity::AnyFriendlyUnitInObjectRangeCheck u_check(GetDynobjOwner(), dynObjOwnerCaster, radius);
Trinity::UnitListSearcher<Trinity::AnyFriendlyUnitInObjectRangeCheck> searcher(GetDynobjOwner(), targetList, u_check);
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index b4a98e06bd1..628ec1a0f16 100755
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -614,8 +614,8 @@ void Spell::SelectSpellTargets()
if (effectTargetType == SPELL_REQUIRE_NONE)
continue;
- uint32 targetA = m_spellInfo->Effects[i].TargetA;
- uint32 targetB = m_spellInfo->Effects[i].TargetA;
+ uint32 targetA = m_spellInfo->Effects[i].TargetA.GetTarget();
+ uint32 targetB = m_spellInfo->Effects[i].TargetB.GetTarget();
if (targetA)
SelectEffectTargets(i, m_spellInfo->Effects[i].TargetA);
@@ -1974,7 +1974,7 @@ void Spell::SelectEffectTargets(uint32 i, SpellImplicitTargetInfo const& cur)
{
case TARGET_TYPE_UNIT_CASTER:
{
- switch(cur)
+ switch(cur.GetTarget())
{
case TARGET_UNIT_CASTER:
AddUnitTarget(m_caster, i);
@@ -2019,7 +2019,7 @@ void Spell::SelectEffectTargets(uint32 i, SpellImplicitTargetInfo const& cur)
case TARGET_UNIT_PASSENGER_6:
case TARGET_UNIT_PASSENGER_7:
if (m_caster->GetTypeId() == TYPEID_UNIT && m_caster->ToCreature()->IsVehicle())
- if (Unit *unit = m_caster->GetVehicleKit()->GetPassenger(cur - TARGET_UNIT_PASSENGER_0))
+ if (Unit *unit = m_caster->GetVehicleKit()->GetPassenger(cur.GetTarget() - TARGET_UNIT_PASSENGER_0))
AddUnitTarget(unit, i);
break;
default:
@@ -2037,7 +2037,7 @@ void Spell::SelectEffectTargets(uint32 i, SpellImplicitTargetInfo const& cur)
break;
}
- switch(cur)
+ switch(cur.GetTarget())
{
case TARGET_UNIT_TARGET_ENEMY:
if (Unit *magnet = m_caster->SelectMagnetTarget(target, m_spellInfo))
@@ -2083,7 +2083,7 @@ void Spell::SelectEffectTargets(uint32 i, SpellImplicitTargetInfo const& cur)
WorldObject *target = NULL;
float range;
- switch(cur)
+ switch(cur.GetTarget())
{
case TARGET_UNIT_NEARBY_ENEMY:
range = m_spellInfo->GetMaxRange(false);
@@ -2141,12 +2141,12 @@ void Spell::SelectEffectTargets(uint32 i, SpellImplicitTargetInfo const& cur)
case TARGET_TYPE_DEST_CASTER: //4+8+2
{
- if (cur == TARGET_SRC_CASTER)
+ if (cur.GetTarget() == TARGET_SRC_CASTER)
{
m_targets.SetSrc(*m_caster);
break;
}
- else if (cur == TARGET_DST_CASTER)
+ else if (cur.GetTarget() == TARGET_DST_CASTER)
{
m_targets.SetDst(*m_caster);
break;
@@ -2155,17 +2155,17 @@ void Spell::SelectEffectTargets(uint32 i, SpellImplicitTargetInfo const& cur)
float angle, dist;
float objSize = m_caster->GetObjectSize();
- if (cur == TARGET_MINION)
+ if (cur.GetTarget() == TARGET_MINION)
dist = 0.0f;
else
dist = m_spellInfo->Effects[i].CalcRadius(m_caster);
if (modOwner) modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RADIUS, dist, this);
if (dist < objSize)
dist = objSize;
- else if (cur == TARGET_DEST_CASTER_RANDOM)
+ else if (cur.GetTarget() == TARGET_DEST_CASTER_RANDOM)
dist = objSize + (dist - objSize) * (float)rand_norm();
- switch(cur)
+ switch(cur.GetTarget())
{
case TARGET_DEST_CASTER_FRONT_LEFT: angle = static_cast<float>(-M_PI/4); break;
case TARGET_DEST_CASTER_BACK_LEFT: angle = static_cast<float>(-3*M_PI/4); break;
@@ -2181,7 +2181,7 @@ void Spell::SelectEffectTargets(uint32 i, SpellImplicitTargetInfo const& cur)
}
Position pos;
- if (cur == TARGET_DEST_CASTER_FRONT_LEAP)
+ if (cur.GetTarget() == TARGET_DEST_CASTER_FRONT_LEAP)
m_caster->GetFirstCollisionPosition(pos, dist, angle);
else
m_caster->GetNearPosition(pos, dist, angle);
@@ -2199,7 +2199,7 @@ void Spell::SelectEffectTargets(uint32 i, SpellImplicitTargetInfo const& cur)
break;
}
- if (cur == TARGET_DST_TARGET_ENEMY || cur == TARGET_DEST_TARGET_ANY)
+ if (cur.GetTarget() == TARGET_DST_TARGET_ENEMY || cur.GetTarget() == TARGET_DEST_TARGET_ANY)
{
m_targets.SetDst(*target);
break;
@@ -2211,10 +2211,10 @@ void Spell::SelectEffectTargets(uint32 i, SpellImplicitTargetInfo const& cur)
dist = m_spellInfo->Effects[i].CalcRadius(m_caster);
if (dist < objSize)
dist = objSize;
- else if (cur == TARGET_DEST_TARGET_RANDOM)
+ else if (cur.GetTarget() == TARGET_DEST_TARGET_RANDOM)
dist = objSize + (dist - objSize) * (float)rand_norm();
- switch(cur)
+ switch(cur.GetTarget())
{
case TARGET_DEST_TARGET_FRONT: angle = 0.0f; break;
case TARGET_DEST_TARGET_BACK: angle = static_cast<float>(M_PI); break;
@@ -2243,7 +2243,7 @@ void Spell::SelectEffectTargets(uint32 i, SpellImplicitTargetInfo const& cur)
}
float angle;
- switch(cur)
+ switch(cur.GetTarget())
{
case TARGET_DEST_DYNOBJ_ENEMY:
case TARGET_DEST_DYNOBJ_ALLY:
@@ -2265,7 +2265,7 @@ void Spell::SelectEffectTargets(uint32 i, SpellImplicitTargetInfo const& cur)
}
float dist = m_spellInfo->Effects[i].CalcRadius(m_caster);
- if (cur == TARGET_DEST_DEST_RANDOM || cur == TARGET_DEST_DEST_RANDOM_DIR_DIST)
+ if (cur.GetTarget() == TARGET_DEST_DEST_RANDOM || cur.GetTarget() == TARGET_DEST_DEST_RANDOM_DIR_DIST)
dist *= (float)rand_norm();
// must has dst, no need to set flag
@@ -2277,7 +2277,7 @@ void Spell::SelectEffectTargets(uint32 i, SpellImplicitTargetInfo const& cur)
case TARGET_TYPE_DEST_SPECIAL:
{
- switch(cur)
+ switch(cur.GetTarget())
{
case TARGET_DST_DB:
if (SpellTargetPosition const* st = sSpellMgr->GetSpellTargetPosition(m_spellInfo->Id))
@@ -2324,7 +2324,7 @@ void Spell::SelectEffectTargets(uint32 i, SpellImplicitTargetInfo const& cur)
break;
}
- switch (cur)
+ switch (cur.GetTarget())
{
case TARGET_UNIT_CHANNEL_TARGET:
// unit target may be no longer avalible - teleported out of map for example
@@ -2352,7 +2352,7 @@ void Spell::SelectEffectTargets(uint32 i, SpellImplicitTargetInfo const& cur)
default:
{
- switch (cur)
+ switch (cur.GetTarget())
{
case TARGET_GAMEOBJECT:
if (m_targets.GetGOTarget())
@@ -2396,7 +2396,7 @@ void Spell::SelectEffectTargets(uint32 i, SpellImplicitTargetInfo const& cur)
float range;
std::list<Unit*> unitList;
- switch (cur)
+ switch (cur.GetTarget())
{
case TARGET_UNIT_NEARBY_ENEMY:
case TARGET_UNIT_TARGET_ENEMY:
@@ -2433,7 +2433,7 @@ void Spell::SelectEffectTargets(uint32 i, SpellImplicitTargetInfo const& cur)
float radius;
SpellTargets targetType;
- switch(cur)
+ switch(cur.GetTarget())
{
case TARGET_UNIT_AREA_ENEMY_SRC:
case TARGET_UNIT_AREA_ENEMY_DST:
@@ -2601,7 +2601,7 @@ void Spell::SelectEffectTargets(uint32 i, SpellImplicitTargetInfo const& cur)
SearchAreaTarget(unitList, radius, pushType, targetType);
break;
default:
- switch (cur)
+ switch (cur.GetTarget())
{
case TARGET_UNIT_AREA_PARTY_SRC:
case TARGET_UNIT_AREA_PARTY_DST:
@@ -4791,7 +4791,7 @@ SpellCastResult Spell::CheckCast(bool strict)
// If 0 spell effect empty - client not send target data (need use selection)
// TODO: check it on next client version
if (m_targets.GetTargetMask() == TARGET_FLAG_SELF &&
- m_spellInfo->Effects[1].TargetA == TARGET_UNIT_TARGET_ENEMY)
+ m_spellInfo->Effects[1].TargetA.GetTarget() == TARGET_UNIT_TARGET_ENEMY)
{
target = m_caster->GetUnit(*m_caster, m_caster->ToPlayer()->GetSelection());
if (target)
@@ -4809,7 +4809,7 @@ SpellCastResult Spell::CheckCast(bool strict)
// check pet presents
for (int j = 0; j < MAX_SPELL_EFFECTS; ++j)
{
- if (m_spellInfo->Effects[j].TargetA == TARGET_UNIT_PET)
+ if (m_spellInfo->Effects[j].TargetA.GetTarget() == TARGET_UNIT_PET)
{
target = m_caster->GetGuardianPet();
if (!target)
@@ -4980,7 +4980,7 @@ SpellCastResult Spell::CheckCast(bool strict)
if (m_caster->GetTypeId() != TYPEID_PLAYER)
return SPELL_FAILED_BAD_TARGETS;
- if (m_spellInfo->Effects[i].TargetA != TARGET_UNIT_PET)
+ if (m_spellInfo->Effects[i].TargetA.GetTarget() != TARGET_UNIT_PET)
break;
Pet* pet = m_caster->ToPlayer()->GetPet();
@@ -5102,13 +5102,13 @@ SpellCastResult Spell::CheckCast(bool strict)
}
case SPELL_EFFECT_OPEN_LOCK:
{
- if (m_spellInfo->Effects[i].TargetA != TARGET_GAMEOBJECT &&
- m_spellInfo->Effects[i].TargetA != TARGET_GAMEOBJECT_ITEM)
+ if (m_spellInfo->Effects[i].TargetA.GetTarget() != TARGET_GAMEOBJECT &&
+ m_spellInfo->Effects[i].TargetA.GetTarget() != TARGET_GAMEOBJECT_ITEM)
break;
if (m_caster->GetTypeId() != TYPEID_PLAYER // only players can open locks, gather etc.
// we need a go target in case of TARGET_GAMEOBJECT
- || (m_spellInfo->Effects[i].TargetA == TARGET_GAMEOBJECT && !m_targets.GetGOTarget()))
+ || (m_spellInfo->Effects[i].TargetA.GetTarget() == TARGET_GAMEOBJECT && !m_targets.GetGOTarget()))
return SPELL_FAILED_BAD_TARGETS;
Item *pTempItem = NULL;
@@ -5121,7 +5121,7 @@ SpellCastResult Spell::CheckCast(bool strict)
pTempItem = m_caster->ToPlayer()->GetItemByGuid(m_targets.GetItemTargetGUID());
// we need a go target, or an openable item target in case of TARGET_GAMEOBJECT_ITEM
- if (m_spellInfo->Effects[i].TargetA == TARGET_GAMEOBJECT_ITEM &&
+ if (m_spellInfo->Effects[i].TargetA.GetTarget() == TARGET_GAMEOBJECT_ITEM &&
!m_targets.GetGOTarget() &&
(!pTempItem || !pTempItem->GetTemplate()->LockID || !pTempItem->IsLocked()))
return SPELL_FAILED_BAD_TARGETS;
@@ -5829,7 +5829,7 @@ SpellCastResult Spell::CheckItems()
for (int i = 0; i < MAX_SPELL_EFFECTS; i++)
{
// skip check, pet not required like checks, and for TARGET_UNIT_PET m_targets.GetUnitTarget() is not the real target but the caster
- if (m_spellInfo->Effects[i].TargetA == TARGET_UNIT_PET)
+ if (m_spellInfo->Effects[i].TargetA.GetTarget() == TARGET_UNIT_PET)
continue;
if (m_spellInfo->Effects[i].Effect == SPELL_EFFECT_HEAL)
@@ -6447,7 +6447,7 @@ CurrentSpellTypes Spell::GetCurrentContainer()
bool Spell::CheckTarget(Unit* target, uint32 eff)
{
// Check targets for creature type mask and remove not appropriate (skip explicit self target case, maybe need other explicit targets)
- if (m_spellInfo->Effects[eff].TargetA != TARGET_UNIT_CASTER)
+ if (m_spellInfo->Effects[eff].TargetA.GetTarget() != TARGET_UNIT_CASTER)
{
if (!CheckTargetCreatureType(target))
return false;
@@ -6561,7 +6561,7 @@ bool Spell::IsNextMeleeSwingSpell() const
return m_spellInfo->Attributes & SPELL_ATTR0_ON_NEXT_SWING;
}
-bool Spell::IsAutoActionResetSpell() const
+bool Spell::IsAutoActionResetSpell() const
{
return !m_IsTriggeredSpell && (m_spellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_AUTOATTACK);
}
@@ -6740,7 +6740,7 @@ bool Spell::IsValidSingleTargetSpell(Unit const* target) const
}
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
- if (!IsValidSingleTargetEffect(target, m_spellInfo->Effects[i].TargetA))
+ if (!IsValidSingleTargetEffect(target, m_spellInfo->Effects[i].TargetA.GetTarget()))
return false;
// Need to check B?
//if (!IsValidSingleTargetEffect(m_spellInfo->Effects[i].TargetB, target)
@@ -6924,7 +6924,7 @@ SpellCastResult Spell::CanOpenLock(uint32 effIndex, uint32 lockId, SkillType& sk
// skill bonus provided by casting spell (mostly item spells)
// add the damage modifier from the spell casted (cheat lock / skeleton key etc.)
- if (m_spellInfo->Effects[effIndex].TargetA == TARGET_GAMEOBJECT_ITEM || m_spellInfo->Effects[effIndex].TargetB == TARGET_GAMEOBJECT_ITEM)
+ if (m_spellInfo->Effects[effIndex].TargetA.GetTarget() == TARGET_GAMEOBJECT_ITEM || m_spellInfo->Effects[effIndex].TargetB.GetTarget() == TARGET_GAMEOBJECT_ITEM)
skillValue += uint32(CalculateDamage(effIndex, NULL));
if (skillValue < reqSkillValue)
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 491e6db5394..7564699c256 100755
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -1865,7 +1865,7 @@ void Spell::EffectJumpDest(SpellEffIndex effIndex)
{
m_targets.GetDst()->GetPosition(x, y, z);
- if (m_spellInfo->Effects[effIndex].TargetA == TARGET_DEST_TARGET_BACK)
+ if (m_spellInfo->Effects[effIndex].TargetA.GetTarget() == TARGET_DEST_TARGET_BACK)
{
// explicit cast data from client or server-side cast
// some spell at client send caster
@@ -6872,7 +6872,7 @@ void Spell::GetSummonPosition(uint32 i, Position &pos, float radius, uint32 coun
else
{
//This is a workaround. Do not have time to write much about it
- switch (m_spellInfo->Effects[i].TargetA)
+ switch (m_spellInfo->Effects[i].TargetA.GetTarget())
{
case TARGET_MINION:
case TARGET_DEST_CASTER_RANDOM:
@@ -7044,7 +7044,7 @@ void Spell::EffectBind(SpellEffIndex effIndex)
uint32 area_id;
WorldLocation loc;
- if (m_spellInfo->Effects[effIndex].TargetA == TARGET_DST_DB || m_spellInfo->Effects[effIndex].TargetB == TARGET_DST_DB)
+ if (m_spellInfo->Effects[effIndex].TargetA.GetTarget() == TARGET_DST_DB || m_spellInfo->Effects[effIndex].TargetB.GetTarget() == TARGET_DST_DB)
{
SpellTargetPosition const* st = sSpellMgr->GetSpellTargetPosition(m_spellInfo->Id);
if (!st)
diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp
index a5afe382fe6..c59492c9ec3 100644
--- a/src/server/game/Spells/SpellInfo.cpp
+++ b/src/server/game/Spells/SpellInfo.cpp
@@ -34,6 +34,12 @@ SpellSelectTargetTypes SpellImplicitTargetInfo::GetType() const
return Type[_target];
}
+
+Targets SpellImplicitTargetInfo::GetTarget() const
+{
+ return _target;
+}
+
bool SpellImplicitTargetInfo::IsPosition(uint32 targetType)
{
switch (SpellImplicitTargetInfo::Type[targetType])
@@ -48,11 +54,6 @@ bool SpellImplicitTargetInfo::IsPosition(uint32 targetType)
return false;
}
-SpellImplicitTargetInfo::operator Targets() const
-{
- return _target;
-}
-
bool SpellImplicitTargetInfo::InitStaticData()
{
InitAreaData();
@@ -395,9 +396,13 @@ bool SpellEffectInfo::HasRadius() const
float SpellEffectInfo::CalcRadius(Unit* caster, Spell* spell) const
{
+ if (!HasRadius())
+ return 0.0f;
+
float radius = RadiusEntry->radiusMax;
if (Player* modOwner = (caster ? caster->GetSpellModOwner() : NULL))
modOwner->ApplySpellMod(_spellInfo->Id, SPELLMOD_RADIUS, radius, spell);
+
return radius;
}
@@ -1619,7 +1624,7 @@ SpellInfo const* SpellInfo::GetAuraRankForLevel(uint8 level) const
bool needRankSelection = false;
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
- if (IsPositiveEffect(i) &&
+ if (IsPositiveEffect(i) &&
(Effects[i].Effect == SPELL_EFFECT_APPLY_AURA ||
Effects[i].Effect == SPELL_EFFECT_APPLY_AREA_AURA_PARTY ||
Effects[i].Effect == SPELL_EFFECT_APPLY_AREA_AURA_RAID))
@@ -1801,7 +1806,7 @@ bool SpellInfo::_IsPositiveEffect(uint8 effIndex, bool deep) const
continue;
// if non-positive trigger cast targeted to positive target this main cast is non-positive
// this will place this spell auras as debuffs
- if (_IsPositiveTarget(spellTriggeredProto->Effects[i].TargetA, spellTriggeredProto->Effects[effIndex].TargetB) && !spellTriggeredProto->_IsPositiveEffect(i, true))
+ if (_IsPositiveTarget(spellTriggeredProto->Effects[i].TargetA.GetTarget(), spellTriggeredProto->Effects[effIndex].TargetB.GetTarget()) && !spellTriggeredProto->_IsPositiveEffect(i, true))
return false;
}
}
@@ -1827,12 +1832,12 @@ bool SpellInfo::_IsPositiveEffect(uint8 effIndex, bool deep) const
return false;
case SPELL_AURA_PERIODIC_DAMAGE: // used in positive spells also.
// part of negative spell if casted at self (prevent cancel)
- if (Effects[effIndex].TargetA == TARGET_UNIT_CASTER)
+ if (Effects[effIndex].TargetA.GetTarget() == TARGET_UNIT_CASTER)
return false;
break;
case SPELL_AURA_MOD_DECREASE_SPEED: // used in positive spells also
// part of positive spell if casted at self
- if (Effects[effIndex].TargetA != TARGET_UNIT_CASTER)
+ if (Effects[effIndex].TargetA.GetTarget() != TARGET_UNIT_CASTER)
return false;
// but not this if this first effect (didn't find better check)
if (Attributes & SPELL_ATTR0_NEGATIVE_1 && effIndex == 0)
@@ -1894,7 +1899,7 @@ bool SpellInfo::_IsPositiveEffect(uint8 effIndex, bool deep) const
}
// non-positive targets
- if (!_IsPositiveTarget(Effects[effIndex].TargetA, Effects[effIndex].TargetB))
+ if (!_IsPositiveTarget(Effects[effIndex].TargetA.GetTarget(), Effects[effIndex].TargetB.GetTarget()))
return false;
// negative spell if triggered spell is negative
diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h
index 178246495cd..9cf75b06d3b 100644
--- a/src/server/game/Spells/SpellInfo.h
+++ b/src/server/game/Spells/SpellInfo.h
@@ -120,7 +120,7 @@ public:
bool IsArea() const;
SpellSelectTargetTypes GetType() const;
- operator Targets() const;
+ Targets GetTarget() const;
// temporarily avalible to public
static bool IsPosition(uint32 targetType);
diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp
index a14d53eb667..bf101345336 100755
--- a/src/server/game/Spells/SpellMgr.cpp
+++ b/src/server/game/Spells/SpellMgr.cpp
@@ -1379,7 +1379,7 @@ void SpellMgr::LoadSpellLearnSpells()
// talent or passive spells or skill-step spells auto-casted and not need dependent learning,
// pet teaching spells must not be dependent learning (casted)
// other required explicit dependent learning
- dbc_node.autoLearned = entry->Effects[i].TargetA == TARGET_UNIT_PET || GetTalentSpellCost(spell) > 0 || entry->IsPassive() || entry->HasEffect(SPELL_EFFECT_SKILL_STEP);
+ dbc_node.autoLearned = entry->Effects[i].TargetA.GetTarget() == TARGET_UNIT_PET || GetTalentSpellCost(spell) > 0 || entry->IsPassive() || entry->HasEffect(SPELL_EFFECT_SKILL_STEP);
SpellLearnSpellMapBounds db_node_bounds = GetSpellLearnSpellMapBounds(spell);
@@ -1462,7 +1462,7 @@ void SpellMgr::LoadSpellTargetPositions()
bool found = false;
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
- if (spellInfo->Effects[i].TargetA == TARGET_DST_DB || spellInfo->Effects[i].TargetB == TARGET_DST_DB)
+ if (spellInfo->Effects[i].TargetA.GetTarget() == TARGET_DST_DB || spellInfo->Effects[i].TargetB.GetTarget() == TARGET_DST_DB)
{
// additional requirements
if (spellInfo->Effects[i].Effect == SPELL_EFFECT_BIND && spellInfo->Effects[i].MiscValue)
@@ -2019,7 +2019,7 @@ void SpellMgr::LoadSpellPetAuras()
continue;
}
- PetAura pa(pet, aura, spellInfo->Effects[eff].TargetA == TARGET_UNIT_PET, spellInfo->Effects[eff].CalcValue());
+ PetAura pa(pet, aura, spellInfo->Effects[eff].TargetA.GetTarget() == TARGET_UNIT_PET, spellInfo->Effects[eff].CalcValue());
mSpellPetAuraMap[(spell<<8) + eff] = pa;
}
diff --git a/src/server/game/Spells/SpellScript.cpp b/src/server/game/Spells/SpellScript.cpp
index 2edf040223a..fb4d9afb9ad 100755
--- a/src/server/game/Spells/SpellScript.cpp
+++ b/src/server/game/Spells/SpellScript.cpp
@@ -205,7 +205,7 @@ bool SpellScript::UnitTargetHandler::CheckEffect(SpellInfo const* spellEntry, ui
{
if (!targetType)
return false;
- return (effIndex == EFFECT_ALL) || (spellEntry->Effects[effIndex].TargetA == targetType || spellEntry->Effects[effIndex].TargetB == targetType);
+ return (effIndex == EFFECT_ALL) || (spellEntry->Effects[effIndex].TargetA.GetTarget() == targetType || spellEntry->Effects[effIndex].TargetB.GetTarget() == targetType);
}
void SpellScript::UnitTargetHandler::Call(SpellScript* spellScript, std::list<Unit*>& unitTargets)