TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Trinity::MessageDistDeliverer Struct Reference

#include <GridNotifiers.h>

Public Member Functions

 MessageDistDeliverer (WorldObject *src, WorldPacket const *msg, float dist, bool own_team_only=false, Player const *skipped=NULL)
 
void Visit (PlayerMapType &m)
 
void Visit (CreatureMapType &m)
 
void Visit (DynamicObjectMapType &m)
 
template<class SKIP >
void Visit (GridRefManager< SKIP > &)
 
void SendPacket (Player *player)
 

Public Attributes

WorldObjecti_source
 
WorldPacket consti_message
 
float i_distSq
 
uint32 team
 
Player constskipped_receiver
 

Constructor & Destructor Documentation

Trinity::MessageDistDeliverer::MessageDistDeliverer ( WorldObject src,
WorldPacket const msg,
float  dist,
bool  own_team_only = false,
Player const skipped = NULL 
)
inline
134  : i_source(src), i_message(msg), i_distSq(dist * dist)
135  , team(0)
136  , skipped_receiver(skipped)
137  {
138  if (own_team_only)
139  if (Player* player = src->ToPlayer())
140  team = player->GetTeam();
141  }
uint32 team
Definition: GridNotifiers.h:131
Player * ToPlayer()
Definition: Object.h:191
WorldPacket const * i_message
Definition: GridNotifiers.h:129
WorldObject * i_source
Definition: GridNotifiers.h:128
float i_distSq
Definition: GridNotifiers.h:130
Player const * skipped_receiver
Definition: GridNotifiers.h:132

+ Here is the call graph for this function:

Member Function Documentation

void Trinity::MessageDistDeliverer::SendPacket ( Player *  player)
inline
149  {
150  // never send packet to self
151  if (player == i_source || (team && player->GetTeam() != team) || skipped_receiver == player)
152  return;
153 
154  if (!player->HaveAtClient(i_source))
155  return;
156 
157  if (WorldSession* session = player->GetSession())
158  session->SendPacket(i_message);
159  }
uint32 team
Definition: GridNotifiers.h:131
WorldPacket const * i_message
Definition: GridNotifiers.h:129
WorldObject * i_source
Definition: GridNotifiers.h:128
Player session in the World.
Definition: WorldSession.h:882
Player const * skipped_receiver
Definition: GridNotifiers.h:132

+ Here is the caller graph for this function:

void MessageDistDeliverer::Visit ( PlayerMapType m)
264 {
265  for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
266  {
267  Player* target = iter->GetSource();
268  if (!target->IsInPhase(i_source))
269  continue;
270 
271  if (target->GetExactDist2dSq(i_source) > i_distSq)
272  continue;
273 
274  // Send packet to all who are sharing the player's vision
275  if (target->HasSharedVision())
276  {
277  SharedVisionList::const_iterator i = target->GetSharedVisionList().begin();
278  for (; i != target->GetSharedVisionList().end(); ++i)
279  if ((*i)->m_seer == target)
280  SendPacket(*i);
281  }
282 
283  if (target->m_seer == target || target->GetVehicle())
284  SendPacket(target);
285  }
286 }
void SendPacket(Player *player)
Definition: GridNotifiers.h:148
Definition: LinkedList.h:141
iterator begin()
Definition: GridRefManager.h:36
WorldObject * i_source
Definition: GridNotifiers.h:128
float i_distSq
Definition: GridNotifiers.h:130
iterator end()
Definition: GridRefManager.h:37

+ Here is the call graph for this function:

void MessageDistDeliverer::Visit ( CreatureMapType m)
289 {
290  for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
291  {
292  Creature* target = iter->GetSource();
293  if (!target->IsInPhase(i_source))
294  continue;
295 
296  if (target->GetExactDist2dSq(i_source) > i_distSq)
297  continue;
298 
299  // Send packet to all who are sharing the creature's vision
300  if (target->HasSharedVision())
301  {
302  SharedVisionList::const_iterator i = target->GetSharedVisionList().begin();
303  for (; i != target->GetSharedVisionList().end(); ++i)
304  if ((*i)->m_seer == target)
305  SendPacket(*i);
306  }
307  }
308 }
float GetExactDist2dSq(float x, float y) const
Definition: Position.h:132
SharedVisionList const & GetSharedVisionList()
Definition: Unit.h:1754
Definition: Creature.h:467
void SendPacket(Player *player)
Definition: GridNotifiers.h:148
Definition: LinkedList.h:141
bool IsInPhase(uint32 phase) const
Definition: Object.h:462
iterator begin()
Definition: GridRefManager.h:36
WorldObject * i_source
Definition: GridNotifiers.h:128
float i_distSq
Definition: GridNotifiers.h:130
iterator end()
Definition: GridRefManager.h:37
bool HasSharedVision() const
Definition: Unit.h:1757

+ Here is the call graph for this function:

void MessageDistDeliverer::Visit ( DynamicObjectMapType m)
311 {
312  for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
313  {
314  DynamicObject* target = iter->GetSource();
315  if (!target->IsInPhase(i_source))
316  continue;
317 
318  if (target->GetExactDist2dSq(i_source) > i_distSq)
319  continue;
320 
321  if (Unit* caster = target->GetCaster())
322  {
323  // Send packet back to the caster if the caster has vision of dynamic object
324  Player* player = caster->ToPlayer();
325  if (player && player->m_seer == target)
326  SendPacket(player);
327  }
328  }
329 }
float GetExactDist2dSq(float x, float y) const
Definition: Position.h:132
Definition: DynamicObject.h:35
void SendPacket(Player *player)
Definition: GridNotifiers.h:148
Definition: LinkedList.h:141
bool IsInPhase(uint32 phase) const
Definition: Object.h:462
iterator begin()
Definition: GridRefManager.h:36
WorldObject * i_source
Definition: GridNotifiers.h:128
float i_distSq
Definition: GridNotifiers.h:130
iterator end()
Definition: GridRefManager.h:37
Unit * GetCaster() const
Definition: DynamicObject.h:54
Definition: Unit.h:1305

+ Here is the call graph for this function:

template<class SKIP >
void Trinity::MessageDistDeliverer::Visit ( GridRefManager< SKIP > &  )
inline
146 { }

Member Data Documentation

float Trinity::MessageDistDeliverer::i_distSq
WorldPacket const* Trinity::MessageDistDeliverer::i_message
WorldObject* Trinity::MessageDistDeliverer::i_source
Player const* Trinity::MessageDistDeliverer::skipped_receiver
uint32 Trinity::MessageDistDeliverer::team

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