TrinityCore
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<class T >
void ObjectAccessor::AddObject ( T *  object)
95  {
97  }
static void Insert(T *o)
Definition: ObjectAccessor.cpp:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddObject() [2/2]

template<>
void ObjectAccessor::AddObject ( Player player)
299 {
302 }
static void Insert(T *o)
Definition: ObjectAccessor.cpp:32
void Insert(Player *p)
Definition: ObjectAccessor.cpp:80
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FindConnectedPlayer()

Player * ObjectAccessor::FindConnectedPlayer ( ObjectGuid const &  guid)
274 {
275  return HashMapHolder<Player>::Find(guid);
276 }
static T * Find(ObjectGuid guid)
Definition: ObjectAccessor.cpp:51
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FindConnectedPlayerByName()

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

◆ FindPlayer()

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

◆ FindPlayerByLowGUID()

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

◆ FindPlayerByName()

Player * ObjectAccessor::FindPlayerByName ( std::string_view  name)
259 {
260  Player* player = PlayerNameMapHolder::Find(name);
261  if (!player || !player->IsInWorld())
262  return nullptr;
263 
264  return player;
265 }
Player * Find(std::string_view name)
Definition: ObjectAccessor.cpp:90
bool IsInWorld() const
Definition: Object.h:151
Definition: Player.h:1131
+ 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 
)
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 
)
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 
)
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 
)
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 
)
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 Pet * GetPet(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:222
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:217
+ 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 
)
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 
)
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 
)
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;
132  case HighGuid::Transport:
134  if (typemask & TYPEMASK_GAMEOBJECT)
135  return GetGameObject(p, guid);
136  break;
137  case HighGuid::Creature:
138  case HighGuid::Vehicle:
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 }
TC_GAME_API Pet * GetPet(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:222
Definition: ObjectGuid.h:55
Definition: ObjectGuid.h:60
TC_GAME_API DynamicObject * GetDynamicObject(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:186
Definition: ObjectGuid.h:67
TC_GAME_API AreaTrigger * GetAreaTrigger(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:191
Definition: ObjectGuid.h:59
Definition: ObjectGuid.h:62
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:227
TC_GAME_API SceneObject * GetSceneObject(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:196
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:217
Definition: ObjectGuid.h:40
Definition: ObjectGuid.h:65
TC_GAME_API GameObject * GetGameObject(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:176
Definition: ObjectGuid.h:66
TC_GAME_API Conversation * GetConversation(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:201
Definition: Player.h:1131
Definition: ObjectGuid.h:63
+ 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 
)
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 
)
228 {
229  if (Player* player = HashMapHolder<Player>::Find(guid))
230  if (player->IsInWorld() && player->GetMap() == m)
231  return player;
232 
233  return nullptr;
234 }
Definition: ObjectAccessor.h:41
Definition: Player.h:1131
+ Here is the caller graph for this function:

◆ GetPlayer() [2/2]

Player * ObjectAccessor::GetPlayer ( WorldObject const &  u,
ObjectGuid const &  guid 
)
237 {
238  return GetPlayer(u.GetMap(), guid);
239 }
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:227
+ Here is the call graph for this function:

◆ GetPlayers()

HashMapHolder< Player >::MapType const & ObjectAccessor::GetPlayers ( )
284 {
286 }
static MapType & GetContainer()
Definition: ObjectAccessor.cpp:60
+ 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 
)
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 
)
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 
)
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 }
TC_GAME_API Pet * GetPet(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:222
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:227
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:217
+ Here is the call graph for this function:

◆ GetWorldObject()

WorldObject * ObjectAccessor::GetWorldObject ( WorldObject const &  p,
ObjectGuid const &  guid 
)
102 {
103  switch (guid.GetHigh())
104  {
105  case HighGuid::Player: return GetPlayer(p, guid);
106  case HighGuid::Transport:
107  case HighGuid::GameObject: return GetGameObject(p, guid);
108  case HighGuid::Vehicle:
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 Pet * GetPet(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:222
TC_GAME_API DynamicObject * GetDynamicObject(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:186
TC_GAME_API AreaTrigger * GetAreaTrigger(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:191
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:227
TC_GAME_API Corpse * GetCorpse(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:171
TC_GAME_API SceneObject * GetSceneObject(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:196
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:217
TC_GAME_API GameObject * GetGameObject(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:176
TC_GAME_API Conversation * GetConversation(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:201
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RemoveObject() [1/2]

template<class T >
void ObjectAccessor::RemoveObject ( T *  object)
101  {
102  HashMapHolder<T>::Remove(object);
103  }
static void Remove(T *o)
Definition: ObjectAccessor.cpp:43
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RemoveObject() [2/2]

template<>
void ObjectAccessor::RemoveObject ( Player player)
306 {
309 }
static void Remove(T *o)
Definition: ObjectAccessor.cpp:43
void Remove(Player *p)
Definition: ObjectAccessor.cpp:85
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SaveAllPlayers()

void ObjectAccessor::SaveAllPlayers ( )
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
Definition: ObjectAccessor.h:48
TC_GAME_API HashMapHolder< Player >::MapType const & GetPlayers()
Definition: ObjectAccessor.cpp:283
Definition: ObjectAccessor.h:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function: