diff options
author | Shauren <shauren.trinity@gmail.com> | 2022-02-25 23:37:02 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2022-02-25 23:37:02 +0100 |
commit | 3e9b9603b66b94ef5f11a25dc7100e5db60d09e0 (patch) | |
tree | c20e0479a8d3961efc138790d158ab72724aa097 | |
parent | 1021fcee345b0817ca087c04f8f063eb9d10bfe9 (diff) |
Core/Objects: Add new 9.2 guid types
-rw-r--r-- | src/server/game/Entities/Object/ObjectGuid.cpp | 65 | ||||
-rw-r--r-- | src/server/game/Entities/Object/ObjectGuid.h | 16 |
2 files changed, 75 insertions, 6 deletions
diff --git a/src/server/game/Entities/Object/ObjectGuid.cpp b/src/server/game/Entities/Object/ObjectGuid.cpp index 9fec48ea6e0..90ae18ef5fe 100644 --- a/src/server/game/Entities/Object/ObjectGuid.cpp +++ b/src/server/game/Entities/Object/ObjectGuid.cpp @@ -276,7 +276,7 @@ namespace return Trinity::StringFormat("%s-%u-%012llX", typeName, guid.GetRealmId(), guid.GetRawValue(0)); } - ObjectGuid ParseGuild(HighGuid /*type*/, char const* guidString) + ObjectGuid ParseGuild(HighGuid type, char const* guidString) { uint32 realmId = 0; uint64 dbId = UI64LIT(0); @@ -284,7 +284,7 @@ namespace if (std::sscanf(guidString, "%u-%012" SCNx64, &realmId, &dbId) != 2) return ObjectGuid::FromStringFailed; - return ObjectGuidFactory::CreateGuild(realmId, dbId); + return ObjectGuidFactory::CreateGuild(type, realmId, dbId); } std::string FormatMobileSession(char const* typeName, ObjectGuid guid) @@ -418,6 +418,40 @@ namespace return ObjectGuidFactory::CreateClubFinder(realmId, type, clubFinderId, dbId); } + std::string FormatToolsClient(char const* typeName, ObjectGuid guid) + { + return Trinity::StringFormat("%s-%u-%u-%u-%010llX", typeName, guid.GetMapId(), uint32(guid.GetRawValue(0) >> 40) & 0xFFFFFF, guid.GetCounter()); + } + + ObjectGuid ParseToolsClient(HighGuid /*type*/, char const* guidString) + { + uint32 mapId = 0; + uint32 serverId = 0; + uint64 counter = UI64LIT(0); + if (std::sscanf(guidString, "%u-%u-%010" SCNx64, &mapId, &serverId, &counter) != 3) + return ObjectGuid::FromStringFailed; + + return ObjectGuidFactory::CreateToolsClient(mapId, serverId, counter); + } + + std::string FormatWorldLayer(char const* typeName, ObjectGuid guid) + { + return Trinity::StringFormat("%s-%X-%u-%u-%u", typeName, uint32((guid.GetRawValue(1) >> 10) & 0xFFFFFFFF), uint32(guid.GetRawValue(1) & 0x1FF), + uint32((guid.GetRawValue(0) >> 24) & 0xFF), uint32(guid.GetRawValue(0) & 0x7FFFFF)); + } + + ObjectGuid ParseWorldLayer(HighGuid /*type*/, char const* guidString) + { + uint32 arg1 = 0; + uint16 arg2 = 0; + uint8 arg3 = 0; + uint32 arg4 = 0; + if (std::sscanf(guidString, "%x-%hu-%hhu-%u", &arg1, &arg2, &arg3, &arg4) != 4) + return ObjectGuid::FromStringFailed; + + return ObjectGuidFactory::CreateWorldLayer(arg1, arg2, arg3, arg4); + } + ObjectGuidInfo(); } Info; @@ -478,6 +512,9 @@ namespace SET_GUID_INFO(Cast, FormatWorldObject, ParseWorldObject); SET_GUID_INFO(ClientConnection, FormatClient, ParseClient); SET_GUID_INFO(ClubFinder, FormatClubFinder, ParseClubFinder); + SET_GUID_INFO(ToolsClient, FormatToolsClient, ParseToolsClient); + SET_GUID_INFO(WorldLayer, FormatWorldLayer, ParseWorldLayer); + SET_GUID_INFO(ArenaTeam, FormatGuild, ParseGuild); #undef SET_GUID_INFO } @@ -604,9 +641,9 @@ ObjectGuid ObjectGuidFactory::CreateGlobal(HighGuid type, ObjectGuid::LowType db dbId); } -ObjectGuid ObjectGuidFactory::CreateGuild(uint32 realmId, ObjectGuid::LowType dbId) +ObjectGuid ObjectGuidFactory::CreateGuild(HighGuid type, uint32 realmId, ObjectGuid::LowType dbId) { - return ObjectGuid(uint64((uint64(HighGuid::Guild) << 58) + return ObjectGuid(uint64((uint64(type) << 58) | (uint64(GetRealmIdForObjectGuid(realmId)) << 42)), dbId); } @@ -664,6 +701,23 @@ ObjectGuid ObjectGuidFactory::CreateClubFinder(uint32 realmId, uint8 type, uint3 dbId); } +ObjectGuid ObjectGuidFactory::CreateToolsClient(uint16 mapId, uint32 serverId, uint64 counter) +{ + return ObjectGuid(uint64((uint64(HighGuid::ToolsClient) << 58) + | uint64(mapId)), + uint64((uint64(serverId & 0xFFFFFF) << 40) + | (counter & UI64LIT(0xFFFFFFFFFF)))); +} + +ObjectGuid ObjectGuidFactory::CreateWorldLayer(uint32 arg1, uint16 arg2, uint8 arg3, uint32 arg4) +{ + return ObjectGuid(uint64((uint64(HighGuid::WorldLayer) << 58) + | (uint64(arg1 & 0xFFFFFFFF) << 10) + | (uint64(arg2 & 0x1FF))), + uint64((uint64(arg3 & 0xFF) << 24) + | uint64(arg4 & 0x7FFFFF))); +} + ObjectGuid const ObjectGuid::Empty = ObjectGuid(); ObjectGuid const ObjectGuid::FromStringFailed = ObjectGuid::Create<HighGuid::Uniq>(UI64LIT(4)); ObjectGuid const ObjectGuid::TradeItem = ObjectGuid::Create<HighGuid::Uniq>(UI64LIT(10)); @@ -762,3 +816,6 @@ template class TC_GAME_API ObjectGuidGenerator<HighGuid::ClientSession>; template class TC_GAME_API ObjectGuidGenerator<HighGuid::Cast>; template class TC_GAME_API ObjectGuidGenerator<HighGuid::ClientConnection>; template class TC_GAME_API ObjectGuidGenerator<HighGuid::ClubFinder>; +template class TC_GAME_API ObjectGuidGenerator<HighGuid::ToolsClient>; +template class TC_GAME_API ObjectGuidGenerator<HighGuid::WorldLayer>; +template class TC_GAME_API ObjectGuidGenerator<HighGuid::ArenaTeam>; diff --git a/src/server/game/Entities/Object/ObjectGuid.h b/src/server/game/Entities/Object/ObjectGuid.h index b2422071420..7a49c7c95f1 100644 --- a/src/server/game/Entities/Object/ObjectGuid.h +++ b/src/server/game/Entities/Object/ObjectGuid.h @@ -120,6 +120,9 @@ enum class HighGuid Cast = 47, ClientConnection = 48, ClubFinder = 49, + ToolsClient = 50, + WorldLayer = 51, + ArenaTeam = 52, Count, }; @@ -152,6 +155,8 @@ enum class ObjectGuidFormatType LFGList, Client, ClubFinder, + ToolsClient, + WorldLayer, }; template<HighGuid high> @@ -218,6 +223,9 @@ MAKE_GUID_TRAIT(HighGuid::ClientSession, ObjectGuidSequenceSource::Realm, Object MAKE_GUID_TRAIT(HighGuid::Cast, ObjectGuidSequenceSource::Map, ObjectGuidFormatType::WorldObject); MAKE_GUID_TRAIT(HighGuid::ClientConnection, ObjectGuidSequenceSource::Realm, ObjectGuidFormatType::Client); MAKE_GUID_TRAIT(HighGuid::ClubFinder, ObjectGuidSequenceSource::Global, ObjectGuidFormatType::ClubFinder); +MAKE_GUID_TRAIT(HighGuid::ToolsClient, ObjectGuidSequenceSource::Realm, ObjectGuidFormatType::ToolsClient); +MAKE_GUID_TRAIT(HighGuid::WorldLayer, ObjectGuidSequenceSource::Global, ObjectGuidFormatType::WorldLayer); +MAKE_GUID_TRAIT(HighGuid::ArenaTeam, ObjectGuidSequenceSource::Realm, ObjectGuidFormatType::Guild); class ByteBuffer; class ObjectGuid; @@ -234,13 +242,15 @@ public: static ObjectGuid CreateClientActor(uint16 ownerType, uint16 ownerId, uint32 counter); static ObjectGuid CreateChatChannel(uint32 realmId, bool builtIn, bool trade, uint16 zoneId, uint8 factionGroupMask, uint64 counter); static ObjectGuid CreateGlobal(HighGuid type, uint64 dbIdHigh, uint64 dbId); - static ObjectGuid CreateGuild(uint32 realmId, uint64 dbId); + static ObjectGuid CreateGuild(HighGuid type, uint32 realmId, uint64 dbId); static ObjectGuid CreateMobileSession(uint32 realmId, uint16 arg1, uint64 counter); static ObjectGuid CreateWebObj(uint32 realmId, uint8 arg1, uint8 arg2, uint64 counter); static ObjectGuid CreateLFGObject(uint8 arg1, uint8 arg2, uint8 arg3, uint8 arg4, bool arg5, uint8 arg6, uint64 counter); static ObjectGuid CreateLFGList(uint8 arg1, uint64 counter); static ObjectGuid CreateClient(HighGuid type, uint32 realmId, uint32 arg1, uint64 counter); static ObjectGuid CreateClubFinder(uint32 realmId, uint8 type, uint32 clubFinderId, uint64 dbId); + static ObjectGuid CreateToolsClient(uint16 mapId, uint32 serverId, uint64 counter); + static ObjectGuid CreateWorldLayer(uint32 arg1, uint16 arg2, uint8 arg3, uint32 arg4); }; #pragma pack(push, 1) @@ -349,13 +359,15 @@ class TC_GAME_API ObjectGuid template<HighGuid type> static std::enable_if_t<ObjectGuidTraits<type>::Format::value == ObjectGuidFormatType::ClientActor, ObjectGuid> Create(uint16 ownerType, uint16 ownerId, uint32 counter) { return ObjectGuidFactory::CreateClientActor(ownerType, ownerId, counter); } template<HighGuid type> static std::enable_if_t<ObjectGuidTraits<type>::Format::value == ObjectGuidFormatType::ChatChannel, ObjectGuid> Create(bool builtIn, bool trade, uint16 zoneId, uint8 factionGroupMask, ObjectGuid::LowType counter) { return ObjectGuidFactory::CreateChatChannel(0, builtIn, trade, zoneId, factionGroupMask, counter); } template<HighGuid type> static std::enable_if_t<ObjectGuidTraits<type>::Format::value == ObjectGuidFormatType::Global, ObjectGuid> Create(ObjectGuid::LowType dbId) { return ObjectGuidFactory::CreateGlobal(type, UI64LIT(0), dbId); } - template<HighGuid type> static std::enable_if_t<ObjectGuidTraits<type>::Format::value == ObjectGuidFormatType::Guild, ObjectGuid> Create(ObjectGuid::LowType dbId) { return ObjectGuidFactory::CreateGuild(0, dbId); } + template<HighGuid type> static std::enable_if_t<ObjectGuidTraits<type>::Format::value == ObjectGuidFormatType::Guild, ObjectGuid> Create(ObjectGuid::LowType dbId) { return ObjectGuidFactory::CreateGuild(type, 0, dbId); } template<HighGuid type> static std::enable_if_t<ObjectGuidTraits<type>::Format::value == ObjectGuidFormatType::MobileSession, ObjectGuid> Create(uint16 arg1, ObjectGuid::LowType counter) { return ObjectGuidFactory::CreateMobileSession(0, arg1, counter); } template<HighGuid type> static std::enable_if_t<ObjectGuidTraits<type>::Format::value == ObjectGuidFormatType::WebObj, ObjectGuid> Create(uint8 arg1, uint8 arg2, ObjectGuid::LowType counter) { return ObjectGuidFactory::CreateWebObj(0, arg1, arg2, counter); } template<HighGuid type> static std::enable_if_t<ObjectGuidTraits<type>::Format::value == ObjectGuidFormatType::LFGObject, ObjectGuid> Create(uint8 arg1, uint8 arg2, uint8 arg3, uint8 arg4, bool arg5, uint8 arg6, ObjectGuid::LowType counter) { return ObjectGuidFactory::CreateLFGObject(arg1, arg2, arg3, arg4, arg5, arg6, counter); } template<HighGuid type> static std::enable_if_t<ObjectGuidTraits<type>::Format::value == ObjectGuidFormatType::LFGList, ObjectGuid> Create(uint8 arg1, ObjectGuid::LowType counter) { return ObjectGuidFactory::CreateLFGList(arg1, counter); } template<HighGuid type> static std::enable_if_t<ObjectGuidTraits<type>::Format::value == ObjectGuidFormatType::Client, ObjectGuid> Create(uint32 arg1, ObjectGuid::LowType counter) { return ObjectGuidFactory::CreateClient(type, 0, arg1, counter); } template<HighGuid type> static std::enable_if_t<ObjectGuidTraits<type>::Format::value == ObjectGuidFormatType::ClubFinder, ObjectGuid> Create(uint8 clubType, uint32 clubFinderId, ObjectGuid::LowType dbId) { return ObjectGuidFactory::CreateClubFinder(0, clubType, clubFinderId, dbId); } + template<HighGuid type> static std::enable_if_t<ObjectGuidTraits<type>::Format::value == ObjectGuidFormatType::ToolsClient, ObjectGuid> Create(uint16 mapId, uint32 serverId, ObjectGuid::LowType counter) { return ObjectGuidFactory::CreateToolsClient(mapId, serverId, counter); } + template<HighGuid type> static std::enable_if_t<ObjectGuidTraits<type>::Format::value == ObjectGuidFormatType::WorldLayer, ObjectGuid> Create(uint32 arg1, uint16 arg2, uint8 arg3, uint32 arg4) { return ObjectGuidFactory::CreateWorldLayer(arg1, arg2, arg3, arg4); } protected: ObjectGuid(uint64 high, uint64 low) |