TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 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 Player * GetPlayer (Map const *, ObjectGuid const &guid)
 
TC_GAME_API Player * GetPlayer (WorldObject const &, ObjectGuid const &guid)
 
TC_GAME_API CreatureGetCreatureOrPetOrVehicle (WorldObject const &, ObjectGuid const &)
 
TC_GAME_API Player * FindPlayer (ObjectGuid const &)
 
TC_GAME_API Player * FindPlayerByName (std::string const &name)
 
TC_GAME_API Player * FindConnectedPlayer (ObjectGuid const &)
 
TC_GAME_API Player * FindConnectedPlayerByName (std::string const &name)
 
TC_GAME_API HashMapHolder
< Player >::MapType const
GetPlayers ()
 
template<class T >
void AddObject (T *object)
 
template<class T >
void RemoveObject (T *object)
 
TC_GAME_API void SaveAllPlayers ()
 

Function Documentation

template<class T >
void ObjectAccessor::AddObject ( T *  object)
99  {
100  HashMapHolder<T>::Insert(object);
101  }
bool Insert(ContainerUnorderedMap< SPECIFIC_TYPE, KEY_TYPE > &elements, KEY_TYPE const &handle, SPECIFIC_TYPE *obj)
Definition: TypeContainerFunctions.h:38

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Player * ObjectAccessor::FindConnectedPlayer ( ObjectGuid const guid)
216 {
217  return HashMapHolder<Player>::Find(guid);
218 }
SPECIFIC_TYPE * Find(ContainerUnorderedMap< SPECIFIC_TYPE, KEY_TYPE > const &elements, KEY_TYPE const &handle, SPECIFIC_TYPE *)
Definition: TypeContainerFunctions.h:74

+ Here is the call graph for this function:

Player * ObjectAccessor::FindConnectedPlayerByName ( std::string const name)
241 {
242  boost::shared_lock<boost::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
243 
244  std::string nameStr = name;
245  std::transform(nameStr.begin(), nameStr.end(), nameStr.begin(), ::tolower);
247  for (HashMapHolder<Player>::MapType::const_iterator iter = m.begin(); iter != m.end(); ++iter)
248  {
249  std::string currentName = iter->second->GetName();
250  std::transform(currentName.begin(), currentName.end(), currentName.begin(), ::tolower);
251  if (nameStr.compare(currentName) == 0)
252  return iter->second;
253  }
254 
255  return NULL;
256 }
arena_t NULL
Definition: jemalloc_internal.h:624
TC_GAME_API HashMapHolder< Player >::MapType const & GetPlayers()
Definition: ObjectAccessor.cpp:258
Definition: ObjectAccessor.h:45

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Player * ObjectAccessor::FindPlayer ( ObjectGuid const guid)
210 {
211  Player* player = HashMapHolder<Player>::Find(guid);
212  return player && player->IsInWorld() ? player : nullptr;
213 }
SPECIFIC_TYPE * Find(ContainerUnorderedMap< SPECIFIC_TYPE, KEY_TYPE > const &elements, KEY_TYPE const &handle, SPECIFIC_TYPE *)
Definition: TypeContainerFunctions.h:74

+ Here is the call graph for this function:

Player * ObjectAccessor::FindPlayerByName ( std::string const name)
221 {
222  boost::shared_lock<boost::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
223 
224  std::string nameStr = name;
225  std::transform(nameStr.begin(), nameStr.end(), nameStr.begin(), ::tolower);
227  for (HashMapHolder<Player>::MapType::const_iterator iter = m.begin(); iter != m.end(); ++iter)
228  {
229  if (!iter->second->IsInWorld())
230  continue;
231  std::string currentName = iter->second->GetName();
232  std::transform(currentName.begin(), currentName.end(), currentName.begin(), ::tolower);
233  if (nameStr.compare(currentName) == 0)
234  return iter->second;
235  }
236 
237  return NULL;
238 }
arena_t NULL
Definition: jemalloc_internal.h:624
TC_GAME_API HashMapHolder< Player >::MapType const & GetPlayers()
Definition: ObjectAccessor.cpp:258
Definition: ObjectAccessor.h:45

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

AreaTrigger * ObjectAccessor::GetAreaTrigger ( WorldObject const u,
ObjectGuid const guid 
)
159 {
160  return u.GetMap()->GetAreaTrigger(guid);
161 }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Corpse * ObjectAccessor::GetCorpse ( WorldObject const u,
ObjectGuid const guid 
)
139 {
140  return u.GetMap()->GetCorpse(guid);
141 }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Creature * ObjectAccessor::GetCreature ( WorldObject const u,
ObjectGuid const guid 
)
175 {
176  return u.GetMap()->GetCreature(guid);
177 }

+ Here is the call graph for this function:

Creature * ObjectAccessor::GetCreatureOrPetOrVehicle ( WorldObject const u,
ObjectGuid const guid 
)
199 {
200  if (guid.IsPet())
201  return GetPet(u, guid);
202 
203  if (guid.IsCreatureOrVehicle())
204  return GetCreature(u, guid);
205 
206  return NULL;
207 }
TC_GAME_API Pet * GetPet(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:179
arena_t NULL
Definition: jemalloc_internal.h:624
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:174

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DynamicObject * ObjectAccessor::GetDynamicObject ( WorldObject const u,
ObjectGuid const guid 
)
154 {
155  return u.GetMap()->GetDynamicObject(guid);
156 }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

GameObject * ObjectAccessor::GetGameObject ( WorldObject const u,
ObjectGuid const guid 
)
144 {
145  return u.GetMap()->GetGameObject(guid);
146 }

+ Here is the call graph for this function:

Object * ObjectAccessor::GetObjectByTypeMask ( WorldObject const p,
ObjectGuid const guid,
uint32  typemask 
)
97 {
98  switch (guid.GetHigh())
99  {
100  case HighGuid::Item:
101  if (typemask & TYPEMASK_ITEM && p.GetTypeId() == TYPEID_PLAYER)
102  return ((Player const&)p).GetItemByGuid(guid);
103  break;
104  case HighGuid::Player:
105  if (typemask & TYPEMASK_PLAYER)
106  return GetPlayer(p, guid);
107  break;
108  case HighGuid::Transport:
110  if (typemask & TYPEMASK_GAMEOBJECT)
111  return GetGameObject(p, guid);
112  break;
113  case HighGuid::Creature:
114  case HighGuid::Vehicle:
115  if (typemask & TYPEMASK_UNIT)
116  return GetCreature(p, guid);
117  break;
118  case HighGuid::Pet:
119  if (typemask & TYPEMASK_UNIT)
120  return GetPet(p, guid);
121  break;
123  if (typemask & TYPEMASK_DYNAMICOBJECT)
124  return GetDynamicObject(p, guid);
125  break;
127  if (typemask & TYPEMASK_AREATRIGGER)
128  return GetAreaTrigger(p, guid);
129  case HighGuid::Corpse:
130  break;
131  default:
132  break;
133  }
134 
135  return NULL;
136 }
TC_GAME_API Pet * GetPet(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:179
Definition: ObjectGuid.h:47
Definition: ObjectGuid.h:50
TC_GAME_API DynamicObject * GetDynamicObject(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:153
arena_t NULL
Definition: jemalloc_internal.h:624
TC_GAME_API AreaTrigger * GetAreaTrigger(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:158
Definition: ObjectGuid.h:49
Definition: ObjectGuid.h:51
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:184
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:174
Definition: ObjectGuid.h:33
Definition: ObjectGuid.h:54
TC_GAME_API GameObject * GetGameObject(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:143
Definition: ObjectGuid.h:52

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Pet * ObjectAccessor::GetPet ( WorldObject const u,
ObjectGuid const guid 
)
180 {
181  return u.GetMap()->GetPet(guid);
182 }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Player * ObjectAccessor::GetPlayer ( Map const m,
ObjectGuid const guid 
)
185 {
186  if (Player* player = HashMapHolder<Player>::Find(guid))
187  if (player->IsInWorld() && player->GetMap() == m)
188  return player;
189 
190  return nullptr;
191 }
Definition: ObjectAccessor.h:45
Player * ObjectAccessor::GetPlayer ( WorldObject const u,
ObjectGuid const guid 
)
194 {
195  return GetPlayer(u.GetMap(), guid);
196 }
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:184

+ Here is the call graph for this function:

HashMapHolder< Player >::MapType const & ObjectAccessor::GetPlayers ( )
259 {
261 }
Definition: ObjectAccessor.h:45

+ Here is the caller graph for this function:

Transport * ObjectAccessor::GetTransport ( WorldObject const u,
ObjectGuid const guid 
)
149 {
150  return u.GetMap()->GetTransport(guid);
151 }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Unit * ObjectAccessor::GetUnit ( WorldObject const u,
ObjectGuid const guid 
)
164 {
165  if (guid.IsPlayer())
166  return GetPlayer(u, guid);
167 
168  if (guid.IsPet())
169  return GetPet(u, guid);
170 
171  return GetCreature(u, guid);
172 }
TC_GAME_API Pet * GetPet(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:179
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:184
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:174

+ Here is the call graph for this function:

WorldObject * ObjectAccessor::GetWorldObject ( WorldObject const p,
ObjectGuid const guid 
)
80 {
81  switch (guid.GetHigh())
82  {
83  case HighGuid::Player: return GetPlayer(p, guid);
85  case HighGuid::GameObject: return GetGameObject(p, guid);
86  case HighGuid::Vehicle:
87  case HighGuid::Creature: return GetCreature(p, guid);
88  case HighGuid::Pet: return GetPet(p, guid);
89  case HighGuid::DynamicObject: return GetDynamicObject(p, guid);
90  case HighGuid::AreaTrigger: return GetAreaTrigger(p, guid);
91  case HighGuid::Corpse: return GetCorpse(p, guid);
92  default: return NULL;
93  }
94 }
TC_GAME_API Pet * GetPet(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:179
TC_GAME_API DynamicObject * GetDynamicObject(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:153
arena_t NULL
Definition: jemalloc_internal.h:624
TC_GAME_API AreaTrigger * GetAreaTrigger(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:158
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:184
TC_GAME_API Corpse * GetCorpse(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:138
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:174
TC_GAME_API GameObject * GetGameObject(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:143

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class T >
void ObjectAccessor::RemoveObject ( T *  object)
105  {
106  HashMapHolder<T>::Remove(object);
107  }
bool Remove(ContainerUnorderedMap< SPECIFIC_TYPE, KEY_TYPE > &elements, KEY_TYPE const &handle, SPECIFIC_TYPE *)
Definition: TypeContainerFunctions.h:104

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ObjectAccessor::SaveAllPlayers ( )
264 {
265  boost::shared_lock<boost::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
266 
268  for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
269  itr->second->SaveToDB();
270 }
TC_GAME_API HashMapHolder< Player >::MapType const & GetPlayers()
Definition: ObjectAccessor.cpp:258
Definition: ObjectAccessor.h:45

+ Here is the call graph for this function:

+ Here is the caller graph for this function: