AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Acore::MessageDistDelivererToHostile Struct Reference

#include "GridNotifiers.h"

Public Member Functions

 MessageDistDelivererToHostile (Unit *src, WorldPacket *msg, float dist)
 
void Visit (PlayerMapType &m)
 
void Visit (CreatureMapType &m)
 
void Visit (DynamicObjectMapType &m)
 
template<class SKIP >
void Visit (GridRefMgr< SKIP > &)
 
void SendPacket (Player *player)
 

Public Attributes

Uniti_source
 
WorldPacketi_message
 
uint32 i_phaseMask
 
float i_distSq
 

Detailed Description

Constructor & Destructor Documentation

◆ MessageDistDelivererToHostile()

Acore::MessageDistDelivererToHostile::MessageDistDelivererToHostile ( Unit src,
WorldPacket msg,
float  dist 
)
inline
139 : i_source(src), i_message(msg), i_phaseMask(src->GetPhaseMask()), i_distSq(dist * dist)
140 {
141 }
uint32 GetPhaseMask() const
Definition: Object.h:451
uint32 i_phaseMask
Definition: GridNotifiers.h:136
float i_distSq
Definition: GridNotifiers.h:137
Unit * i_source
Definition: GridNotifiers.h:134
WorldPacket * i_message
Definition: GridNotifiers.h:135

Member Function Documentation

◆ SendPacket()

void Acore::MessageDistDelivererToHostile::SendPacket ( Player player)
inline
148 {
149 // never send packet to self
150 if (player == i_source || !player->HaveAtClient(i_source) || player->IsFriendlyTo(i_source))
151 return;
152
153 player->GetSession()->SendPacket(i_message);
154 }
bool HaveAtClient(WorldObject const *u) const
Definition: Player.cpp:11444
WorldSession * GetSession() const
Definition: Player.h:1998
bool IsFriendlyTo(Unit const *unit) const
Definition: Unit.cpp:10241
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
Definition: WorldSession.cpp:214

References Player::GetSession(), Player::HaveAtClient(), i_message, i_source, Unit::IsFriendlyTo(), and WorldSession::SendPacket().

Referenced by Visit().

◆ Visit() [1/4]

void MessageDistDelivererToHostile::Visit ( CreatureMapType m)
321{
322 for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
323 {
324 Creature* target = iter->GetSource();
325 if (!target->HasSharedVision() || !target->InSamePhase(i_phaseMask))
326 continue;
327
328 if (target->GetExactDist2dSq(i_source) > i_distSq)
329 continue;
330
331 // Send packet to all who are sharing the creature's vision
332 SharedVisionList::const_iterator i = target->GetSharedVisionList().begin();
333 for (; i != target->GetSharedVisionList().end(); ++i)
334 if ((*i)->m_seer == target)
335 SendPacket(*i);
336 }
337}
Definition: LinkedList.h:139
Definition: Creature.h:43
bool InSamePhase(WorldObject const *obj) const
Definition: Object.h:452
float GetExactDist2dSq(const float x, const float y) const
Definition: Position.h:156
SharedVisionList const & GetSharedVisionList()
Definition: Unit.h:1737
bool HasSharedVision() const
Definition: Unit.h:1740
iterator begin()
Definition: GridRefMgr.h:35
iterator end()
Definition: GridRefMgr.h:36
void SendPacket(Player *player)
Definition: GridNotifiers.h:147

References GridRefMgr< OBJECT >::begin(), GridRefMgr< OBJECT >::end(), Position::GetExactDist2dSq(), Unit::GetSharedVisionList(), Unit::HasSharedVision(), i_distSq, i_phaseMask, i_source, WorldObject::InSamePhase(), and SendPacket().

◆ Visit() [2/4]

void MessageDistDelivererToHostile::Visit ( DynamicObjectMapType m)
340{
341 for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
342 {
343 DynamicObject* target = iter->GetSource();
344 if (!target->GetCasterGUID().IsPlayer() || !target->InSamePhase(i_phaseMask))
345 continue;
346
347 if (target->GetExactDist2dSq(i_source) > i_distSq)
348 continue;
349
350 // Send packet back to the caster if the caster has vision of dynamic object
351 Player* caster = (Player*)target->GetCaster();
352 if (caster && caster->m_seer == target)
353 SendPacket(caster);
354 }
355}
Definition: DynamicObject.h:35
Unit * GetCaster() const
Definition: DynamicObject.h:55
ObjectGuid GetCasterGUID() const
Definition: DynamicObject.h:59
bool IsPlayer() const
Definition: ObjectGuid.h:168
Definition: Player.h:1081
WorldObject * m_seer
Definition: Player.h:2334

References GridRefMgr< OBJECT >::begin(), GridRefMgr< OBJECT >::end(), DynamicObject::GetCaster(), DynamicObject::GetCasterGUID(), Position::GetExactDist2dSq(), i_distSq, i_phaseMask, i_source, WorldObject::InSamePhase(), ObjectGuid::IsPlayer(), Player::m_seer, and SendPacket().

◆ Visit() [3/4]

template<class SKIP >
void Acore::MessageDistDelivererToHostile::Visit ( GridRefMgr< SKIP > &  )
inline
145{}

◆ Visit() [4/4]

void MessageDistDelivererToHostile::Visit ( PlayerMapType m)
296{
297 for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
298 {
299 Player* target = iter->GetSource();
300 if (!target->InSamePhase(i_phaseMask))
301 continue;
302
303 if (target->GetExactDist2dSq(i_source) > i_distSq)
304 continue;
305
306 // Send packet to all who are sharing the player's vision
307 if (target->HasSharedVision())
308 {
309 SharedVisionList::const_iterator i = target->GetSharedVisionList().begin();
310 for (; i != target->GetSharedVisionList().end(); ++i)
311 if ((*i)->m_seer == target)
312 SendPacket(*i);
313 }
314
315 if (target->m_seer == target || target->GetVehicle())
316 SendPacket(target);
317 }
318}
Vehicle * GetVehicle() const
Definition: Unit.h:1786

References GridRefMgr< OBJECT >::begin(), GridRefMgr< OBJECT >::end(), Position::GetExactDist2dSq(), Unit::GetSharedVisionList(), Unit::GetVehicle(), Unit::HasSharedVision(), i_distSq, i_phaseMask, i_source, WorldObject::InSamePhase(), Player::m_seer, and SendPacket().

Member Data Documentation

◆ i_distSq

float Acore::MessageDistDelivererToHostile::i_distSq

Referenced by Visit().

◆ i_message

WorldPacket* Acore::MessageDistDelivererToHostile::i_message

Referenced by SendPacket().

◆ i_phaseMask

uint32 Acore::MessageDistDelivererToHostile::i_phaseMask

Referenced by Visit().

◆ i_source

Unit* Acore::MessageDistDelivererToHostile::i_source

Referenced by SendPacket(), and Visit().