18#ifndef TRINITYCORE_OBJECT_GUID_H
19#define TRINITYCORE_OBJECT_GUID_H
33#include <unordered_set>
85inline constexpr std::array<uint32, NUM_CLIENT_OBJECT_TYPES + 1>
ObjectTypeMask =
206template<HighGu
id high>
210 using Format = std::integral_constant<ObjectGuidFormatType, ObjectGuidFormatType::Null>;
213#define MAKE_GUID_TRAIT(high, sequence, format) \
214 template<> struct ObjectGuidTraits<high> \
216 static constexpr EnumFlag<ObjectGuidSequenceSource> SequenceSource = sequence; \
217 using Format = std::integral_constant<ObjectGuidFormatType, format>; \
319 static constexpr std::size_t BytesSize = 16;
326 std::span<uint8 const, 16>
GetRawValue()
const {
return std::span<uint8 const, 16>(
reinterpret_cast<uint8 const*
>(_data.data()), BytesSize); }
327 void SetRawValue(std::span<uint8 const> rawBytes);
341 return (_data[1] >> 38) &
UI64LIT(0xFFFFF);
345 return _data[0] &
UI64LIT(0x000000FFFFFFFFFF);
362 bool IsEmpty()
const {
return _data[0] == 0 && _data[1] == 0; }
392 return std::strong_ordering::equal;
395 static std::string_view GetTypeName(
HighGuid high);
397 std::string ToString()
const;
398 std::string ToHexString()
const;
399 static ObjectGuid FromString(std::string_view guidString);
405 template <HighGuid type, std::enable_if_t<ObjectGuidTraits<type>::Format::value ==
ObjectGuidFormatType::WorldObject,
int32> = 0>
static ObjectGuid Create(
uint16 mapId,
uint32 entry,
LowType counter) {
return ObjectGuidFactory::CreateWorldObject(type, 0, 0, mapId, 0, entry, counter); }
406 template <HighGuid type, std::enable_if_t<ObjectGuidTraits<type>::Format::value ==
ObjectGuidFormatType::WorldObject,
int32> = 0>
static ObjectGuid Create(
uint8 subType,
uint16 mapId,
uint32 entry,
LowType counter) {
return ObjectGuidFactory::CreateWorldObject(type, subType, 0, mapId, 0, entry, counter); }
409 template <HighGuid type, std::enable_if_t<ObjectGuidTraits<type>::Format::value ==
ObjectGuidFormatType::ChatChannel,
int32> = 0>
static ObjectGuid Create(
bool builtIn,
bool trade,
uint16 zoneId,
uint8 factionGroupMask,
LowType counter) {
return ObjectGuidFactory::CreateChatChannel(0, builtIn, trade, zoneId, factionGroupMask, counter); }
414 template <HighGuid type, std::enable_if_t<ObjectGuidTraits<type>::Format::value ==
ObjectGuidFormatType::LFGObject,
int32> = 0>
static ObjectGuid Create(
uint8 arg1,
uint8 arg2,
uint8 arg3,
uint8 arg4,
bool arg5,
uint8 arg6,
LowType counter) {
return ObjectGuidFactory::CreateLFGObject(arg1, arg2, arg3, arg4, arg5, arg6, counter); }
428 std::array<uint64, 2> _data = { };
452 template <
typename FormatContext>
478 switch (legacyTypeID)
511 if (legacyTypeMask & (1 <<
uint32(i)))
#define DEFINE_ENUM_FLAG(enumType)
ByteBuffer & operator<<(ByteBuffer &buf, ObjectGuid const &guid)
ByteBuffer & operator>>(ByteBuffer &buf, ObjectGuid &guid)
std::list< ObjectGuid > GuidList
std::unordered_set< ObjectGuid > GuidUnorderedSet
constexpr std::array< uint32, NUM_CLIENT_OBJECT_TYPES+1 > ObjectTypeMask
TC_GAME_API ByteBuffer & operator>>(ByteBuffer &buf, ObjectGuid &guid)
@ NUM_CLIENT_OBJECT_TYPES
@ TYPEID_AZERITE_EMPOWERED_ITEM
std::set< ObjectGuid > GuidSet
#define MAKE_GUID_TRAIT(high, sequence, format)
@ TYPEMASK_AZERITE_EMPOWERED_ITEM
TC_GAME_API ByteBuffer & operator<<(ByteBuffer &buf, ObjectGuid const &guid)
std::vector< ObjectGuid > GuidVector
static ObjectGuid CreateTransport(HighGuid type, uint32 counter)
static ObjectGuid CreateHousing(uint32 subType, uint32 arg1, uint32 arg2, uint64 arg3)
static ObjectGuid CreateGlobal(HighGuid type, uint64 dbIdHigh, uint64 dbId)
static ObjectGuid CreateItem(uint32 realmId, uint64 dbId)
static ObjectGuid CreateWorldLayer(uint32 arg1, uint16 arg2, uint8 arg3, uint32 arg4)
static ObjectGuid CreateLMMLobby(uint32 realmId, uint32 arg2, uint8 arg3, uint8 arg4, uint64 counter)
static ObjectGuid CreateMobileSession(uint32 realmId, uint16 arg1, uint64 counter)
static ObjectGuid CreateClubFinder(uint32 realmId, uint8 type, uint32 clubFinderId, uint64 dbId)
static ObjectGuid CreateClient(HighGuid type, uint32 realmId, uint32 arg1, uint64 counter)
static ObjectGuid CreateClientActor(uint16 ownerType, uint16 ownerId, uint32 counter)
static ObjectGuid CreateToolsClient(uint16 mapId, uint32 serverId, uint64 counter)
static ObjectGuid CreatePlayer(uint32 realmId, uint8 subType, uint32 arg1, uint64 dbId)
static ObjectGuid CreateGuild(HighGuid type, uint32 realmId, uint64 dbId)
static ObjectGuid CreateWorldObject(HighGuid type, uint8 subType, uint32 realmId, uint16 mapId, uint32 serverId, uint32 entry, uint64 counter)
static ObjectGuid CreateChatChannel(uint32 realmId, bool builtIn, bool trade, uint16 zoneId, uint8 factionGroupMask, uint64 counter)
static constexpr ObjectGuid CreateUniq(uint64 id)
static ObjectGuid CreateLFGList(uint8 arg1, uint64 counter)
static constexpr ObjectGuid CreateNull()
static ObjectGuid CreateLFGObject(uint8 arg1, uint8 arg2, uint8 arg3, uint8 arg4, bool arg5, uint8 arg6, uint64 counter)
static ObjectGuid CreateWebObj(uint32 realmId, uint8 arg1, uint8 arg2, uint64 counter)
static LowType GetMaxCounter(HighGuid high)
static ObjectGuid Create(uint32 arg1, LowType counter)
LowType GetCounter() const
static ObjectGuid Create(uint8 arg1, uint8 arg2, LowType counter)
static ObjectGuid const Empty
static ObjectGuid Create(uint32 arg1, uint16 arg2, uint8 arg3, uint32 arg4)
bool IsAnyTypeGameObject() const
static ObjectGuid Create(uint8 clubType, uint32 clubFinderId, LowType dbId)
static ObjectGuid Create(uint16 ownerType, uint16 ownerId, uint32 counter)
static ObjectGuid const ToStringFailed
std::span< uint8 const, 16 > GetRawValue() const
bool IsAreaTrigger() const
static ObjectGuid Create(uint32 counter)
static ObjectGuid Create(bool builtIn, bool trade, uint16 zoneId, uint8 factionGroupMask, LowType counter)
uint64 GetRawValue(std::size_t i) const
void SetRawValue(uint64 high, uint64 low)
bool operator==(ObjectGuid const &right) const =default
bool IsSceneObject() const
static ObjectGuid const FromStringFailed
bool IsMOTransport() const
static ObjectGuid Create(uint16 mapId, uint32 serverId, LowType counter)
std::string_view GetTypeName() const
static constexpr ObjectGuid Create()
static ObjectGuid Create(uint8 arg1, LowType counter)
bool IsDynamicObject() const
LowType GetMaxCounter() const
bool IsGameObject() const
static ObjectGuid Create(LowType dbId)
static ObjectGuid Create(uint8 subType, uint16 mapId, uint32 entry, LowType counter)
static ObjectGuid Create(uint32 arg2, uint8 arg3, uint8 arg4, LowType counter)
bool IsCreatureOrPet() const
std::strong_ordering operator<=>(ObjectGuid const &right) const
constexpr ObjectGuid(uint64 high, uint64 low)
std::array< uint64, 2 > _data
static ObjectGuid const TradeItem
static constexpr ObjectGuid Create(LowType id)
static ObjectGuid Create(uint16 arg1, LowType counter)
uint32 GetSubType() const
bool IsAnyTypeCreature() const
bool IsCreatureOrVehicle() const
static ObjectGuid Create(uint8 arg1, uint8 arg2, uint8 arg3, uint8 arg4, bool arg5, uint8 arg6, LowType counter)
uint32 GetRealmId() const
static ObjectGuid Create(uint32 subType, uint32 arg1, uint32 arg2, uint64 arg3)
static ObjectGuid Create(uint16 mapId, uint32 entry, LowType counter)
constexpr ObjectGuid()=default
bool IsConversation() const
constexpr TypeMask ConvertLegacyTypeMask(uint32 legacyTypeMask)
constexpr ::TypeID ConvertLegacyTypeID(TypeID legacyTypeID)
constexpr bool is_neq(std::partial_ordering cmp) noexcept
std::integral_constant< ObjectGuidFormatType, ObjectGuidFormatType::Null > Format
static constexpr EnumFlag< ObjectGuidSequenceSource > SequenceSource
static constexpr std::size_t GetHash(std::span< V, Extent > data) noexcept
std::size_t operator()(ObjectGuid const &key) const noexcept