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

#include "GridNotifiers.h"

Inheritance diagram for Acore::VisibleNotifier:
Acore::PlayerRelocationNotifier

Public Member Functions

 VisibleNotifier (Player &player, bool gobjOnly, bool largeOnly)
 
void Visit (GameObjectMapType &)
 
template<class T >
void Visit (GridRefMgr< T > &m)
 
void SendToSelf (void)
 

Public Attributes

Playeri_player
 
GuidUnorderedSet vis_guids
 
std::vector< Unit * > & i_visibleNow
 
bool i_gobjOnly
 
bool i_largeOnly
 
UpdateData i_data
 

Detailed Description

Constructor & Destructor Documentation

◆ VisibleNotifier()

Acore::VisibleNotifier::VisibleNotifier ( Player player,
bool  gobjOnly,
bool  largeOnly 
)
inline
52 :
53 i_player(player), vis_guids(player.m_clientGUIDs), i_visibleNow(player.m_newVisible), i_gobjOnly(gobjOnly), i_largeOnly(largeOnly)
54 {
55 i_visibleNow.clear();
56 }
GuidUnorderedSet m_clientGUIDs
Definition: Player.h:2363
std::vector< Unit * > m_newVisible
Definition: Player.h:2364
bool i_gobjOnly
Definition: GridNotifiers.h:48
std::vector< Unit * > & i_visibleNow
Definition: GridNotifiers.h:47
bool i_largeOnly
Definition: GridNotifiers.h:49
Player & i_player
Definition: GridNotifiers.h:45
GuidUnorderedSet vis_guids
Definition: GridNotifiers.h:46

References i_visibleNow.

Member Function Documentation

◆ SendToSelf()

void VisibleNotifier::SendToSelf ( void  )
42{
43 // at this moment i_clientGUIDs have guids that not iterate at grid level checks
44 // but exist one case when this possible and object not out of range: transports
45 if (Transport* transport = i_player.GetTransport())
46 for (Transport::PassengerSet::const_iterator itr = transport->GetPassengers().begin(); itr != transport->GetPassengers().end(); ++itr)
47 {
48 if (i_largeOnly != (*itr)->IsVisibilityOverridden())
49 continue;
50
51 if (vis_guids.find((*itr)->GetGUID()) != vis_guids.end())
52 {
53 vis_guids.erase((*itr)->GetGUID());
54
55 switch ((*itr)->GetTypeId())
56 {
58 i_player.UpdateVisibilityOf((*itr)->ToGameObject(), i_data, i_visibleNow);
59 break;
60 case TYPEID_PLAYER:
61 i_player.UpdateVisibilityOf((*itr)->ToPlayer(), i_data, i_visibleNow);
62 (*itr)->ToPlayer()->UpdateVisibilityOf(&i_player);
63 break;
64 case TYPEID_UNIT:
65 i_player.UpdateVisibilityOf((*itr)->ToCreature(), i_data, i_visibleNow);
66 break;
67 default:
68 break;
69 }
70 }
71 }
72
73 for (GuidUnorderedSet::const_iterator it = vis_guids.begin(); it != vis_guids.end(); ++it)
74 {
76 {
77 if (i_largeOnly != obj->IsVisibilityOverridden())
78 continue;
79 }
80
81 // pussywizard: static transports are removed only in RemovePlayerFromMap and here if can no longer detect (eg. phase changed)
82 if ((*it).IsTransport())
83 if (GameObject* staticTrans = i_player.GetMap()->GetGameObject(*it))
84 if (i_player.CanSeeOrDetect(staticTrans, false, true))
85 continue;
86
87 i_player.m_clientGUIDs.erase(*it);
89
90 if ((*it).IsPlayer())
91 {
93 if (player && player->IsInMap(&i_player))
95 }
96 }
97
98 if (!i_data.HasData())
99 return;
100
101 WorldPacket packet;
102 i_data.BuildPacket(packet);
103 i_player.GetSession()->SendPacket(&packet);
104
105 for (std::vector<Unit*>::const_iterator it = i_visibleNow.begin(); it != i_visibleNow.end(); ++it)
106 {
107 if (i_largeOnly != (*it)->IsVisibilityOverridden())
108 continue;
109
111 }
112}
@ TYPEID_GAMEOBJECT
Definition: ObjectGuid.h:37
@ TYPEID_UNIT
Definition: ObjectGuid.h:35
@ TYPEID_PLAYER
Definition: ObjectGuid.h:36
Player * FindPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:248
WorldObject * GetWorldObject(WorldObject const &, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:118
Definition: GameObject.h:121
Definition: Object.h:405
Map * GetMap() const
Definition: Object.h:531
Transport * GetTransport() const
Definition: Object.h:599
bool CanSeeOrDetect(WorldObject const *obj, bool ignoreStealth=false, bool distanceCheck=false, bool checkAlert=false) const
Definition: Object.cpp:1726
bool IsInMap(WorldObject const *obj) const
Definition: Object.cpp:1285
bool HasData() const
Definition: UpdateData.h:60
bool BuildPacket(WorldPacket &packet)
Definition: UpdateData.cpp:48
void AddOutOfRangeGUID(ObjectGuid guid)
Definition: UpdateData.cpp:31
Definition: Player.h:1064
void UpdateVisibilityOf(WorldObject *target)
Definition: PlayerUpdates.cpp:1667
WorldSession * GetSession() const
Definition: Player.h:1980
void GetInitialVisiblePackets(Unit *target)
Definition: PlayerUpdates.cpp:1656
Definition: Transport.h:29
UpdateData i_data
Definition: GridNotifiers.h:50
GameObject * GetGameObject(ObjectGuid const guid)
Definition: Map.cpp:3319
Definition: WorldPacket.h:27
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
Definition: WorldSession.cpp:214

References UpdateData::AddOutOfRangeGUID(), UpdateData::BuildPacket(), WorldObject::CanSeeOrDetect(), ObjectAccessor::FindPlayer(), Map::GetGameObject(), Player::GetInitialVisiblePackets(), WorldObject::GetMap(), Player::GetSession(), WorldObject::GetTransport(), ObjectAccessor::GetWorldObject(), UpdateData::HasData(), i_data, i_largeOnly, i_player, i_visibleNow, WorldObject::IsInMap(), Player::m_clientGUIDs, WorldSession::SendPacket(), TYPEID_GAMEOBJECT, TYPEID_PLAYER, TYPEID_UNIT, Player::UpdateVisibilityOf(), and vis_guids.

Referenced by Unit::ExecuteDelayedUnitRelocationEvent(), and Player::UpdateVisibilityForPlayer().

◆ Visit() [1/2]

void VisibleNotifier::Visit ( GameObjectMapType m)
29{
30 for (GameObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
31 {
32 GameObject* go = iter->GetSource();
34 continue;
35
36 vis_guids.erase(go->GetGUID());
38 }
39}
Definition: LinkedList.h:139
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:109
bool IsVisibilityOverridden() const
Definition: Object.h:577
iterator begin()
Definition: GridRefMgr.h:35
iterator end()
Definition: GridRefMgr.h:36

References GridRefMgr< OBJECT >::begin(), GridRefMgr< OBJECT >::end(), Object::GetGUID(), i_data, i_largeOnly, i_player, i_visibleNow, WorldObject::IsVisibilityOverridden(), Player::UpdateVisibilityOf(), and vis_guids.

Referenced by Acore::PlayerRelocationNotifier::Visit().

◆ Visit() [2/2]

template<class T >
void Acore::VisibleNotifier::Visit ( GridRefMgr< T > &  m)
inline
34{
35 // Xinef: Update gameobjects only
36 if (i_gobjOnly)
37 return;
38
39 for (typename GridRefMgr<T>::iterator iter = m.begin(); iter != m.end(); ++iter)
40 {
41 if (i_largeOnly != iter->GetSource()->IsVisibilityOverridden())
42 continue;
43
44 vis_guids.erase(iter->GetSource()->GetGUID());
46 }
47}

References GridRefMgr< OBJECT >::begin(), GridRefMgr< OBJECT >::end(), i_data, i_gobjOnly, i_largeOnly, i_player, i_visibleNow, Player::UpdateVisibilityOf(), and vis_guids.

Member Data Documentation

◆ i_data

UpdateData Acore::VisibleNotifier::i_data

◆ i_gobjOnly

bool Acore::VisibleNotifier::i_gobjOnly

Referenced by Visit().

◆ i_largeOnly

bool Acore::VisibleNotifier::i_largeOnly

Referenced by SendToSelf(), and Visit().

◆ i_player

Player& Acore::VisibleNotifier::i_player

◆ i_visibleNow

std::vector<Unit*>& Acore::VisibleNotifier::i_visibleNow

◆ vis_guids

GuidUnorderedSet Acore::VisibleNotifier::vis_guids