19 #ifndef ObjectGuid_h__
20 #define ObjectGuid_h__
24 #include <type_traits>
42 #define NUM_CLIENT_OBJECT_TYPES 11
113 template<HighGu
id high>
121 #define GUID_TRAIT_GLOBAL(highguid) \
122 template<> struct ObjectGuidTraits<highguid> \
124 static bool const Global = true; \
125 static bool const RealmSpecific = false; \
126 static bool const MapSpecific = false; \
129 #define GUID_TRAIT_REALM_SPECIFIC(highguid) \
130 template<> struct ObjectGuidTraits<highguid> \
132 static bool const Global = false; \
133 static bool const RealmSpecific = true; \
134 static bool const MapSpecific = false; \
137 #define GUID_TRAIT_MAP_SPECIFIC(highguid) \
138 template<> struct ObjectGuidTraits<highguid> \
140 static bool const Global = false; \
141 static bool const RealmSpecific = false; \
142 static bool const MapSpecific = true; \
187 #pragma pack(push, 1)
201 template<HighGu
id type>
202 static typename std::enable_if<ObjectGuidTraits<type>::Global, ObjectGuid>::type
Create(LowType counter) {
return Global(type, counter); }
204 template<HighGu
id type>
205 static typename std::enable_if<ObjectGuidTraits<type>::RealmSpecific, ObjectGuid>::type
Create(LowType counter) {
return RealmSpecific(type, counter); }
207 template<HighGu
id type>
208 static typename std::enable_if<ObjectGuidTraits<type>::MapSpecific, ObjectGuid>::type
Create(
uint16 mapId,
uint32 entry, LowType counter) {
return MapSpecific(type, 0, mapId, 0, entry, counter); }
212 std::vector<uint8> GetRawValue()
const;
213 void SetRawValue(std::vector<uint8>
const& guid);
215 void Clear() { _high = 0; _low = 0; }
233 return ((
uint8*)&_low)[index];
239 return ((
uint8 const*)&_low)[index];
242 bool IsEmpty()
const {
return _low == 0 && _high == 0; }
250 bool IsUnit()
const {
return IsAnyTypeCreature() || IsPlayer(); }
287 bool operator!= (ObjectGuid
const& guid)
const {
return !(*
this == guid); }
290 if (_high < guid.
_high)
292 else if (_high > guid.
_high)
295 return _low < guid.
_low;
298 static char const* GetTypeName(
HighGuid high);
318 static ObjectGuid Global(
HighGuid type, LowType counter);
319 static ObjectGuid RealmSpecific(
HighGuid type, LowType counter);
323 explicit ObjectGuid(
uint32 const&) =
delete;
339 #define PACKED_GUID_MIN_BUFFER_SIZE 18
349 void Set(ObjectGuid
const& guid);
351 size_t size()
const {
return _packedGuid.size(); }
367 static void HandleCounterOverflow(
HighGuid high);
371 template<HighGu
id high>
400 return boost::hash_range(reinterpret_cast<uint64 const*>(&key), reinterpret_cast<uint64 const*>(&key) + 2);
405 #endif // ObjectGuid_h__
bool IsCreatureOrVehicle() const
Definition: ObjectGuid.h:247
bool IsUnit() const
Definition: ObjectGuid.h:250
bool IsGameObject() const
Definition: ObjectGuid.h:252
bool IsPlayer() const
Definition: ObjectGuid.h:249
Definition: ObjectGuid.h:47
virtual void Set(uint64 val)
Definition: ObjectGuid.h:362
Definition: ObjectGuid.h:50
static LowType GetMaxCounter(HighGuid)
Definition: ObjectGuid.h:223
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
Definition: ByteBuffer.h:70
TypeID GetTypeId() const
Definition: ObjectGuid.h:283
Definition: ObjectGuid.h:31
Definition: ObjectGuid.h:36
PackedGuid()
Definition: ObjectGuid.h:346
#define hash
Definition: private_namespace.h:186
ByteBuffer _packedGuid
Definition: ObjectGuid.h:354
uint64 _low
Definition: ObjectGuid.h:325
TC_GAME_API ByteBuffer & operator>>(ByteBuffer &buf, ObjectGuid &guid)
Definition: ObjectGuid.cpp:167
Definition: ObjectGuid.h:372
Definition: ObjectGuid.h:46
static bool const MapSpecific
Definition: ObjectGuid.h:118
uint8 & operator[](uint32 index)
Definition: ObjectGuid.h:230
#define UI64LIT(N)
Definition: Define.h:138
Definition: ObjectGuid.h:32
char const * GetTypeName() const
Definition: ObjectGuid.h:299
static std::enable_if< ObjectGuidTraits< type >::RealmSpecific, ObjectGuid >::type Create(LowType counter)
Definition: ObjectGuid.h:205
uint64 _nextGuid
Definition: ObjectGuid.h:368
Definition: ObjectGuid.h:357
Definition: Transport.h:28
Definition: ObjectGuid.h:56
Definition: Creature.h:467
std::deque< ObjectGuid > GuidDeque
Definition: ObjectGuid.h:334
ObjectGuid::LowType Generate() override
Definition: ObjectGuid.h:377
std::vector< ObjectGuid > GuidVector
Definition: ObjectGuid.h:335
bool operator<(const String &left, const String &right)
Definition: String.cpp:785
ObjectGuid::LowType GetNextAfterMaxUsed() const
Definition: ObjectGuid.h:364
uint64 LowType
Definition: ObjectGuid.h:199
static void HandleCounterOverflow(HighGuid high)
Definition: ObjectGuid.cpp:193
bool IsSceneObject() const
Definition: ObjectGuid.h:260
uint16_t uint16
Definition: g3dmath.h:166
std::list< ObjectGuid > GuidList
Definition: ObjectGuid.h:333
static bool const RealmSpecific
Definition: ObjectGuid.h:117
bool IsAnyTypeGameObject() const
Definition: ObjectGuid.h:257
bool IsMOTransport() const
Definition: ObjectGuid.h:256
Definition: ObjectGuid.h:49
bool IsItem() const
Definition: ObjectGuid.h:251
Definition: DynamicObject.h:35
Definition: ObjectGuid.h:114
bool IsDynamicObject() const
Definition: ObjectGuid.h:253
Definition: ObjectGuid.h:51
uint32 GetMapId() const
Definition: ObjectGuid.h:219
string ToString(int i)
Definition: strutil.h:491
Definition: ObjectGuid.h:37
#define GUID_TRAIT_GLOBAL(highguid)
Definition: ObjectGuid.h:121
HighGuid
Definition: ObjectGuid.h:60
bool IsVehicle() const
Definition: ObjectGuid.h:245
static std::enable_if< ObjectGuidTraits< type >::Global, ObjectGuid >::type Create(LowType counter)
Definition: ObjectGuid.h:202
Definition: ObjectGuid.h:39
static std::enable_if< ObjectGuidTraits< type >::MapSpecific, ObjectGuid >::type Create(uint16 mapId, uint32 entry, LowType counter)
Definition: ObjectGuid.h:208
PackedGuid(ObjectGuid const &guid)
Definition: ObjectGuid.h:347
ObjectGuid(uint64 high, uint64 low)
Definition: ObjectGuid.h:322
bool operator!=(const CoordPair< LIMIT > &p1, const CoordPair< LIMIT > &p2)
Definition: GridDefines.h:166
Definition: ObjectGuid.h:34
#define GUID_TRAIT_MAP_SPECIFIC(highguid)
Definition: ObjectGuid.h:137
uint32 GetRealmId() const
Definition: ObjectGuid.h:218
bool operator==(const CoordPair< LIMIT > &p1, const CoordPair< LIMIT > &p2)
Definition: GridDefines.h:160
uint32_t uint32
Definition: Define.h:150
bool operator!() const
Definition: ObjectGuid.h:285
uint64_t uint64
Definition: Define.h:149
size_t size() const
Definition: ObjectGuid.h:351
uint16_t uint16
Definition: Define.h:151
Definition: ObjectGuid.h:57
LowType GetMaxCounter() const
Definition: ObjectGuid.h:228
Definition: GameObject.h:880
TypeMask
Definition: ObjectGuid.h:44
void SetRawValue(uint64 high, uint64 low)
Definition: ObjectGuid.h:214
TC_GAME_API ByteBuffer & operator<<(ByteBuffer &buf, ObjectGuid const &guid)
Definition: ObjectGuid.cpp:146
#define GUID_TRAIT_REALM_SPECIFIC(highguid)
Definition: ObjectGuid.h:129
static bool const Global
Definition: ObjectGuid.h:116
Definition: ObjectGuid.h:29
ObjectGuidGeneratorBase(ObjectGuid::LowType start=UI64LIT(1))
Definition: ObjectGuid.h:360
uint32 GetEntry() const
Definition: ObjectGuid.h:220
bool IsAreaTrigger() const
Definition: ObjectGuid.h:255
TypeID
Definition: ObjectGuid.h:27
void Clear()
Definition: ObjectGuid.h:215
size_t operator()(ObjectGuid const &key) const
Definition: ObjectGuid.h:398
bool IsConversation() const
Definition: ObjectGuid.h:261
#define PACKED_GUID_MIN_BUFFER_SIZE
Definition: ObjectGuid.h:339
Definition: ObjectGuid.h:38
Definition: ObjectGuid.h:33
std::set< ObjectGuid > GuidSet
Definition: ObjectGuid.h:332
static ObjectGuid const TradeItem
Definition: ObjectGuid.h:197
#define TC_GAME_API
Definition: Define.h:134
bool HasEntry() const
Definition: ObjectGuid.h:316
Definition: ObjectGuid.h:54
HighGuid GetHigh() const
Definition: ObjectGuid.h:217
bool IsCreatureOrPet() const
Definition: ObjectGuid.h:246
bool IsAnyTypeCreature() const
Definition: ObjectGuid.h:248
static TypeID GetTypeId(HighGuid high)
Definition: ObjectGuid.h:263
Definition: ObjectGuid.h:48
uint8_t uint8
Definition: Define.h:152
#define ASSERT
Definition: Errors.h:55
static bool HasEntry(HighGuid high)
Definition: ObjectGuid.h:303
uint8 const & operator[](uint32 index) const
Definition: ObjectGuid.h:236
std::unordered_set< ObjectGuid > GuidUnorderedSet
Definition: ObjectGuid.h:336
Definition: ObjectGuid.h:189
uint32_t uint32
Definition: g3dmath.h:168
ObjectGuidGenerator(ObjectGuid::LowType start=UI64LIT(1))
Definition: ObjectGuid.h:375
Definition: ObjectGuid.h:35
Definition: ObjectGuid.h:55
Definition: ObjectGuid.h:341
Definition: ObjectGuid.h:53
ObjectGuid()
Definition: ObjectGuid.h:210
bool IsGuild() const
Definition: ObjectGuid.h:259
bool IsParty() const
Definition: ObjectGuid.h:258
bool IsEmpty() const
Definition: ObjectGuid.h:242
Definition: ObjectGuid.h:30
uint64 _high
Definition: ObjectGuid.h:326
Definition: AreaTrigger.h:26
bool IsCreature() const
Definition: ObjectGuid.h:243
bool IsPet() const
Definition: ObjectGuid.h:244
LowType GetCounter() const
Definition: ObjectGuid.h:221
bool IsCorpse() const
Definition: ObjectGuid.h:254
Definition: ObjectGuid.h:52