OregonCore  revision fb2a440-git
Your Favourite TBC server
ObjectGuid Class Reference

#include <ObjectGuid.h>

Public Member Functions

 ObjectGuid ()
 
 ObjectGuid (uint64 const &guid)
 
 ObjectGuid (HighGuid hi, uint32 entry, uint32 counter)
 
 operator uint64 () const
 
PackedGuidReader ReadAsPacked ()
 
void Set (uint64 const &guid)
 
void Clear ()
 
void operator= (uint64 const &guid)
 
PackedGuid WriteAsPacked () const
 
uint64 const & GetRawValue () const
 
HighGuid GetHigh () const
 
uint32 GetEntry () const
 
uint32 GetCounter () const
 
bool IsEmpty () const
 
bool IsCreature () const
 
bool IsPet () const
 
bool IsCreatureOrPet () const
 
bool IsPlayer () const
 
bool IsUnit () const
 
bool IsItem () const
 
bool IsGameobject () const
 
bool IsDynamicObject () const
 
bool IsCorpse () const
 
bool IsTransport () const
 
bool IsMOTransport () const
 
TypeID GetTypeId ()
 
bool operator! () const
 
bool operator== (ObjectGuid const &guid) const
 
bool operator!= (ObjectGuid const &guid) const
 
bool operator< (ObjectGuid const &guid) const
 
char const * GetTypeName () const
 
std::string GetString () const
 

Private Member Functions

bool HasEntry () const
 

Private Attributes

uint64 m_guid
 

Detailed Description

Definition at line 122 of file ObjectGuid.h.

Constructor & Destructor Documentation

ObjectGuid::ObjectGuid ( )
inline

Definition at line 125 of file ObjectGuid.h.

125 : m_guid(0) {}
uint64 m_guid
Definition: ObjectGuid.h:277
ObjectGuid::ObjectGuid ( uint64 const &  guid)
inline

Definition at line 126 of file ObjectGuid.h.

126 : m_guid(guid) {} // NOTE: must be explicit in future for more strict control type conversions
uint64 m_guid
Definition: ObjectGuid.h:277
ObjectGuid::ObjectGuid ( HighGuid  hi,
uint32  entry,
uint32  counter 
)
inline

Definition at line 127 of file ObjectGuid.h.

127 : m_guid(uint64(counter) | (uint64(entry) << 24) | (uint64(hi) << 48)) {}
uint64 m_guid
Definition: ObjectGuid.h:277
ACE_UINT64 uint64
Definition: Define.h:70

Member Function Documentation

void ObjectGuid::Clear ( )
inline

Definition at line 141 of file ObjectGuid.h.

Referenced by SmartAI::JustRespawned(), SmartScript::ResetBaseObject(), SmartAI::SmartAI(), and SmartAI::StopFollow().

142  {
143  m_guid = 0;
144  }
uint64 m_guid
Definition: ObjectGuid.h:277
uint32 ObjectGuid::GetCounter ( ) const
inline

Definition at line 166 of file ObjectGuid.h.

References UI64LIT.

Referenced by GetString().

167  {
168  return HasEntry()
169  ? uint32(m_guid & UI64LIT(0x0000000000FFFFFF))
170  : uint32(m_guid & UI64LIT(0x00000000FFFFFFFF));
171  }
#define UI64LIT(N)
Definition: Common.h:150
uint64 m_guid
Definition: ObjectGuid.h:277
bool HasEntry() const
Definition: ObjectGuid.h:257
ACE_UINT32 uint32
Definition: Define.h:71
uint32 ObjectGuid::GetEntry ( ) const
inline

Definition at line 162 of file ObjectGuid.h.

References UI64LIT.

Referenced by GetString().

163  {
164  return HasEntry() ? uint32((m_guid >> 24) & UI64LIT(0x0000000000FFFFFF)) : 0;
165  }
#define UI64LIT(N)
Definition: Common.h:150
uint64 m_guid
Definition: ObjectGuid.h:277
bool HasEntry() const
Definition: ObjectGuid.h:257
ACE_UINT32 uint32
Definition: Define.h:71
HighGuid ObjectGuid::GetHigh ( ) const
inline

