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

#include <GridNotifiers.h>

Public Member Functions

 VisibleNotifier (Player &player)
 
template<class T >
void Visit (GridRefManager< T > &m)
 
void SendToSelf (void)
 

Public Attributes

Player & i_player
 
UpdateData i_data
 
std::set< Unit * > i_visibleNow
 
GuidUnorderedSet vis_guids
 

Constructor & Destructor Documentation

Trinity::VisibleNotifier::VisibleNotifier ( Player &  player)
inline
50 : i_player(player), i_data(player.GetMapId()), vis_guids(player.m_clientGUIDs) { }
UpdateData i_data
Definition: GridNotifiers.h:46
Player & i_player
Definition: GridNotifiers.h:45
GuidUnorderedSet vis_guids
Definition: GridNotifiers.h:48

Member Function Documentation

void VisibleNotifier::SendToSelf ( void  )
31 {
32  // at this moment i_clientGUIDs have guids that not iterate at grid level checks
33  // but exist one case when this possible and object not out of range: transports
34  if (Transport* transport = i_player.GetTransport())
35  {
36  for (Transport::PassengerSet::const_iterator itr = transport->GetPassengers().begin(); itr != transport->GetPassengers().end(); ++itr)
37  {
38  if (vis_guids.find((*itr)->GetGUID()) != vis_guids.end())
39  {
40  vis_guids.erase((*itr)->GetGUID());
41 
42  switch ((*itr)->GetTypeId())
43  {
44  case TYPEID_GAMEOBJECT:
45  i_player.UpdateVisibilityOf((*itr)->ToGameObject(), i_data, i_visibleNow);
46  break;
47  case TYPEID_PLAYER:
48  i_player.UpdateVisibilityOf((*itr)->ToPlayer(), i_data, i_visibleNow);
49  if (!(*itr)->isNeedNotify(NOTIFY_VISIBILITY_CHANGED))
50  (*itr)->ToPlayer()->UpdateVisibilityOf(&i_player);
51  break;
52  case TYPEID_UNIT:
53  i_player.UpdateVisibilityOf((*itr)->ToCreature(), i_data, i_visibleNow);
54  break;
56  i_player.UpdateVisibilityOf((*itr)->ToDynObject(), i_data, i_visibleNow);
57  break;
58  default:
59  break;
60  }
61  }
62  }
63  }
64 
65  for (auto it = vis_guids.begin(); it != vis_guids.end(); ++it)
66  {
67  i_player.m_clientGUIDs.erase(*it);
69 
70  if (it->IsPlayer())
71  {
72  Player* player = ObjectAccessor::FindPlayer(*it);
73  if (player && !player->isNeedNotify(NOTIFY_VISIBILITY_CHANGED))
74  player->UpdateVisibilityOf(&i_player);
75  }
76  }
77 
78  if (!i_data.HasData())
79  return;
80 
81  WorldPacket packet;
82  i_data.BuildPacket(&packet);
83  i_player.GetSession()->SendPacket(&packet);
84 
85  for (std::set<Unit*>::const_iterator it = i_visibleNow.begin(); it != i_visibleNow.end(); ++it)
86  i_player.SendInitialVisiblePackets(*it);
87 }
Definition: Object.h:74
UpdateData i_data
Definition: GridNotifiers.h:46
Definition: ObjectGuid.h:32
Definition: Transport.h:28
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
Definition: ObjectGuid.h:34
Player & i_player
Definition: GridNotifiers.h:45
Definition: ObjectGuid.h:33
void AddOutOfRangeGUID(GuidSet &guids)
Definition: UpdateData.cpp:27
bool HasData() const
Definition: UpdateData.h:73
std::set< Unit * > i_visibleNow
Definition: GridNotifiers.h:47
GuidUnorderedSet vis_guids
Definition: GridNotifiers.h:48
bool BuildPacket(WorldPacket *packet)
Definition: UpdateData.cpp:43
Definition: ObjectGuid.h:35
Definition: WorldPacket.h:26

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class T >
void Trinity::VisibleNotifier::Visit ( GridRefManager< T > &  m)
inline
33 {
34  for (typename GridRefManager<T>::iterator iter = m.begin(); iter != m.end(); ++iter)
35  {
36  vis_guids.erase(iter->GetSource()->GetGUID());
37  i_player.UpdateVisibilityOf(iter->GetSource(), i_data, i_visibleNow);
38  }
39 }
UpdateData i_data
Definition: GridNotifiers.h:46
Definition: GridReference.h:25
Player & i_player
Definition: GridNotifiers.h:45
iterator begin()
Definition: GridRefManager.h:36
std::set< Unit * > i_visibleNow
Definition: GridNotifiers.h:47
GuidUnorderedSet vis_guids
Definition: GridNotifiers.h:48
iterator end()
Definition: GridRefManager.h:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

UpdateData Trinity::VisibleNotifier::i_data
Player& Trinity::VisibleNotifier::i_player
std::set<Unit*> Trinity::VisibleNotifier::i_visibleNow
GuidUnorderedSet Trinity::VisibleNotifier::vis_guids

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