diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Grids/Notifiers/GridNotifiers.cpp | 68 | ||||
-rw-r--r-- | src/server/game/Grids/Notifiers/GridNotifiers.h | 28 | ||||
-rw-r--r-- | src/server/game/Spells/SpellEffects.cpp | 24 |
3 files changed, 118 insertions, 2 deletions
diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.cpp b/src/server/game/Grids/Notifiers/GridNotifiers.cpp index b58ec477e69..4d78dd23d28 100644 --- a/src/server/game/Grids/Notifiers/GridNotifiers.cpp +++ b/src/server/game/Grids/Notifiers/GridNotifiers.cpp @@ -328,6 +328,74 @@ void MessageDistDeliverer::Visit(DynamicObjectMapType &m) } } +void MessageDistDelivererToHostile::Visit(PlayerMapType &m) +{ + for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter) + { + Player* target = iter->GetSource(); + if (!target->InSamePhase(i_phaseMask)) + continue; + + if (target->GetExactDist2dSq(i_source) > i_distSq) + continue; + + // Send packet to all who are sharing the player's vision + if (target->HasSharedVision()) + { + SharedVisionList::const_iterator i = target->GetSharedVisionList().begin(); + for (; i != target->GetSharedVisionList().end(); ++i) + if ((*i)->m_seer == target) + SendPacket(*i); + } + + if (target->m_seer == target || target->GetVehicle()) + SendPacket(target); + } +} + +void MessageDistDelivererToHostile::Visit(CreatureMapType &m) +{ + for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter) + { + Creature* target = iter->GetSource(); + if (!target->InSamePhase(i_phaseMask)) + continue; + + if (target->GetExactDist2dSq(i_source) > i_distSq) + continue; + + // Send packet to all who are sharing the creature's vision + if (target->HasSharedVision()) + { + SharedVisionList::const_iterator i = target->GetSharedVisionList().begin(); + for (; i != target->GetSharedVisionList().end(); ++i) + if ((*i)->m_seer == target) + SendPacket(*i); + } + } +} + +void MessageDistDelivererToHostile::Visit(DynamicObjectMapType &m) +{ + for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter) + { + DynamicObject* target = iter->GetSource(); + if (!target->InSamePhase(i_phaseMask)) + continue; + + if (target->GetExactDist2dSq(i_source) > i_distSq) + continue; + + if (Unit* caster = target->GetCaster()) + { + // Send packet back to the caster if the caster has vision of dynamic object + Player* player = caster->ToPlayer(); + if (player && player->m_seer == target) + SendPacket(player); + } + } +} + /* void MessageDistDeliverer::VisitObject(Player* player) diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h index 9cc533eb27d..1048acff34a 100644 --- a/src/server/game/Grids/Notifiers/GridNotifiers.h +++ b/src/server/game/Grids/Notifiers/GridNotifiers.h @@ -157,6 +157,34 @@ namespace Trinity } }; + struct TC_GAME_API MessageDistDelivererToHostile + { + Unit* i_source; + WorldPacket* i_message; + uint32 i_phaseMask; + float i_distSq; + + MessageDistDelivererToHostile(Unit* src, WorldPacket* msg, float dist) + : i_source(src), i_message(msg), i_phaseMask(src->GetPhaseMask()), i_distSq(dist * dist) + { + } + + void Visit(PlayerMapType &m); + void Visit(CreatureMapType &m); + void Visit(DynamicObjectMapType &m); + template<class SKIP> void Visit(GridRefManager<SKIP> &) { } + + void SendPacket(Player* player) + { + // never send packet to self + if (player == i_source || !player->HaveAtClient(i_source) || player->IsFriendlyTo(i_source)) + return; + + if (WorldSession* session = player->GetSession()) + session->SendPacket(i_message); + } + }; + struct ObjectUpdater { uint32 i_timeDiff; diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index e557501c095..3c7390b54c6 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -46,6 +46,7 @@ #include "Util.h" #include "TemporarySummon.h" #include "GridNotifiers.h" +#include "CellImpl.h" #include "Formulas.h" #include "ScriptMgr.h" #include "SpellHistory.h" @@ -4562,9 +4563,28 @@ void Spell::EffectForceDeselect(SpellEffIndex /*effIndex*/) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT) return; - WorldPacket data(SMSG_CLEAR_TARGET, 8); + float dist = m_caster->GetVisibilityRange(); + + // clear focus + WorldPacket data(SMSG_BREAK_TARGET, m_caster->GetPackGUID().size()); + data << m_caster->GetPackGUID(); + Trinity::MessageDistDelivererToHostile notifierBreak(m_caster, &data, dist); + m_caster->VisitNearbyWorldObject(dist, notifierBreak); + + // and selection + data.Initialize(SMSG_CLEAR_TARGET, 8); data << uint64(m_caster->GetGUID()); - m_caster->SendMessageToSet(&data, true); + Trinity::MessageDistDelivererToHostile notifierClear(m_caster, &data, dist); + m_caster->VisitNearbyWorldObject(dist, notifierClear); + + // we should also force pets to remove us from current target + Unit::AttackerSet attackerSet; + for (Unit::AttackerSet::const_iterator itr = m_caster->getAttackers().begin(); itr != m_caster->getAttackers().end(); ++itr) + if ((*itr)->GetTypeId() == TYPEID_UNIT && !(*itr)->CanHaveThreatList()) + attackerSet.insert(*itr); + + for (Unit::AttackerSet::const_iterator itr = attackerSet.begin(); itr != attackerSet.end(); ++itr) + (*itr)->AttackStop(); } void Spell::EffectSelfResurrect(SpellEffIndex effIndex) |