Definition at line 158 of file ObjectGuid.h.

Referenced by GetTypeName().

159  {
160  return HighGuid((m_guid >> 48) & 0x0000FFFF);
161  }
HighGuid
Definition: ObjectGuid.h:51
uint64 m_guid
Definition: ObjectGuid.h:277
uint64 const& ObjectGuid::GetRawValue ( ) const
inline
std::string ObjectGuid::GetString ( ) const

Definition at line 48 of file ObjectGuid.cpp.

References GetCounter(), GetEntry(), GetTypeName(), and HasEntry().

Referenced by ChatHandler::ExecuteCommandInTable().

49 {
50  std::ostringstream str;
51  str << GetTypeName() << " (";
52  if (HasEntry())
53  str << "Entry: " << GetEntry() << " ";
54  str << "Guid: " << GetCounter() << ")";
55  return str.str();
56 }
uint32 GetCounter() const
Definition: ObjectGuid.h:166
char const * GetTypeName() const
Definition: ObjectGuid.cpp:21
uint32 GetEntry() const
Definition: ObjectGuid.h:162
bool HasEntry() const
Definition: ObjectGuid.h:257
TypeID ObjectGuid::GetTypeId ( )
inline

Definition at line 222 of file ObjectGuid.h.

References HIGHGUID_CORPSE, HIGHGUID_DYNAMICOBJECT, HIGHGUID_GAMEOBJECT, HIGHGUID_ITEM, HIGHGUID_MO_TRANSPORT, HIGHGUID_PET, HIGHGUID_PLAYER, HIGHGUID_UNIT, TYPEID_CORPSE, TYPEID_DYNAMICOBJECT, TYPEID_GAMEOBJECT, TYPEID_ITEM, TYPEID_OBJECT, TYPEID_PLAYER, and TYPEID_UNIT.

223  {
224  switch (GetHigh())
225  {
226  case HIGHGUID_ITEM:
227  return TYPEID_ITEM;
228  //case HIGHGUID_CONTAINER: return TYPEID_CONTAINER; HIGHGUID_CONTAINER==HIGHGUID_ITEM currently
229  case HIGHGUID_UNIT:
230  return TYPEID_UNIT;
231  case HIGHGUID_PET:
232  return TYPEID_UNIT;
233  case HIGHGUID_PLAYER:
234  return TYPEID_PLAYER;
235  case HIGHGUID_GAMEOBJECT:
236  return TYPEID_GAMEOBJECT;
238  return TYPEID_DYNAMICOBJECT;
239  case HIGHGUID_CORPSE:
240  return TYPEID_CORPSE;
242  return TYPEID_GAMEOBJECT;
243  // unknown
244  default:
245  return TYPEID_OBJECT;
246  }
247  }
HighGuid GetHigh() const
Definition: ObjectGuid.h:158
char const * ObjectGuid::GetTypeName ( ) const

Definition at line 21 of file ObjectGuid.cpp.

References GetHigh(), HIGHGUID_CORPSE, HIGHGUID_DYNAMICOBJECT, HIGHGUID_GAMEOBJECT, HIGHGUID_ITEM, HIGHGUID_MO_TRANSPORT, HIGHGUID_PET, HIGHGUID_PLAYER, HIGHGUID_TRANSPORT, HIGHGUID_UNIT, and IsEmpty().

Referenced by GetString().

22 {
23  switch (GetHigh())
24  {
25  case HIGHGUID_ITEM:
26  return "item";
27  case HIGHGUID_PLAYER:
28  return !IsEmpty() ? "player" : "none";
30  return "gameobject";
31  case HIGHGUID_TRANSPORT:
32  return "transport";
33  case HIGHGUID_UNIT:
34  return "creature";
35  case HIGHGUID_PET:
36  return "pet";
38  return "dynobject";
39  case HIGHGUID_CORPSE:
40  return "corpse";
42  return "mo_transport";
43  default:
44  return "<unknown>";
45  }
46 }
HighGuid GetHigh() const
Definition: ObjectGuid.h:158
bool IsEmpty() const
Definition: ObjectGuid.h:173
bool ObjectGuid::HasEntry ( ) const
inlineprivate

Definition at line 257 of file ObjectGuid.h.

References HIGHGUID_CORPSE, HIGHGUID_DYNAMICOBJECT, HIGHGUID_GAMEOBJECT, HIGHGUID_ITEM, HIGHGUID_MO_TRANSPORT, HIGHGUID_PET, HIGHGUID_PLAYER, HIGHGUID_TRANSPORT, and HIGHGUID_UNIT.

Referenced by GetString().

258  {
259  switch (GetHigh())
260  {
261  case HIGHGUID_ITEM:
262  case HIGHGUID_PLAYER:
264  case HIGHGUID_CORPSE:
266  return false;
267  case HIGHGUID_GAMEOBJECT:
268  case HIGHGUID_TRANSPORT:
269  case HIGHGUID_UNIT:
270  case HIGHGUID_PET:
271  default:
272  return true;
273  }
274  }
HighGuid GetHigh() const
Definition: ObjectGuid.h:158
bool ObjectGuid::IsCorpse ( ) const
inline

Definition at line 209 of file ObjectGuid.h.

References HIGHGUID_CORPSE.

210  {
211  return GetHigh() == HIGHGUID_CORPSE;
212  }
HighGuid GetHigh() const
Definition: ObjectGuid.h:158
bool ObjectGuid::IsCreature ( ) const
inline

Definition at line 177 of file ObjectGuid.h.

References HIGHGUID_UNIT.

178  {
179  return GetHigh() == HIGHGUID_UNIT;
180  }
HighGuid GetHigh() const
Definition: ObjectGuid.h:158
bool ObjectGuid::IsCreatureOrPet ( ) const
inline

Definition at line 185 of file ObjectGuid.h.

186  {
187  return IsCreature() || IsPet();
188  }
bool IsCreature() const
Definition: ObjectGuid.h:177
bool IsPet() const
Definition: ObjectGuid.h:181
bool ObjectGuid::IsDynamicObject ( ) const
inline

Definition at line 205 of file ObjectGuid.h.

References HIGHGUID_DYNAMICOBJECT.

206  {
207  return GetHigh() == HIGHGUID_DYNAMICOBJECT;
208  }
HighGuid GetHigh() const
Definition: ObjectGuid.h:158
bool ObjectGuid::IsEmpty ( ) const
inline

Definition at line 173 of file ObjectGuid.h.

Referenced by GetTypeName(), WorldSession::HandleQuestgiverAcceptQuestOpcode(), and SpellCastTargets::Update().

174  {
175  return m_guid == 0;
176  }
uint64 m_guid
Definition: ObjectGuid.h:277
bool ObjectGuid::IsGameobject ( ) const
inline

Definition at line 201 of file ObjectGuid.h.

References HIGHGUID_GAMEOBJECT.

202  {
203  return GetHigh() == HIGHGUID_GAMEOBJECT;
204  }
HighGuid GetHigh() const
Definition: ObjectGuid.h:158
bool ObjectGuid::IsItem ( ) const
inline

Definition at line 197 of file ObjectGuid.h.

References HIGHGUID_ITEM.

198  {
199  return GetHigh() == HIGHGUID_ITEM;
200  }
HighGuid GetHigh() const
Definition: ObjectGuid.h:158
bool ObjectGuid::IsMOTransport ( ) const
inline

Definition at line 217 of file ObjectGuid.h.

References HIGHGUID_MO_TRANSPORT.

218  {
219  return GetHigh() == HIGHGUID_MO_TRANSPORT;
220  }
HighGuid GetHigh() const
Definition: ObjectGuid.h:158
bool ObjectGuid::IsPet ( ) const
inline

Definition at line 181 of file ObjectGuid.h.

References HIGHGUID_PET.

182  {
183  return GetHigh() == HIGHGUID_PET;
184  }
HighGuid GetHigh() const
Definition: ObjectGuid.h:158
bool ObjectGuid::IsPlayer ( ) const
inline

Definition at line 189 of file ObjectGuid.h.

References HIGHGUID_PLAYER.

190  {
191  return !IsEmpty() && GetHigh() == HIGHGUID_PLAYER;
192  }
HighGuid GetHigh() const
Definition: ObjectGuid.h:158
bool IsEmpty() const
Definition: ObjectGuid.h:173
bool ObjectGuid::IsTransport ( ) const
inline

Definition at line 213 of file ObjectGuid.h.

References HIGHGUID_TRANSPORT.

214  {
215  return GetHigh() == HIGHGUID_TRANSPORT;
216  }
HighGuid GetHigh() const
Definition: ObjectGuid.h:158
bool ObjectGuid::IsUnit ( ) const
inline

Definition at line 193 of file ObjectGuid.h.

194  {
195  return IsCreatureOrPet() || IsPlayer();
196  }
bool IsPlayer() const
Definition: ObjectGuid.h:189
bool IsCreatureOrPet() const
Definition: ObjectGuid.h:185
ObjectGuid::operator uint64 ( ) const
inline

Definition at line 130 of file ObjectGuid.h.

130 { return m_guid; }
uint64 m_guid
Definition: ObjectGuid.h:277
bool ObjectGuid::operator! ( ) const
inline

Definition at line 248 of file ObjectGuid.h.

248 { return IsEmpty(); }
bool IsEmpty() const
Definition: ObjectGuid.h:173
bool ObjectGuid::operator!= ( ObjectGuid const &  guid) const
inline

Definition at line 250 of file ObjectGuid.h.

References GetRawValue().

250 { return GetRawValue() != guid.GetRawValue(); }
uint64 const & GetRawValue() const
Definition: ObjectGuid.h:154
bool ObjectGuid::operator< ( ObjectGuid const &  guid) const
inline

Definition at line 251 of file ObjectGuid.h.

References GetRawValue().

251 { return GetRawValue() < guid.GetRawValue(); }
uint64 const & GetRawValue() const
Definition: ObjectGuid.h:154
void ObjectGuid::operator= ( uint64 const &  guid)
inline

Definition at line 147 of file ObjectGuid.h.

148  {
149  m_guid = guid;
150  }
uint64 m_guid
Definition: ObjectGuid.h:277
bool ObjectGuid::operator== ( ObjectGuid const &  guid) const
inline

Definition at line 249 of file ObjectGuid.h.

References GetRawValue().

249 { return GetRawValue() == guid.GetRawValue(); }
uint64 const & GetRawValue() const
Definition: ObjectGuid.h:154
PackedGuidReader ObjectGuid::ReadAsPacked ( )
inline

Definition at line 132 of file ObjectGuid.h.

References PackedGuidReader::PackedGuidReader().

Referenced by SpellCastTargets::read().

133  {
134  return PackedGuidReader(*this);
135  }
void ObjectGuid::Set ( uint64 const &  guid)
inline

Definition at line 137 of file ObjectGuid.h.

Referenced by operator>>().

138  {
139  m_guid = guid;
140  }
uint64 m_guid
Definition: ObjectGuid.h:277
PackedGuid ObjectGuid::WriteAsPacked ( ) const
inline

Definition at line 329 of file ObjectGuid.h.

Referenced by SpellCastTargets::write().

330 {
331  return PackedGuid(*this);
332 }

Member Data Documentation

uint64 ObjectGuid::m_guid
private

Definition at line 277 of file ObjectGuid.h.


The documentation for this class was generated from the following files: