TrinityCore
Loading...
Searching...
No Matches
ObjectAccessor Namespace Reference

Functions

TC_GAME_API WorldObjectGetWorldObject (WorldObject const &, ObjectGuid const &)
 
TC_GAME_API ObjectGetObjectByTypeMask (WorldObject const &, ObjectGuid const &, uint32 typemask)
 
TC_GAME_API CorpseGetCorpse (WorldObject const &u, ObjectGuid const &guid)
 
TC_GAME_API GameObjectGetGameObject (WorldObject const &u, ObjectGuid const &guid)
 
TC_GAME_API TransportGetTransport (WorldObject const &u, ObjectGuid const &guid)
 
TC_GAME_API DynamicObjectGetDynamicObject (WorldObject const &u, ObjectGuid const &guid)
 
TC_GAME_API AreaTriggerGetAreaTrigger (WorldObject const &u, ObjectGuid const &guid)
 
TC_GAME_API SceneObjectGetSceneObject (WorldObject const &u, ObjectGuid const &guid)
 
TC_GAME_API ConversationGetConversation (WorldObject const &u, ObjectGuid const &guid)
 
TC_GAME_API UnitGetUnit (WorldObject const &, ObjectGuid const &guid)
 
TC_GAME_API CreatureGetCreature (WorldObject const &u, ObjectGuid const &guid)
 
TC_GAME_API PetGetPet (WorldObject const &, ObjectGuid const &guid)
 
TC_GAME_API PlayerGetPlayer (Map const *, ObjectGuid const &guid)
 
TC_GAME_API PlayerGetPlayer (WorldObject const &, ObjectGuid const &guid)
 
TC_GAME_API CreatureGetCreatureOrPetOrVehicle (WorldObject const &, ObjectGuid const &)
 
TC_GAME_API PlayerFindPlayer (ObjectGuid const &)
 
TC_GAME_API PlayerFindPlayerByName (std::string_view name)
 
TC_GAME_API PlayerFindPlayerByLowGUID (ObjectGuid::LowType lowguid)
 
TC_GAME_API PlayerFindConnectedPlayer (ObjectGuid const &)
 
TC_GAME_API PlayerFindConnectedPlayerByName (std::string_view name)
 
TC_GAME_API HashMapHolder< Player >::MapType const & GetPlayers ()
 
template<class T >
void AddObject (T *object)
 
template<class T >
void RemoveObject (T *object)
 
template<>
void AddObject (Player *player)
 
template<>
void RemoveObject (Player *player)
 
TC_GAME_API void SaveAllPlayers ()
 

Function Documentation

◆ AddObject() [1/2]

template<>
void ObjectAccessor::AddObject ( Player player)

Definition at line 298 of file ObjectAccessor.cpp.

299{
302}
static void Insert(T *o)
void Insert(Player *p)
+ Here is the call graph for this function:

◆ AddObject() [2/2]

template<class T >
void ObjectAccessor::AddObject ( T *  object)

Definition at line 94 of file ObjectAccessor.h.

95 {
97 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FindConnectedPlayer()

Player * ObjectAccessor::FindConnectedPlayer ( ObjectGuid const &  guid)

Definition at line 273 of file ObjectAccessor.cpp.

274{
275 return HashMapHolder<Player>::Find(guid);
276}
static T * Find(ObjectGuid guid)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FindConnectedPlayerByName()

Player * ObjectAccessor::FindConnectedPlayerByName ( std::string_view  name)

Definition at line 278 of file ObjectAccessor.cpp.

279{
280 return PlayerNameMapHolder::Find(name);
281}
Player * Find(std::string_view name)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FindPlayer()

Player * ObjectAccessor::FindPlayer ( ObjectGuid const &  guid)

Definition at line 252 of file ObjectAccessor.cpp.

253{
254 Player* player = HashMapHolder<Player>::Find(guid);
255 return player && player->IsInWorld() ? player : nullptr;
256}
bool IsInWorld() const
Definition: Object.h:153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FindPlayerByLowGUID()

Player * ObjectAccessor::FindPlayerByLowGUID ( ObjectGuid::LowType  lowguid)

Definition at line 267 of file ObjectAccessor.cpp.

268{
269 ObjectGuid guid = ObjectGuid::Create<HighGuid::Player>(lowguid);
270 return ObjectAccessor::FindPlayer(guid);
271}
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FindPlayerByName()

Player * ObjectAccessor::FindPlayerByName ( std::string_view  name)

Definition at line 258 of file ObjectAccessor.cpp.

259{
260 Player* player = PlayerNameMapHolder::Find(name);
261 if (!player || !player->IsInWorld())
262 return nullptr;
263
264 return player;
265}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetAreaTrigger()

AreaTrigger * ObjectAccessor::GetAreaTrigger ( WorldObject const &  u,
ObjectGuid const &  guid 
)

Definition at line 191 of file ObjectAccessor.cpp.

192{
193 return u.GetMap()->GetAreaTrigger(guid);
194}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetConversation()

Conversation * ObjectAccessor::GetConversation ( WorldObject const &  u,
ObjectGuid const &  guid 
)

Definition at line 201 of file ObjectAccessor.cpp.

202{
203 return u.GetMap()->GetConversation(guid);
204}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetCorpse()

Corpse * ObjectAccessor::GetCorpse ( WorldObject const &  u,
ObjectGuid const &  guid 
)

Definition at line 171 of file ObjectAccessor.cpp.

172{
173 return u.GetMap()->GetCorpse(guid);
174}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetCreature()

Creature * ObjectAccessor::GetCreature ( WorldObject const &  u,
ObjectGuid const &  guid 
)

Definition at line 217 of file ObjectAccessor.cpp.

218{
219 return u.GetMap()->GetCreature(guid);
220}
+ Here is the call graph for this function:

◆ GetCreatureOrPetOrVehicle()

Creature * ObjectAccessor::GetCreatureOrPetOrVehicle ( WorldObject const &  u,
ObjectGuid const &  guid 
)

Definition at line 241 of file ObjectAccessor.cpp.

242{
243 if (guid.IsPet())
244 return GetPet(u, guid);
245
246 if (guid.IsCreatureOrVehicle())
247 return GetCreature(u, guid);
248
249 return nullptr;
250}
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
TC_GAME_API Pet * GetPet(WorldObject const &, ObjectGuid const &guid)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetDynamicObject()

DynamicObject * ObjectAccessor::GetDynamicObject ( WorldObject const &  u,
ObjectGuid const &  guid 
)

Definition at line 186 of file ObjectAccessor.cpp.

187{
188 return u.GetMap()->GetDynamicObject(guid);
189}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetGameObject()

GameObject * ObjectAccessor::GetGameObject ( WorldObject const &  u,
ObjectGuid const &  guid 
)

Definition at line 176 of file ObjectAccessor.cpp.

177{
178 return u.GetMap()->GetGameObject(guid);
179}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetObjectByTypeMask()

Object * ObjectAccessor::GetObjectByTypeMask ( WorldObject const &  p,
ObjectGuid const &  guid,
uint32  typemask 
)

Definition at line 120 of file ObjectAccessor.cpp.

121{
122 switch (guid.GetHigh())
123 {
124 case HighGuid::Item:
125 if (typemask & TYPEMASK_ITEM && p.GetTypeId() == TYPEID_PLAYER)
126 return ((Player const&)p).GetItemByGuid(guid);
127 break;
128 case HighGuid::Player:
129 if (typemask & TYPEMASK_PLAYER)
130 return GetPlayer(p, guid);
131 break;
134 if (typemask & TYPEMASK_GAMEOBJECT)
135 return GetGameObject(p, guid);
136 break;
139 if (typemask & TYPEMASK_UNIT)
140 return GetCreature(p, guid);
141 break;
142 case HighGuid::Pet:
143 if (typemask & TYPEMASK_UNIT)
144 return GetPet(p, guid);
145 break;
147 if (typemask & TYPEMASK_DYNAMICOBJECT)
148 return GetDynamicObject(p, guid);
149 break;
151 if (typemask & TYPEMASK_AREATRIGGER)
152 return GetAreaTrigger(p, guid);
153 break;
155 if (typemask & TYPEMASK_SCENEOBJECT)
156 return GetSceneObject(p, guid);
157 break;
159 if (typemask & TYPEMASK_CONVERSATION)
160 return GetConversation(p, guid);
161 break;
162 case HighGuid::Corpse:
163 break;
164 default:
165 break;
166 }
167
168 return nullptr;
169}
@ TYPEID_PLAYER
Definition: ObjectGuid.h:41
@ TYPEMASK_ITEM
Definition: ObjectGuid.h:56
@ TYPEMASK_SCENEOBJECT
Definition: ObjectGuid.h:67
@ TYPEMASK_DYNAMICOBJECT
Definition: ObjectGuid.h:64
@ TYPEMASK_UNIT
Definition: ObjectGuid.h:60
@ TYPEMASK_CONVERSATION
Definition: ObjectGuid.h:68
@ TYPEMASK_GAMEOBJECT
Definition: ObjectGuid.h:63
@ TYPEMASK_PLAYER
Definition: ObjectGuid.h:61
@ TYPEMASK_AREATRIGGER
Definition: ObjectGuid.h:66
TC_GAME_API GameObject * GetGameObject(WorldObject const &u, ObjectGuid const &guid)
TC_GAME_API AreaTrigger * GetAreaTrigger(WorldObject const &u, ObjectGuid const &guid)
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
TC_GAME_API DynamicObject * GetDynamicObject(WorldObject const &u, ObjectGuid const &guid)
TC_GAME_API Conversation * GetConversation(WorldObject const &u, ObjectGuid const &guid)
TC_GAME_API SceneObject * GetSceneObject(WorldObject const &u, ObjectGuid const &guid)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetPet()

Pet * ObjectAccessor::GetPet ( WorldObject const &  u,
ObjectGuid const &  guid 
)

Definition at line 222 of file ObjectAccessor.cpp.

223{
224 return u.GetMap()->GetPet(guid);
225}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetPlayer() [1/2]

Player * ObjectAccessor::GetPlayer ( Map const *  m,
ObjectGuid const &  guid 
)

Definition at line 227 of file ObjectAccessor.cpp.

228{
229 if (Player* player = HashMapHolder<Player>::Find(guid))
230 if (player->IsInWorld() && player->GetMap() == m)
231 return player;
232
233 return nullptr;
234}
+ Here is the caller graph for this function:

◆ GetPlayer() [2/2]

Player * ObjectAccessor::GetPlayer ( WorldObject const &  u,
ObjectGuid const &  guid 
)

Definition at line 236 of file ObjectAccessor.cpp.

237{
238 return GetPlayer(u.GetMap(), guid);
239}
+ Here is the call graph for this function:

◆ GetPlayers()

HashMapHolder< Player >::MapType const & ObjectAccessor::GetPlayers ( )

Definition at line 283 of file ObjectAccessor.cpp.

284{
286}
static MapType & GetContainer()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetSceneObject()

SceneObject * ObjectAccessor::GetSceneObject ( WorldObject const &  u,
ObjectGuid const &  guid 
)

Definition at line 196 of file ObjectAccessor.cpp.

197{
198 return u.GetMap()->GetSceneObject(guid);
199}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetTransport()

Transport * ObjectAccessor::GetTransport ( WorldObject const &  u,
ObjectGuid const &  guid 
)

Definition at line 181 of file ObjectAccessor.cpp.

182{
183 return u.GetMap()->GetTransport(guid);
184}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetUnit()

Unit * ObjectAccessor::GetUnit ( WorldObject const &  u,
ObjectGuid const &  guid 
)

Definition at line 206 of file ObjectAccessor.cpp.

207{
208 if (guid.IsPlayer())
209 return GetPlayer(u, guid);
210
211 if (guid.IsPet())
212 return GetPet(u, guid);
213
214 return GetCreature(u, guid);
215}
+ Here is the call graph for this function:

◆ GetWorldObject()

WorldObject * ObjectAccessor::GetWorldObject ( WorldObject const &  p,
ObjectGuid const &  guid 
)

Definition at line 101 of file ObjectAccessor.cpp.

102{
103 switch (guid.GetHigh())
104 {
105 case HighGuid::Player: return GetPlayer(p, guid);
107 case HighGuid::GameObject: return GetGameObject(p, guid);
109 case HighGuid::Creature: return GetCreature(p, guid);
110 case HighGuid::Pet: return GetPet(p, guid);
111 case HighGuid::DynamicObject: return GetDynamicObject(p, guid);
112 case HighGuid::AreaTrigger: return GetAreaTrigger(p, guid);
113 case HighGuid::Corpse: return GetCorpse(p, guid);
114 case HighGuid::SceneObject: return GetSceneObject(p, guid);
115 case HighGuid::Conversation: return GetConversation(p, guid);
116 default: return nullptr;
117 }
118}
TC_GAME_API Corpse * GetCorpse(WorldObject const &u, ObjectGuid const &guid)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RemoveObject() [1/2]

template<>
void ObjectAccessor::RemoveObject ( Player player)

Definition at line 305 of file ObjectAccessor.cpp.

306{
309}
static void Remove(T *o)
void Remove(Player *p)
+ Here is the call graph for this function:

◆ RemoveObject() [2/2]

template<class T >
void ObjectAccessor::RemoveObject ( T *  object)

Definition at line 100 of file ObjectAccessor.h.

101 {
103 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SaveAllPlayers()

void ObjectAccessor::SaveAllPlayers ( )

Definition at line 288 of file ObjectAccessor.cpp.

289{
290 std::shared_lock<std::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
291
293 for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
294 itr->second->SaveToDB();
295}
std::unordered_map< ObjectGuid, T * > MapType
TC_GAME_API HashMapHolder< Player >::MapType const & GetPlayers()
+ Here is the call graph for this function:
+ Here is the caller graph for this function: