aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2025-01-20 19:27:44 +0100
committerShauren <shauren.trinity@gmail.com>2025-01-20 19:27:44 +0100
commit0e36fd93601f10949c848c1fc30ee3b70f2cecfa (patch)
tree16b7dec2365367ae30e7017e04bbf02612f00aa2 /src/server
parent56fb627c7dd151190412468370db083ef3b044ad (diff)
Core/Spells: Replace SpellTargetPosition structure with WorldLocation
Diffstat (limited to 'src/server')
-rw-r--r--src/server/game/Spells/Spell.cpp51
-rw-r--r--src/server/game/Spells/SpellDefines.h8
-rw-r--r--src/server/game/Spells/SpellInfo.h1
-rw-r--r--src/server/game/Spells/SpellMgr.cpp21
-rw-r--r--src/server/game/Spells/SpellMgr.h9
5 files changed, 23 insertions, 67 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index b0f0d11cff5..956c8049f51 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -73,40 +73,9 @@
extern NonDefaultConstructible<SpellEffectHandlerFn> SpellEffectHandlers[TOTAL_SPELL_EFFECTS];
-SpellDestination::SpellDestination()
+SpellDestination::SpellDestination(WorldObject const& wObj) : _position(wObj.GetMapId(), wObj),
+ _transportGUID(wObj.GetTransGUID()), _transportOffset(wObj.GetTransOffset())
{
- _position.Relocate(0, 0, 0, 0);
- _transportGUID.Clear();
- _transportOffset.Relocate(0, 0, 0, 0);
-}
-
-SpellDestination::SpellDestination(float x, float y, float z, float orientation, uint32 mapId)
-{
- _position.Relocate(x, y, z, orientation);
- _transportGUID.Clear();
- _position.m_mapId = mapId;
- _transportOffset.Relocate(0, 0, 0, 0);
-}
-
-SpellDestination::SpellDestination(Position const& pos)
-{
- _position.Relocate(pos);
- _transportGUID.Clear();
- _transportOffset.Relocate(0, 0, 0, 0);
-}
-
-SpellDestination::SpellDestination(WorldLocation const& loc)
-{
- _position.WorldRelocate(loc);
- _transportGUID.Clear();
- _transportOffset.Relocate(0, 0, 0, 0);
-}
-
-SpellDestination::SpellDestination(WorldObject const& wObj)
-{
- _transportGUID = wObj.GetTransGUID();
- _transportOffset.Relocate(wObj.GetTransOffsetX(), wObj.GetTransOffsetY(), wObj.GetTransOffsetZ(), wObj.GetTransOffsetO());
- _position.Relocate(wObj);
}
void SpellDestination::Relocate(Position const& pos)
@@ -1178,8 +1147,8 @@ void Spell::SelectImplicitNearbyTargets(SpellEffectInfo const& spellEffectInfo,
if (SpellTargetPosition const* st = sSpellMgr->GetSpellTargetPosition(m_spellInfo->Id, spellEffectInfo.EffectIndex))
{
SpellDestination dest(*m_caster);
- if (st->target_mapId == m_caster->GetMapId() && m_caster->IsInDist(st->target_X, st->target_Y, st->target_Z, range))
- dest = SpellDestination(st->target_X, st->target_Y, st->target_Z, st->target_Orientation);
+ if (st->GetMapId() == m_caster->GetMapId() && m_caster->IsInDist(st, range))
+ dest = st->GetPosition();
else
{
float randomRadius = spellEffectInfo.CalcRadius(m_caster, targetIndex);
@@ -1503,16 +1472,16 @@ void Spell::SelectImplicitCasterDestTargets(SpellEffectInfo const& spellEffectIn
if (SpellTargetPosition const* st = sSpellMgr->GetSpellTargetPosition(m_spellInfo->Id, spellEffectInfo.EffectIndex))
{
/// @todo fix this check
- if (m_spellInfo->HasEffect(SPELL_EFFECT_TELEPORT_UNITS) || m_spellInfo->HasEffect(SPELL_EFFECT_TELEPORT_WITH_SPELL_VISUAL_KIT_LOADING_SCREEN) || m_spellInfo->HasEffect(SPELL_EFFECT_BIND))
- dest = SpellDestination(st->target_X, st->target_Y, st->target_Z, st->target_Orientation, (int32)st->target_mapId);
- else if (st->target_mapId == m_caster->GetMapId())
- dest = SpellDestination(st->target_X, st->target_Y, st->target_Z, st->target_Orientation);
+ if (spellEffectInfo.IsEffect(SPELL_EFFECT_TELEPORT_UNITS) || spellEffectInfo.IsEffect(SPELL_EFFECT_TELEPORT_WITH_SPELL_VISUAL_KIT_LOADING_SCREEN) || spellEffectInfo.IsEffect(SPELL_EFFECT_BIND))
+ dest = *st;
+ else if (st->GetMapId() == m_caster->GetMapId())
+ dest = st->GetPosition();
}
else
{
TC_LOG_DEBUG("spells", "SPELL: unknown target coordinates for spell ID {}", m_spellInfo->Id);
if (WorldObject* target = m_targets.GetObjectTarget())
- dest = SpellDestination(*target);
+ dest = *target;
}
break;
case TARGET_DEST_CASTER_FISHING:
@@ -1630,7 +1599,7 @@ void Spell::SelectImplicitCasterDestTargets(SpellEffectInfo const& spellEffectIn
case TARGET_DEST_CASTER_FRONT_RIGHT:
case TARGET_DEST_CASTER_BACK_RIGHT:
{
- static float const DefaultTotemDistance = 3.0f;
+ constexpr float DefaultTotemDistance = 3.0f;
if (!spellEffectInfo.HasRadius(targetIndex))
dist = DefaultTotemDistance;
break;
diff --git a/src/server/game/Spells/SpellDefines.h b/src/server/game/Spells/SpellDefines.h
index 9bb1b1277fc..120f2fa68c1 100644
--- a/src/server/game/Spells/SpellDefines.h
+++ b/src/server/game/Spells/SpellDefines.h
@@ -328,10 +328,10 @@ enum SpellCastTargetFlags : uint32
struct TC_GAME_API SpellDestination
{
- SpellDestination();
- SpellDestination(float x, float y, float z, float orientation = 0.0f, uint32 mapId = MAPID_INVALID);
- SpellDestination(Position const& pos);
- SpellDestination(WorldLocation const& loc);
+ SpellDestination() { }
+ SpellDestination(float x, float y, float z, float orientation = 0.0f, uint32 mapId = MAPID_INVALID) : _position(mapId, x, y, z, orientation) { }
+ SpellDestination(Position const& pos) : _position(MAPID_INVALID, pos) { }
+ SpellDestination(WorldLocation const& loc) : _position(loc) { }
SpellDestination(WorldObject const& wObj);
void Relocate(Position const& pos);
diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h
index 8ecbd0b7ca5..f49727dc800 100644
--- a/src/server/game/Spells/SpellInfo.h
+++ b/src/server/game/Spells/SpellInfo.h
@@ -36,7 +36,6 @@ class WorldObject;
struct Condition;
struct SpellChainNode;
struct SpellModifier;
-struct SpellTargetPosition;
enum WeaponAttackType : uint8;
enum SpellTargetSelectionCategories
diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp
index cf6734b2df4..dc7c9d35cc3 100644
--- a/src/server/game/Spells/SpellMgr.cpp
+++ b/src/server/game/Spells/SpellMgr.cpp
@@ -1173,21 +1173,16 @@ void SpellMgr::LoadSpellTargetPositions()
uint32 spellId = fields[0].GetUInt32();
SpellEffIndex effIndex = SpellEffIndex(fields[1].GetUInt8());
- SpellTargetPosition st;
+ SpellTargetPosition st(fields[2].GetUInt16(), fields[3].GetFloat(), fields[4].GetFloat(), fields[5].GetFloat());
- st.target_mapId = fields[2].GetUInt16();
- st.target_X = fields[3].GetFloat();
- st.target_Y = fields[4].GetFloat();
- st.target_Z = fields[5].GetFloat();
-
- MapEntry const* mapEntry = sMapStore.LookupEntry(st.target_mapId);
+ MapEntry const* mapEntry = sMapStore.LookupEntry(st.GetMapId());
if (!mapEntry)
{
- TC_LOG_ERROR("sql.sql", "Spell (Id: {}, EffectIndex: {}) is using a non-existant MapID (ID: {}).", spellId, uint32(effIndex), st.target_mapId);
+ TC_LOG_ERROR("sql.sql", "Spell (Id: {}, EffectIndex: {}) is using a non-existant MapID (ID: {}).", spellId, uint32(effIndex), st.GetMapId());
continue;
}
- if (st.target_X == 0 && st.target_Y == 0 && st.target_Z == 0)
+ if (st.GetPositionX() == 0 && st.GetPositionY() == 0 && st.GetPositionZ() == 0)
{
TC_LOG_ERROR("sql.sql", "Spell (Id: {}, EffectIndex: {}): target coordinates not provided.", spellId, uint32(effIndex));
continue;
@@ -1207,14 +1202,14 @@ void SpellMgr::LoadSpellTargetPositions()
}
if (!fields[6].IsNull())
- st.target_Orientation = fields[6].GetFloat();
+ st.SetOrientation(fields[6].GetFloat());
else
{
- // target facing is in degrees for 6484 & 9268... (blizz sucks)
+ // target facing is in degrees for 6484 & 9268...
if (spellInfo->GetEffect(effIndex).PositionFacing > 2 * float(M_PI))
- st.target_Orientation = spellInfo->GetEffect(effIndex).PositionFacing * float(M_PI) / 180;
+ st.SetOrientation(spellInfo->GetEffect(effIndex).PositionFacing * float(M_PI) / 180);
else
- st.target_Orientation = spellInfo->GetEffect(effIndex).PositionFacing;
+ st.SetOrientation(spellInfo->GetEffect(effIndex).PositionFacing);
}
auto hasTarget = [&](Targets target)
diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h
index 26c7e565cc8..9dd886a4fde 100644
--- a/src/server/game/Spells/SpellMgr.h
+++ b/src/server/game/Spells/SpellMgr.h
@@ -407,14 +407,7 @@ struct SpellThreatEntry
typedef std::unordered_map<uint32, SpellThreatEntry> SpellThreatMap;
// coordinates for spells (accessed using SpellMgr functions)
-struct SpellTargetPosition
-{
- uint32 target_mapId;
- float target_X;
- float target_Y;
- float target_Z;
- float target_Orientation;
-};
+using SpellTargetPosition = WorldLocation;
typedef std::map<std::pair<uint32 /*spell_id*/, SpellEffIndex /*effIndex*/>, SpellTargetPosition> SpellTargetPositionMap;