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:2381
std::vector< Unit * > m_newVisible
Definition: Player.h:2382
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  )
41{
42 // at this moment i_clientGUIDs have guids that not iterate at grid level checks
43 // but exist one case when this possible and object not out of range: transports
44 if (Transport* transport = i_player.GetTransport())
45 for (Transport::PassengerSet::const_iterator itr = transport->GetPassengers().begin(); itr != transport->GetPassengers().end(); ++itr)
46 {
47 if (i_largeOnly != (*itr)->IsVisibilityOverridden())
48 continue;
49
50 if (vis_guids.find((*itr)->GetGUID()) != vis_guids.end())
51 {
52 vis_guids.erase((*itr)->GetGUID());
53
54 switch ((*itr)->GetTypeId())
55 {
57 i_player.UpdateVisibilityOf((*itr)->ToGameObject(), i_data, i_visibleNow);
58 break;
59 case TYPEID_PLAYER:
60 i_player.UpdateVisibilityOf((*itr)->ToPlayer(), i_data, i_visibleNow);
61 (*itr)->ToPlayer()->UpdateVisibilityOf(&i_player);
62 break;
63 case TYPEID_UNIT:
64 i_player.UpdateVisibilityOf((*itr)->ToCreature(), i_data, i_visibleNow);
65 break;
66 default:
67 break;
68 }
69 }
70 }
71
72 for (GuidUnorderedSet::const_iterator it = vis_guids.begin(); it != vis_guids.end(); ++it)
73 {
75 {
76 if (i_largeOnly != obj->IsVisibilityOverridden())
77 continue;
78 }
79
80 // pussywizard: static transports are removed only in RemovePlayerFromMap and here if can no longer detect (eg. phase changed)
81 if ((*it).IsTransport())
82 if (GameObject* staticTrans = i_player.GetMap()->GetGameObject(*it))
83 if (i_player.CanSeeOrDetect(staticTrans, false, true))
84 continue;
85
86 i_player.m_clientGUIDs.erase(*it);
88
89 if ((*it).IsPlayer())
90 {
92 if (player && player->IsInMap(&i_player))
94 }
95 }
96
97 if (!i_data.HasData())
98 return;
99
100 WorldPacket packet;
101 i_data.BuildPacket(packet);
102 i_player.GetSession()->SendPacket(&packet);
103
104 for (std::vector<Unit*>::const_iterator it = i_visibleNow.begin(); it != i_visibleNow.end(); ++it)
105 {
106 if (i_largeOnly != (*it)->IsVisibilityOverridden())
107 continue;
108
110 }
111}
@ 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:245
WorldObject * GetWorldObject(WorldObject const &, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:115
Definition: GameObject.h:120
Definition: Object.h:410
Map * GetMap() const
Definition: Object.h:536
Transport * GetTransport() const
Definition: Object.h:604
bool CanSeeOrDetect(WorldObject const *obj, bool ignoreStealth=false, bool distanceCheck=false, bool checkAlert=false) const
Definition: Object.cpp:1737
bool IsInMap(WorldObject const *obj) const
Definition: Object.cpp:1296
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:1081
void UpdateVisibilityOf(WorldObject *target)
Definition: PlayerUpdates.cpp:1671
WorldSession * GetSession() const
Definition: Player.h:1998
void GetInitialVisiblePackets(Unit *target)
Definition: PlayerUpdates.cpp:1660
Definition: Transport.h:29
UpdateData i_data
Definition: GridNotifiers.h:50
GameObject * GetGameObject(ObjectGuid const guid)
Definition: Map.cpp:3322
Definition: WorldPacket.h:26
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)
28{
29 for (GameObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
30 {
31 GameObject* go = iter->GetSource();
33 continue;
34
35 vis_guids.erase(go->GetGUID());
37 }
38}
Definition: LinkedList.h:139
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:112
bool IsVisibilityOverridden() const
Definition: Object.h:582
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
30{
31 // Xinef: Update gameobjects only
32 if (i_gobjOnly)
33 return;
34
35 for (typename GridRefMgr<T>::iterator iter = m.begin(); iter != m.end(); ++iter)
36 {
37 if (i_largeOnly != iter->GetSource()->IsVisibilityOverridden())
38 continue;
39
40 vis_guids.erase(iter->GetSource()->GetGUID());
42 }
43}

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