diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 51 | ||||
-rw-r--r-- | src/server/game/Spells/SpellDefines.h | 8 | ||||
-rw-r--r-- | src/server/game/Spells/SpellInfo.h | 1 | ||||
-rw-r--r-- | src/server/game/Spells/SpellMgr.cpp | 21 | ||||
-rw-r--r-- | src/server/game/Spells/SpellMgr.h | 9 |
5 files changed, 23 insertions, 67 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 1383391ff8d..4092d0db626 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -71,40 +71,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 1aa105b07a6..70a89a855d4 100644 --- a/src/server/game/Spells/SpellDefines.h +++ b/src/server/game/Spells/SpellDefines.h @@ -322,10 +322,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 3692d5a53bb..35d7e8cafb1 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 d343e1e37be..2ad4ed4d5ea 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -1291,21 +1291,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; @@ -1325,14 +1320,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 20ed878b465..c9eaf65ce06 100644 --- a/src/server/game/Spells/SpellMgr.h +++ b/src/server/game/Spells/SpellMgr.h @@ -406,14 +406,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; |