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
140 : i_source(src), i_message(msg), i_phaseMask(src->GetPhaseMask()), i_distSq(dist * dist)
141 {
142 }
uint32 GetPhaseMask() const
Definition Object.h:513
uint32 i_phaseMask
Definition GridNotifiers.h:137
float i_distSq
Definition GridNotifiers.h:138
Unit * i_source
Definition GridNotifiers.h:135
WorldPacket * i_message
Definition GridNotifiers.h:136

Member Function Documentation

◆ SendPacket()

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

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

Referenced by Visit(), Visit(), and Visit().

◆ Visit() [1/4]

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

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)
335{
336 for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
337 {
338 DynamicObject* target = iter->GetSource();
339 if (!target->GetCasterGUID().IsPlayer() || !target->InSamePhase(i_phaseMask))
340 continue;
341
342 if (target->GetExactDist2dSq(i_source) > i_distSq)
343 continue;
344
345 // Send packet back to the caster if the caster has vision of dynamic object
346 Player* caster = (Player*)target->GetCaster();
347 if (caster && caster->m_seer == target)
348 SendPacket(caster);
349 }
350}
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:1072
WorldObject * m_seer
Definition Player.h:2345

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
146{}

◆ Visit() [4/4]

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

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(), Visit(), and Visit().

◆ i_message

WorldPacket* Acore::MessageDistDelivererToHostile::i_message

Referenced by SendPacket().

◆ i_phaseMask

uint32 Acore::MessageDistDelivererToHostile::i_phaseMask

Referenced by Visit(), Visit(), and Visit().

◆ i_source

Unit* Acore::MessageDistDelivererToHostile::i_source

Referenced by SendPacket(), Visit(), Visit(), and Visit().


The documentation for this struct was generated from the following files: