mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Entities: Make ObjectGuid formattable with fmt without using ToString()
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "Realm.h"
|
||||
#include "Util.h"
|
||||
#include "World.h"
|
||||
#include <charconv>
|
||||
|
||||
static_assert(sizeof(ObjectGuid) == sizeof(uint64) * 2, "ObjectGuid must be exactly 16 bytes");
|
||||
|
||||
@@ -31,54 +32,108 @@ namespace
|
||||
struct ObjectGuidInfo
|
||||
{
|
||||
std::string Names[AsUnderlyingType(HighGuid::Count)];
|
||||
std::string(ObjectGuidInfo::*ClientFormatFunction[AsUnderlyingType(HighGuid::Count)])(char const* typeName, ObjectGuid guid);
|
||||
ObjectGuid(ObjectGuidInfo::*ClientParseFunction[AsUnderlyingType(HighGuid::Count)])(HighGuid type, char const* guidString);
|
||||
fmt::appender(*ClientFormatFunction[AsUnderlyingType(HighGuid::Count)])(fmt::format_context& ctx, std::string const& typeName, ObjectGuid const& guid);
|
||||
ObjectGuid(*ClientParseFunction[AsUnderlyingType(HighGuid::Count)])(HighGuid type, std::string_view guidString);
|
||||
|
||||
std::string Format(ObjectGuid guid)
|
||||
static std::string Format(ObjectGuid const& guid)
|
||||
{
|
||||
if (guid.GetHigh() >= HighGuid::Count)
|
||||
return "Uniq-WOWGUID_TO_STRING_FAILED";
|
||||
|
||||
int32 type = AsUnderlyingType(guid.GetHigh());
|
||||
if (!ClientFormatFunction[type])
|
||||
return "Uniq-WOWGUID_TO_STRING_FAILED";
|
||||
|
||||
return (this->*ClientFormatFunction[type])(Names[type].c_str(), guid);
|
||||
return Trinity::StringFormat("{}", guid);
|
||||
}
|
||||
|
||||
ObjectGuid Parse(std::string const& guidString)
|
||||
ObjectGuid Parse(std::string_view guidString) const
|
||||
{
|
||||
std::size_t typeEnd = guidString.find('-');
|
||||
if (typeEnd == std::string::npos)
|
||||
return ObjectGuid::FromStringFailed;
|
||||
|
||||
int32 type = 0;
|
||||
for (; type < AsUnderlyingType(HighGuid::Count); ++type)
|
||||
{
|
||||
if (Names[type].length() < typeEnd)
|
||||
continue;
|
||||
|
||||
if (guidString.compare(0, typeEnd, Names[type]) == 0)
|
||||
break;
|
||||
if (guidString == "0000000000000000")
|
||||
return ObjectGuid::Empty;
|
||||
return ObjectGuid::FromStringFailed;
|
||||
}
|
||||
|
||||
if (type >= AsUnderlyingType(HighGuid::Count))
|
||||
return ObjectGuid::FromStringFailed;
|
||||
std::string_view typeStr = guidString.substr(0, typeEnd);
|
||||
guidString.remove_prefix(typeEnd + 1);
|
||||
|
||||
return (this->*ClientParseFunction[type])(HighGuid(type), &guidString[typeEnd + 1]);
|
||||
// find correct parser for type name
|
||||
for (int32 type = 0; type < AsUnderlyingType(HighGuid::Count); ++type)
|
||||
if (typeStr == Names[type])
|
||||
return ClientParseFunction[type](HighGuid(type), guidString);
|
||||
|
||||
return ObjectGuid::FromStringFailed;
|
||||
}
|
||||
|
||||
std::string FormatNull(char const*, ObjectGuid)
|
||||
struct FormatPadding { std::ptrdiff_t Value; constexpr operator std::ptrdiff_t() const { return Value; } };
|
||||
|
||||
template <std::ptrdiff_t Width>
|
||||
static constexpr inline FormatPadding padding{ .Value = Width };
|
||||
static constexpr inline FormatPadding no_padding{ .Value = 0 };
|
||||
|
||||
struct FormatBase { int32 Value; constexpr operator int32() const { return Value; } };
|
||||
|
||||
static constexpr inline FormatBase dec{ 10 };
|
||||
static constexpr inline FormatBase hex{ 16 };
|
||||
|
||||
static fmt::appender AppendTypeName(fmt::format_context& ctx, std::string const& type)
|
||||
{
|
||||
return "0000000000000000";
|
||||
return std::copy(type.begin(), type.end(), ctx.out());
|
||||
}
|
||||
|
||||
ObjectGuid ParseNull(HighGuid, char const*)
|
||||
template <FormatPadding Width, FormatBase Base>
|
||||
static fmt::appender AppendComponent(fmt::format_context& ctx, uint64 component)
|
||||
{
|
||||
*ctx.out() = '-';
|
||||
|
||||
std::array<char, 20> buf;
|
||||
auto [end, err] = std::to_chars(buf.data(), buf.data() + buf.size(), component, Base);
|
||||
|
||||
ASSERT_NODEBUGINFO(err == std::errc(), "Failed to convert guid part to string");
|
||||
|
||||
if constexpr (Width != 0)
|
||||
{
|
||||
if (std::distance(buf.data(), end) < Width)
|
||||
std::fill_n(ctx.out(), Width - std::distance(buf.data(), end), '0');
|
||||
}
|
||||
|
||||
return std::transform(buf.data(), end, ctx.out(), charToUpper);
|
||||
}
|
||||
|
||||
static fmt::appender AppendComponent(fmt::format_context& ctx, std::string_view component)
|
||||
{
|
||||
*ctx.out() = '-';
|
||||
return std::copy(component.begin(), component.end(), ctx.out());
|
||||
}
|
||||
|
||||
template <FormatBase Base, typename T>
|
||||
static bool ParseComponent(std::string_view& input, T* component)
|
||||
{
|
||||
auto [end, err] = std::from_chars(input.data(), input.data() + input.length(), *component, Base);
|
||||
if (err != std::errc())
|
||||
return false;
|
||||
|
||||
input.remove_prefix(end - input.data());
|
||||
if (!input.empty())
|
||||
{
|
||||
if (input[0] != '-')
|
||||
return false;
|
||||
|
||||
input.remove_prefix(1);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool ParseDone(std::string_view const& sv) { return sv.empty(); }
|
||||
|
||||
static fmt::appender FormatNull(fmt::format_context& ctx, std::string const& /*typeName*/, ObjectGuid const& /*guid*/)
|
||||
{
|
||||
return std::fill_n(ctx.out(), 16, '0');
|
||||
}
|
||||
|
||||
static ObjectGuid ParseNull(HighGuid, std::string_view)
|
||||
{
|
||||
return ObjectGuid::Empty;
|
||||
}
|
||||
|
||||
std::string FormatUniq(char const* typeName, ObjectGuid guid)
|
||||
static fmt::appender FormatUniq(fmt::format_context& ctx, std::string const& typeName, ObjectGuid const& guid)
|
||||
{
|
||||
constexpr char const* uniqNames[] =
|
||||
{
|
||||
@@ -105,13 +160,15 @@ namespace
|
||||
};
|
||||
|
||||
ObjectGuid::LowType id = guid.GetCounter();
|
||||
if (id >= std::size(uniqNames))
|
||||
if (id >= std::size(uniqNames) || !uniqNames[id])
|
||||
id = 3;
|
||||
|
||||
return Trinity::StringFormat("{}-{}", typeName, uniqNames[id]);
|
||||
ctx.advance_to(AppendTypeName(ctx, typeName));
|
||||
ctx.advance_to(AppendComponent(ctx, uniqNames[id]));
|
||||
return ctx.out();
|
||||
}
|
||||
|
||||
ObjectGuid ParseUniq(HighGuid /*type*/, char const* guidString)
|
||||
static ObjectGuid ParseUniq(HighGuid /*type*/, std::string_view guidString)
|
||||
{
|
||||
constexpr char const* uniqNames[] =
|
||||
{
|
||||
@@ -132,7 +189,9 @@ namespace
|
||||
"WOWGUID_FAKE_MODERATOR",
|
||||
nullptr,
|
||||
nullptr,
|
||||
"WOWGUID_UNIQUE_ACCOUNT_OBJ_INITIALIZATION"
|
||||
"WOWGUID_UNIQUE_ACCOUNT_OBJ_INITIALIZATION",
|
||||
nullptr,
|
||||
"WOWGUID_PENDING_PERMANENT_CHARACTER_ASSIGNMENT"
|
||||
};
|
||||
|
||||
for (std::size_t id = 0; id < std::size(uniqNames); ++id)
|
||||
@@ -140,334 +199,480 @@ namespace
|
||||
if (!uniqNames[id])
|
||||
continue;
|
||||
|
||||
if (strcmp(guidString, uniqNames[id]) == 0)
|
||||
if (guidString == uniqNames[id])
|
||||
return ObjectGuidFactory::CreateUniq(id);
|
||||
}
|
||||
|
||||
return ObjectGuid::FromStringFailed;
|
||||
}
|
||||
|
||||
std::string FormatPlayer(char const* typeName, ObjectGuid guid)
|
||||
static fmt::appender FormatPlayer(fmt::format_context& ctx, std::string const& typeName, ObjectGuid const& guid)
|
||||
{
|
||||
return Trinity::StringFormat("{}-{}-{:08X}", typeName, guid.GetRealmId(), guid.GetRawValue(0));
|
||||
ctx.advance_to(AppendTypeName(ctx, typeName));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRealmId()));
|
||||
ctx.advance_to(AppendComponent<padding<8>, hex>(ctx, guid.GetRawValue(0)));
|
||||
return ctx.out();
|
||||
}
|
||||
|
||||
ObjectGuid ParsePlayer(HighGuid /*type*/, char const* guidString)
|
||||
static ObjectGuid ParsePlayer(HighGuid /*type*/, std::string_view guidString)
|
||||
{
|
||||
uint32 realmId = 0;
|
||||
uint64 dbId = UI64LIT(0);
|
||||
|
||||
if (std::sscanf(guidString, "%u-%08" SCNx64, &realmId, &dbId) != 2)
|
||||
if (!ParseComponent<dec>(guidString, &realmId)
|
||||
|| !ParseComponent<hex>(guidString, &dbId)
|
||||
|| !ParseDone(guidString))
|
||||
return ObjectGuid::FromStringFailed;
|
||||
|
||||
return ObjectGuidFactory::CreatePlayer(realmId, dbId);
|
||||
}
|
||||
|
||||
std::string FormatItem(char const* typeName, ObjectGuid guid)
|
||||
static fmt::appender FormatItem(fmt::format_context& ctx, std::string const& typeName, ObjectGuid const& guid)
|
||||
{
|
||||
return Trinity::StringFormat("{}-{}-{}-{:016X}", typeName, guid.GetRealmId(), uint32(guid.GetRawValue(1) >> 18) & 0xFFFFFF, guid.GetRawValue(0));
|
||||
ctx.advance_to(AppendTypeName(ctx, typeName));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRealmId()));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRawValue(1) >> 18 & 0xFFFFFF));
|
||||
ctx.advance_to(AppendComponent<padding<16>, hex>(ctx, guid.GetRawValue(0)));
|
||||
return ctx.out();
|
||||
}
|
||||
|
||||
ObjectGuid ParseItem(HighGuid /*type*/, char const* guidString)
|
||||
static ObjectGuid ParseItem(HighGuid /*type*/, std::string_view guidString)
|
||||
{
|
||||
uint32 realmId = 0;
|
||||
uint32 arg1 = 0;
|
||||
uint64 dbId = UI64LIT(0);
|
||||
|
||||
if (std::sscanf(guidString, "%u-%u-%016" SCNx64, &realmId, &arg1, &dbId) != 3)
|
||||
if (!ParseComponent<dec>(guidString, &realmId)
|
||||
|| !ParseComponent<dec>(guidString, &arg1)
|
||||
|| !ParseComponent<hex>(guidString, &dbId)
|
||||
|| !ParseDone(guidString))
|
||||
return ObjectGuid::FromStringFailed;
|
||||
|
||||
return ObjectGuidFactory::CreateItem(realmId, dbId);
|
||||
}
|
||||
|
||||
std::string FormatWorldObject(char const* typeName, ObjectGuid guid)
|
||||
static fmt::appender FormatWorldObject(fmt::format_context& ctx, std::string const& typeName, ObjectGuid const& guid)
|
||||
{
|
||||
return Trinity::StringFormat("{}-{}-{}-{}-{}-{}-{:010X}", typeName, guid.GetSubType(), guid.GetRealmId(), guid.GetMapId(),
|
||||
uint32(guid.GetRawValue(0) >> 40) & 0xFFFFFF, guid.GetEntry(), guid.GetCounter());
|
||||
ctx.advance_to(AppendTypeName(ctx, typeName));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetSubType()));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRealmId()));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetMapId()));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRawValue(0) >> 40 & 0xFFFFFF));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetEntry()));
|
||||
ctx.advance_to(AppendComponent<padding<10>, hex>(ctx, guid.GetCounter()));
|
||||
return ctx.out();
|
||||
}
|
||||
|
||||
ObjectGuid ParseWorldObject(HighGuid type, char const* guidString)
|
||||
static ObjectGuid ParseWorldObject(HighGuid type, std::string_view guidString)
|
||||
{
|
||||
uint32 subType = 0;
|
||||
uint8 subType = 0;
|
||||
uint32 realmId = 0;
|
||||
uint32 mapId = 0;
|
||||
uint16 mapId = 0;
|
||||
uint32 serverId = 0;
|
||||
uint32 id = 0;
|
||||
uint64 counter = UI64LIT(0);
|
||||
if (std::sscanf(guidString, "%u-%u-%u-%u-%u-%010" SCNx64, &subType, &realmId, &mapId, &serverId, &id, &counter) != 6)
|
||||
|
||||
if (!ParseComponent<dec>(guidString, &subType)
|
||||
|| !ParseComponent<dec>(guidString, &realmId)
|
||||
|| !ParseComponent<dec>(guidString, &mapId)
|
||||
|| !ParseComponent<dec>(guidString, &serverId)
|
||||
|| !ParseComponent<dec>(guidString, &id)
|
||||
|| !ParseComponent<hex>(guidString, &counter)
|
||||
|| !ParseDone(guidString))
|
||||
return ObjectGuid::FromStringFailed;
|
||||
|
||||
return ObjectGuidFactory::CreateWorldObject(type, subType, realmId, mapId, serverId, id, counter);
|
||||
}
|
||||
|
||||
std::string FormatTransport(char const* typeName, ObjectGuid guid)
|
||||
static fmt::appender FormatTransport(fmt::format_context& ctx, std::string const& typeName, ObjectGuid const& guid)
|
||||
{
|
||||
return Trinity::StringFormat("{}-{}-{:016X}", typeName, uint32(guid.GetRawValue(1) >> 38) & 0xFFFFF, guid.GetRawValue(0));
|
||||
ctx.advance_to(AppendTypeName(ctx, typeName));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetEntry()));
|
||||
ctx.advance_to(AppendComponent<padding<16>, hex>(ctx, guid.GetRawValue(0)));
|
||||
return ctx.out();
|
||||
}
|
||||
|
||||
ObjectGuid ParseTransport(HighGuid type, char const* guidString)
|
||||
static ObjectGuid ParseTransport(HighGuid type, std::string_view guidString)
|
||||
{
|
||||
uint32 id = 0;
|
||||
uint64 counter = UI64LIT(0);
|
||||
uint32 counter = 0;
|
||||
|
||||
if (std::sscanf(guidString, "%u-%016" SCNx64, &id, &counter) != 2)
|
||||
if (!ParseComponent<dec>(guidString, &id)
|
||||
|| !ParseComponent<hex>(guidString, &counter)
|
||||
|| !ParseDone(guidString))
|
||||
return ObjectGuid::FromStringFailed;
|
||||
|
||||
return ObjectGuidFactory::CreateTransport(type, counter);
|
||||
}
|
||||
|
||||
std::string FormatClientActor(char const* typeName, ObjectGuid guid)
|
||||
static fmt::appender FormatClientActor(fmt::format_context& ctx, std::string const& typeName, ObjectGuid const& guid)
|
||||
{
|
||||
return Trinity::StringFormat("{}-{}-{}-{}", typeName, guid.GetRealmId(), uint32(guid.GetRawValue(1) >> 26) & 0xFFFFFF, uint32(guid.GetRawValue(0)));
|
||||
ctx.advance_to(AppendTypeName(ctx, typeName));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRealmId()));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRawValue(1) >> 26 & 0xFFFFFF));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRawValue(0) & 0xFFFFFFFF));
|
||||
return ctx.out();
|
||||
}
|
||||
|
||||
ObjectGuid ParseClientActor(HighGuid /*type*/, char const* guidString)
|
||||
static ObjectGuid ParseClientActor(HighGuid /*type*/, std::string_view guidString)
|
||||
{
|
||||
uint32 ownerType = 0;
|
||||
uint32 ownerId = 0;
|
||||
uint16 ownerType = 0;
|
||||
uint16 ownerId = 0;
|
||||
uint32 counter = 0;
|
||||
|
||||
if (std::sscanf(guidString, "%u-%u-%u", &ownerType, &ownerId, &counter) != 3)
|
||||
if (!ParseComponent<dec>(guidString, &ownerType)
|
||||
|| !ParseComponent<dec>(guidString, &ownerId)
|
||||
|| !ParseComponent<dec>(guidString, &counter)
|
||||
|| !ParseDone(guidString))
|
||||
return ObjectGuid::FromStringFailed;
|
||||
|
||||
return ObjectGuidFactory::CreateClientActor(ownerType, ownerId, counter);
|
||||
}
|
||||
|
||||
std::string FormatChatChannel(char const* typeName, ObjectGuid guid)
|
||||
static fmt::appender FormatChatChannel(fmt::format_context& ctx, std::string const& typeName, ObjectGuid const& guid)
|
||||
{
|
||||
uint32 builtIn = (guid.GetRawValue(1) >> 25) & 0x1;
|
||||
uint32 trade = (guid.GetRawValue(1) >> 24) & 0x1;
|
||||
uint32 zoneId = (guid.GetRawValue(1) >> 10) & 0x3FFF;
|
||||
uint32 factionGroupMask = (guid.GetRawValue(1) >> 4) & 0x3F;
|
||||
return Trinity::StringFormat("{}-{}-{}-{}-{}-{}-{:08X}", typeName, guid.GetRealmId(), builtIn, trade, zoneId, factionGroupMask, guid.GetRawValue(0));
|
||||
|
||||
ctx.advance_to(AppendTypeName(ctx, typeName));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRealmId()));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, builtIn));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, trade));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, zoneId));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, factionGroupMask));
|
||||
ctx.advance_to(AppendComponent<padding<8>, hex>(ctx, guid.GetRawValue(0)));
|
||||
return ctx.out();
|
||||
}
|
||||
|
||||
ObjectGuid ParseChatChannel(HighGuid /*type*/, char const* guidString)
|
||||
static ObjectGuid ParseChatChannel(HighGuid /*type*/, std::string_view guidString)
|
||||
{
|
||||
uint32 realmId = 0;
|
||||
uint32 builtIn = 0;
|
||||
uint32 trade = 0;
|
||||
uint32 zoneId = 0;
|
||||
uint32 factionGroupMask = 0;
|
||||
uint16 zoneId = 0;
|
||||
uint8 factionGroupMask = 0;
|
||||
uint64 id = UI64LIT(0);
|
||||
|
||||
if (std::sscanf(guidString, "%u-%u-%u-%u-%u-%08" SCNx64, &realmId, &builtIn, &trade, &zoneId, &factionGroupMask, &id) != 6)
|
||||
if (!ParseComponent<dec>(guidString, &realmId)
|
||||
|| !ParseComponent<dec>(guidString, &builtIn)
|
||||
|| !ParseComponent<dec>(guidString, &trade)
|
||||
|| !ParseComponent<dec>(guidString, &zoneId)
|
||||
|| !ParseComponent<dec>(guidString, &factionGroupMask)
|
||||
|| !ParseComponent<hex>(guidString, &id)
|
||||
|| !ParseDone(guidString))
|
||||
return ObjectGuid::FromStringFailed;
|
||||
|
||||
return ObjectGuidFactory::CreateChatChannel(realmId, builtIn != 0, trade != 0, zoneId, factionGroupMask, id);
|
||||
}
|
||||
|
||||
std::string FormatGlobal(char const* typeName, ObjectGuid guid)
|
||||
static fmt::appender FormatGlobal(fmt::format_context& ctx, std::string const& typeName, ObjectGuid const& guid)
|
||||
{
|
||||
return Trinity::StringFormat("{}-{}-{:012X}", typeName, guid.GetRawValue(1) & 0x3FFFFFFFFFFFFFF, guid.GetRawValue(0));
|
||||
ctx.advance_to(AppendTypeName(ctx, typeName));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRawValue(1) & 0x3FFFFFFFFFFFFFF));
|
||||
ctx.advance_to(AppendComponent<padding<12>, hex>(ctx, guid.GetRawValue(0)));
|
||||
return ctx.out();
|
||||
}
|
||||
|
||||
ObjectGuid ParseGlobal(HighGuid type, char const* guidString)
|
||||
static ObjectGuid ParseGlobal(HighGuid type, std::string_view guidString)
|
||||
{
|
||||
uint64 dbIdHigh = UI64LIT(0);
|
||||
uint64 dbIdLow = UI64LIT(0);
|
||||
|
||||
if (std::sscanf(guidString, "%" SCNu64 "-%012" SCNx64, &dbIdHigh, &dbIdLow) != 2)
|
||||
if (!ParseComponent<dec>(guidString, &dbIdHigh)
|
||||
|| !ParseComponent<hex>(guidString, &dbIdLow)
|
||||
|| !ParseDone(guidString))
|
||||
return ObjectGuid::FromStringFailed;
|
||||
|
||||
return ObjectGuidFactory::CreateGlobal(type, dbIdHigh, dbIdLow);
|
||||
}
|
||||
|
||||
std::string FormatGuild(char const* typeName, ObjectGuid guid)
|
||||
static fmt::appender FormatGuild(fmt::format_context& ctx, std::string const& typeName, ObjectGuid const& guid)
|
||||
{
|
||||
return Trinity::StringFormat("{}-{}-{:012X}", typeName, guid.GetRealmId(), guid.GetRawValue(0));
|
||||
ctx.advance_to(AppendTypeName(ctx, typeName));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRealmId()));
|
||||
ctx.advance_to(AppendComponent<padding<12>, hex>(ctx, guid.GetRawValue(0)));
|
||||
return ctx.out();
|
||||
}
|
||||
|
||||
ObjectGuid ParseGuild(HighGuid type, char const* guidString)
|
||||
static ObjectGuid ParseGuild(HighGuid type, std::string_view guidString)
|
||||
{
|
||||
uint32 realmId = 0;
|
||||
uint64 dbId = UI64LIT(0);
|
||||
|
||||
if (std::sscanf(guidString, "%u-%012" SCNx64, &realmId, &dbId) != 2)
|
||||
if (!ParseComponent<dec>(guidString, &realmId)
|
||||
|| !ParseComponent<hex>(guidString, &dbId)
|
||||
|| !ParseDone(guidString))
|
||||
return ObjectGuid::FromStringFailed;
|
||||
|
||||
return ObjectGuidFactory::CreateGuild(type, realmId, dbId);
|
||||
}
|
||||
|
||||
std::string FormatMobileSession(char const* typeName, ObjectGuid guid)
|
||||
static fmt::appender FormatMobileSession(fmt::format_context& ctx, std::string const& typeName, ObjectGuid const& guid)
|
||||
{
|
||||
return Trinity::StringFormat("{}-{}-{}-{:08X}", typeName, guid.GetRealmId(), uint32(guid.GetRawValue(1) >> 33) & 0x1FF, guid.GetRawValue(0));
|
||||
ctx.advance_to(AppendTypeName(ctx, typeName));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRealmId()));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRawValue(1) >> 33 & 0x1FF));
|
||||
ctx.advance_to(AppendComponent<padding<8>, hex>(ctx, guid.GetRawValue(0)));
|
||||
return ctx.out();
|
||||
}
|
||||
|
||||
ObjectGuid ParseMobileSession(HighGuid /*type*/, char const* guidString)
|
||||
static ObjectGuid ParseMobileSession(HighGuid /*type*/, std::string_view guidString)
|
||||
{
|
||||
uint32 realmId = 0;
|
||||
uint32 arg1 = 0;
|
||||
uint16 arg1 = 0;
|
||||
uint64 counter = UI64LIT(0);
|
||||
|
||||
if (std::sscanf(guidString, "%u-%u-%08" SCNx64, &realmId, &arg1, &counter) != 3)
|
||||
if (!ParseComponent<dec>(guidString, &realmId)
|
||||
|| !ParseComponent<dec>(guidString, &arg1)
|
||||
|| !ParseComponent<hex>(guidString, &counter)
|
||||
|| !ParseDone(guidString))
|
||||
return ObjectGuid::FromStringFailed;
|
||||
|
||||
return ObjectGuidFactory::CreateMobileSession(realmId, arg1, counter);
|
||||
}
|
||||
|
||||
std::string FormatWebObj(char const* typeName, ObjectGuid guid)
|
||||
static fmt::appender FormatWebObj(fmt::format_context& ctx, std::string const& typeName, ObjectGuid const& guid)
|
||||
{
|
||||
return Trinity::StringFormat("{}-{}-{}-{}-{:012X}", typeName, guid.GetRealmId(), uint32(guid.GetRawValue(1) >> 37) & 0x1F,
|
||||
uint32(guid.GetRawValue(1) >> 35) & 0x3, guid.GetRawValue(0));
|
||||
ctx.advance_to(AppendTypeName(ctx, typeName));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRealmId()));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRawValue(1) >> 37 & 0x1F));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRawValue(1) >> 35 & 0x3));
|
||||
ctx.advance_to(AppendComponent<padding<12>, hex>(ctx, guid.GetRawValue(0)));
|
||||
return ctx.out();
|
||||
}
|
||||
|
||||
ObjectGuid ParseWebObj(HighGuid /*type*/, char const* guidString)
|
||||
static ObjectGuid ParseWebObj(HighGuid /*type*/, std::string_view guidString)
|
||||
{
|
||||
uint32 realmId = 0;
|
||||
uint32 arg1 = 0;
|
||||
uint32 arg2 = 0;
|
||||
uint8 arg1 = 0;
|
||||
uint8 arg2 = 0;
|
||||
uint64 counter = UI64LIT(0);
|
||||
|
||||
if (std::sscanf(guidString, "%u-%u-%u-%012" SCNx64, &realmId, &arg1, &arg2, &counter) != 4)
|
||||
if (!ParseComponent<dec>(guidString, &realmId)
|
||||
|| !ParseComponent<dec>(guidString, &arg1)
|
||||
|| !ParseComponent<dec>(guidString, &arg2)
|
||||
|| !ParseComponent<hex>(guidString, &counter)
|
||||
|| !ParseDone(guidString))
|
||||
return ObjectGuid::FromStringFailed;
|
||||
|
||||
return ObjectGuidFactory::CreateWebObj(realmId, arg1, arg2, counter);
|
||||
}
|
||||
|
||||
std::string FormatLFGObject(char const* typeName, ObjectGuid guid)
|
||||
static fmt::appender FormatLFGObject(fmt::format_context& ctx, std::string const& typeName, ObjectGuid const& guid)
|
||||
{
|
||||
return Trinity::StringFormat("{}-{}-{}-{}-{}-{}-{}-{:06X}", typeName, uint32(guid.GetRawValue(1) >> 54) & 0xF, uint32(guid.GetRawValue(1) >> 50) & 0xF,
|
||||
uint32(guid.GetRawValue(1) >> 46) & 0xF, uint32(guid.GetRawValue(1) >> 38) & 0xFF, uint32(guid.GetRawValue(1) >> 37) & 0x1,
|
||||
uint32(guid.GetRawValue(1) >> 35) & 0x3, guid.GetRawValue(0));
|
||||
ctx.advance_to(AppendTypeName(ctx, typeName));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRawValue(1) >> 54 & 0xF));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRawValue(1) >> 50 & 0xF));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRawValue(1) >> 46 & 0xF));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRawValue(1) >> 38 & 0xFF));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRawValue(1) >> 37 & 0x1));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRawValue(1) >> 35 & 0x3));
|
||||
ctx.advance_to(AppendComponent<padding<6>, hex>(ctx, guid.GetRawValue(0)));
|
||||
return ctx.out();
|
||||
}
|
||||
|
||||
ObjectGuid ParseLFGObject(HighGuid /*type*/, char const* guidString)
|
||||
static ObjectGuid ParseLFGObject(HighGuid /*type*/, std::string_view guidString)
|
||||
{
|
||||
uint32 arg1 = 0;
|
||||
uint32 arg2 = 0;
|
||||
uint32 arg3 = 0;
|
||||
uint32 arg4 = 0;
|
||||
uint32 arg5 = 0;
|
||||
uint32 arg6 = 0;
|
||||
uint8 arg1 = 0;
|
||||
uint8 arg2 = 0;
|
||||
uint8 arg3 = 0;
|
||||
uint8 arg4 = 0;
|
||||
uint8 arg5 = 0;
|
||||
uint8 arg6 = 0;
|
||||
uint64 counter = UI64LIT(0);
|
||||
|
||||
if (std::sscanf(guidString, "%u-%u-%u-%u-%u-%u-%06" SCNx64, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &counter) != 7)
|
||||
if (!ParseComponent<dec>(guidString, &arg1)
|
||||
|| !ParseComponent<dec>(guidString, &arg2)
|
||||
|| !ParseComponent<dec>(guidString, &arg3)
|
||||
|| !ParseComponent<dec>(guidString, &arg4)
|
||||
|| !ParseComponent<dec>(guidString, &arg5)
|
||||
|| !ParseComponent<dec>(guidString, &arg6)
|
||||
|| !ParseComponent<hex>(guidString, &counter)
|
||||
|| !ParseDone(guidString))
|
||||
return ObjectGuid::FromStringFailed;
|
||||
|
||||
return ObjectGuidFactory::CreateLFGObject(arg1, arg2, arg3, arg4, arg5 != 0, arg6, counter);
|
||||
}
|
||||
|
||||
std::string FormatLFGList(char const* typeName, ObjectGuid guid)
|
||||
static fmt::appender FormatLFGList(fmt::format_context& ctx, std::string const& typeName, ObjectGuid const& guid)
|
||||
{
|
||||
return Trinity::StringFormat("{}-{}-{:06X}", typeName, uint32(guid.GetRawValue(1) >> 54) & 0xF, guid.GetRawValue(0));
|
||||
ctx.advance_to(AppendTypeName(ctx, typeName));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRawValue(1) >> 54 & 0xF));
|
||||
ctx.advance_to(AppendComponent<padding<6>, hex>(ctx, guid.GetRawValue(0)));
|
||||
return ctx.out();
|
||||
}
|
||||
|
||||
ObjectGuid ParseLFGList(HighGuid /*type*/, char const* guidString)
|
||||
static ObjectGuid ParseLFGList(HighGuid /*type*/, std::string_view guidString)
|
||||
{
|
||||
uint32 arg1 = 0;
|
||||
uint8 arg1 = 0;
|
||||
uint64 counter = UI64LIT(0);
|
||||
|
||||
if (std::sscanf(guidString, "%u-%06" SCNx64, &arg1, &counter) != 2)
|
||||
if (!ParseComponent<dec>(guidString, &arg1)
|
||||
|| !ParseComponent<hex>(guidString, &counter)
|
||||
|| !ParseDone(guidString))
|
||||
return ObjectGuid::FromStringFailed;
|
||||
|
||||
return ObjectGuidFactory::CreateLFGList(arg1, counter);
|
||||
}
|
||||
|
||||
std::string FormatClient(char const* typeName, ObjectGuid guid)
|
||||
static fmt::appender FormatClient(fmt::format_context& ctx, std::string const& typeName, ObjectGuid const& guid)
|
||||
{
|
||||
return Trinity::StringFormat("{}-{}-{}-{:012X}", typeName, guid.GetRealmId(), uint32(guid.GetRawValue(1) >> 10) & 0xFFFFFFFF, guid.GetRawValue(0));
|
||||
ctx.advance_to(AppendTypeName(ctx, typeName));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRealmId()));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRawValue(1) >> 10 & 0xFFFFFFFF));
|
||||
ctx.advance_to(AppendComponent<padding<12>, hex>(ctx, guid.GetRawValue(0)));
|
||||
return ctx.out();
|
||||
}
|
||||
|
||||
ObjectGuid ParseClient(HighGuid type, char const* guidString)
|
||||
static ObjectGuid ParseClient(HighGuid type, std::string_view guidString)
|
||||
{
|
||||
uint32 realmId = 0;
|
||||
uint32 arg1 = 0;
|
||||
uint64 counter = UI64LIT(0);
|
||||
|
||||
if (std::sscanf(guidString, "%u-%u-%012" SCNx64, &realmId, &arg1, &counter) != 3)
|
||||
if (!ParseComponent<dec>(guidString, &realmId)
|
||||
|| !ParseComponent<dec>(guidString, &arg1)
|
||||
|| !ParseComponent<hex>(guidString, &counter)
|
||||
|| !ParseDone(guidString))
|
||||
return ObjectGuid::FromStringFailed;
|
||||
|
||||
return ObjectGuidFactory::CreateClient(type, realmId, arg1, counter);
|
||||
}
|
||||
|
||||
std::string FormatClubFinder(char const* typeName, ObjectGuid guid)
|
||||
static fmt::appender FormatClubFinder(fmt::format_context& ctx, std::string const& typeName, ObjectGuid const& guid)
|
||||
{
|
||||
uint32 type = uint32(guid.GetRawValue(1) >> 33) & 0xFF;
|
||||
uint32 clubFinderId = uint32(guid.GetRawValue(1)) & 0xFFFFFFFF;
|
||||
if (type == 1) // guild
|
||||
return Trinity::StringFormat("{}-{}-{}-{}-{}", typeName, type, clubFinderId, guid.GetRealmId(), guid.GetRawValue(0) /*guildId*/);
|
||||
|
||||
return Trinity::StringFormat("{}-{}-{}-{:016X}", typeName, type, clubFinderId, guid.GetRawValue(0) /*clubId*/);
|
||||
ctx.advance_to(AppendTypeName(ctx, typeName));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, type));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, clubFinderId));
|
||||
switch (type)
|
||||
{
|
||||
case 0: // club
|
||||
ctx.advance_to(AppendComponent<padding<16>, hex>(ctx, guid.GetRawValue(0))); // clubId
|
||||
break;
|
||||
case 1: // guild
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRealmId()));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRawValue(0))); // guildId
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ctx.out();
|
||||
}
|
||||
|
||||
ObjectGuid ParseClubFinder(HighGuid /*type*/, char const* guidString)
|
||||
static ObjectGuid ParseClubFinder(HighGuid /*type*/, std::string_view guidString)
|
||||
{
|
||||
uint32 type = 0;
|
||||
uint32 consumed = 0;
|
||||
|
||||
if (std::sscanf(guidString, "%u-%n", &type, &consumed) != 1)
|
||||
return ObjectGuid::FromStringFailed;
|
||||
|
||||
uint8 type = 0;
|
||||
uint32 clubFinderId = 0;
|
||||
uint32 realmId = 0;
|
||||
uint64 dbId = UI64LIT(0);
|
||||
|
||||
if (!ParseComponent<dec>(guidString, &type)
|
||||
|| !ParseComponent<dec>(guidString, &clubFinderId))
|
||||
return ObjectGuid::FromStringFailed;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case 0: // club
|
||||
if (std::sscanf(guidString + consumed, "%u-%016" SCNx64, &clubFinderId, &dbId) != 2)
|
||||
if (!ParseComponent<hex>(guidString, &dbId))
|
||||
return ObjectGuid::FromStringFailed;
|
||||
break;
|
||||
case 1: // guild
|
||||
if (std::sscanf(guidString + consumed, "%u-%u-%016" SCNx64, &clubFinderId, &realmId, &dbId) != 3)
|
||||
if (!ParseComponent<dec>(guidString, &realmId)
|
||||
|| !ParseComponent<dec>(guidString, &dbId))
|
||||
return ObjectGuid::FromStringFailed;
|
||||
break;
|
||||
default:
|
||||
return ObjectGuid::FromStringFailed;
|
||||
}
|
||||
|
||||
if (!ParseDone(guidString))
|
||||
return ObjectGuid::FromStringFailed;
|
||||
|
||||
return ObjectGuidFactory::CreateClubFinder(realmId, type, clubFinderId, dbId);
|
||||
}
|
||||
|
||||
std::string FormatToolsClient(char const* typeName, ObjectGuid guid)
|
||||
static fmt::appender FormatToolsClient(fmt::format_context& ctx, std::string const& typeName, ObjectGuid const& guid)
|
||||
{
|
||||
return Trinity::StringFormat("{}-{}-{}-{:010X}", typeName, guid.GetMapId(), uint32(guid.GetRawValue(0) >> 40) & 0xFFFFFF, guid.GetCounter());
|
||||
ctx.advance_to(AppendTypeName(ctx, typeName));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetMapId()));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRawValue(0) >> 40 & 0xFFFFFF));
|
||||
ctx.advance_to(AppendComponent<padding<10>, hex>(ctx, guid.GetCounter()));
|
||||
return ctx.out();
|
||||
}
|
||||
|
||||
ObjectGuid ParseToolsClient(HighGuid /*type*/, char const* guidString)
|
||||
static ObjectGuid ParseToolsClient(HighGuid /*type*/, std::string_view guidString)
|
||||
{
|
||||
uint32 mapId = 0;
|
||||
uint16 mapId = 0;
|
||||
uint32 serverId = 0;
|
||||
uint64 counter = UI64LIT(0);
|
||||
if (std::sscanf(guidString, "%u-%u-%010" SCNx64, &mapId, &serverId, &counter) != 3)
|
||||
|
||||
if (!ParseComponent<dec>(guidString, &mapId)
|
||||
|| !ParseComponent<dec>(guidString, &serverId)
|
||||
|| !ParseComponent<hex>(guidString, &counter)
|
||||
|| !ParseDone(guidString))
|
||||
return ObjectGuid::FromStringFailed;
|
||||
|
||||
return ObjectGuidFactory::CreateToolsClient(mapId, serverId, counter);
|
||||
}
|
||||
|
||||
std::string FormatWorldLayer(char const* typeName, ObjectGuid guid)
|
||||
static fmt::appender FormatWorldLayer(fmt::format_context& ctx, std::string const& typeName, ObjectGuid const& guid)
|
||||
{
|
||||
return Trinity::StringFormat("{}-{:X}-{}-{}-{}", typeName, uint32((guid.GetRawValue(1) >> 10) & 0xFFFFFFFF), uint32(guid.GetRawValue(1) & 0x1FF),
|
||||
uint32((guid.GetRawValue(0) >> 24) & 0xFF), uint32(guid.GetRawValue(0) & 0x7FFFFF));
|
||||
ctx.advance_to(AppendTypeName(ctx, typeName));
|
||||
ctx.advance_to(AppendComponent<padding<0>, hex>(ctx, guid.GetRawValue(1) >> 10 & 0xFFFFFFFF));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRawValue(1) & 0x1FF));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRawValue(0) >> 24 & 0xFF));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRawValue(0) & 0x7FFFFF));
|
||||
return ctx.out();
|
||||
}
|
||||
|
||||
ObjectGuid ParseWorldLayer(HighGuid /*type*/, char const* guidString)
|
||||
static ObjectGuid ParseWorldLayer(HighGuid /*type*/, std::string_view 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)
|
||||
|
||||
if (!ParseComponent<hex>(guidString, &arg1)
|
||||
|| !ParseComponent<dec>(guidString, &arg2)
|
||||
|| !ParseComponent<dec>(guidString, &arg3)
|
||||
|| !ParseComponent<dec>(guidString, &arg4)
|
||||
|| !ParseDone(guidString))
|
||||
return ObjectGuid::FromStringFailed;
|
||||
|
||||
return ObjectGuidFactory::CreateWorldLayer(arg1, arg2, arg3, arg4);
|
||||
}
|
||||
|
||||
std::string FormatLMMLobby(char const* typeName, ObjectGuid guid)
|
||||
static fmt::appender FormatLMMLobby(fmt::format_context& ctx, std::string const& typeName, ObjectGuid const& guid)
|
||||
{
|
||||
return Trinity::StringFormat("{}-{}-{}-{}-{}-{:X}", typeName, guid.GetRealmId(), uint32(guid.GetRawValue(1) >> 26) & 0xFFFFFF,
|
||||
uint32(guid.GetRawValue(1) >> 18) & 0xFF, uint32(guid.GetRawValue(1) >> 10) & 0xFF, guid.GetRawValue(0));
|
||||
ctx.advance_to(AppendTypeName(ctx, typeName));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, guid.GetRealmId()));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, uint32(guid.GetRawValue(1) >> 26) & 0xFFFFFF));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, uint32(guid.GetRawValue(1) >> 18) & 0xFF));
|
||||
ctx.advance_to(AppendComponent<no_padding, dec>(ctx, uint32(guid.GetRawValue(1) >> 10) & 0xFF));
|
||||
ctx.advance_to(AppendComponent<padding<0>, hex>(ctx, guid.GetRawValue(0)));
|
||||
return ctx.out();
|
||||
}
|
||||
|
||||
ObjectGuid ParseLMMLobby(HighGuid /*type*/, char const* guidString)
|
||||
static ObjectGuid ParseLMMLobby(HighGuid /*type*/, std::string_view guidString)
|
||||
{
|
||||
uint32 realmId = 0;
|
||||
uint32 arg2 = 0;
|
||||
uint8 arg3 = 0;
|
||||
uint8 arg4 = 0;
|
||||
uint64 arg5 = 0;
|
||||
if (std::sscanf(guidString, "%u-%u-%hhu-%hhu-%" SCNx64, &realmId, &arg2, &arg3, &arg4, &arg5) != 5)
|
||||
|
||||
if (!ParseComponent<dec>(guidString, &realmId)
|
||||
|| !ParseComponent<dec>(guidString, &arg2)
|
||||
|| !ParseComponent<dec>(guidString, &arg3)
|
||||
|| !ParseComponent<dec>(guidString, &arg4)
|
||||
|| !ParseComponent<hex>(guidString, &arg5)
|
||||
|| !ParseDone(guidString))
|
||||
return ObjectGuid::FromStringFailed;
|
||||
|
||||
return ObjectGuidFactory::CreateLMMLobby(realmId, arg2, arg3, arg4, arg5);
|
||||
@@ -543,17 +748,32 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
char const* ObjectGuid::GetTypeName(HighGuid high)
|
||||
template <typename FormatContext>
|
||||
inline auto fmt::formatter<ObjectGuid>::format(ObjectGuid const& guid, FormatContext& ctx) const -> decltype(ctx.out())
|
||||
{
|
||||
if (guid.GetHigh() >= HighGuid::Count)
|
||||
return format(ObjectGuid::ToStringFailed, ctx);
|
||||
|
||||
int32 type = AsUnderlyingType(guid.GetHigh());
|
||||
if (!Info.ClientFormatFunction[type])
|
||||
return format(ObjectGuid::ToStringFailed, ctx);
|
||||
|
||||
return Info.ClientFormatFunction[type](ctx, Info.Names[type].c_str(), guid);
|
||||
}
|
||||
|
||||
template TC_GAME_API fmt::appender fmt::formatter<ObjectGuid>::format<fmt::format_context>(ObjectGuid const&, format_context&) const;
|
||||
|
||||
std::string_view ObjectGuid::GetTypeName(HighGuid high)
|
||||
{
|
||||
if (high >= HighGuid::Count)
|
||||
return "<unknown>";
|
||||
|
||||
return Info.Names[uint32(high)].c_str();
|
||||
return Info.Names[uint32(high)];
|
||||
}
|
||||
|
||||
std::string ObjectGuid::ToString() const
|
||||
{
|
||||
return Info.Format(*this);
|
||||
return ObjectGuidInfo::Format(*this);
|
||||
}
|
||||
|
||||
std::string ObjectGuid::ToHexString() const
|
||||
@@ -561,7 +781,7 @@ std::string ObjectGuid::ToHexString() const
|
||||
return Trinity::StringFormat("0x{:016X}{:016X}", _data[1], _data[0]);
|
||||
}
|
||||
|
||||
ObjectGuid ObjectGuid::FromString(std::string const& guidString)
|
||||
ObjectGuid ObjectGuid::FromString(std::string_view guidString)
|
||||
{
|
||||
return Info.Parse(guidString);
|
||||
}
|
||||
@@ -752,6 +972,7 @@ ObjectGuid ObjectGuidFactory::CreateLMMLobby(uint32 realmId, uint32 arg2, uint8
|
||||
}
|
||||
|
||||
ObjectGuid const ObjectGuid::Empty = ObjectGuid();
|
||||
ObjectGuid const ObjectGuid::ToStringFailed = ObjectGuid::Create<HighGuid::Uniq>(UI64LIT(3));
|
||||
ObjectGuid const ObjectGuid::FromStringFailed = ObjectGuid::Create<HighGuid::Uniq>(UI64LIT(4));
|
||||
ObjectGuid const ObjectGuid::TradeItem = ObjectGuid::Create<HighGuid::Uniq>(UI64LIT(10));
|
||||
|
||||
|
||||
@@ -272,6 +272,7 @@ class TC_GAME_API ObjectGuid
|
||||
|
||||
public:
|
||||
static ObjectGuid const Empty;
|
||||
static ObjectGuid const ToStringFailed;
|
||||
static ObjectGuid const FromStringFailed;
|
||||
static ObjectGuid const TradeItem;
|
||||
|
||||
@@ -349,11 +350,11 @@ class TC_GAME_API ObjectGuid
|
||||
return std::strong_ordering::equal;
|
||||
}
|
||||
|
||||
static char const* GetTypeName(HighGuid high);
|
||||
char const* GetTypeName() const { return !IsEmpty() ? GetTypeName(GetHigh()) : "None"; }
|
||||
static std::string_view GetTypeName(HighGuid high);
|
||||
std::string_view GetTypeName() const { return !IsEmpty() ? GetTypeName(GetHigh()) : "None"; }
|
||||
std::string ToString() const;
|
||||
std::string ToHexString() const;
|
||||
static ObjectGuid FromString(std::string const& guidString);
|
||||
static ObjectGuid FromString(std::string_view guidString);
|
||||
std::size_t GetHash() const;
|
||||
|
||||
template<HighGuid type> static std::enable_if_t<ObjectGuidTraits<type>::Format::value == ObjectGuidFormatType::Null, ObjectGuid> Create() { return ObjectGuidFactory::CreateNull(); }
|
||||
@@ -378,10 +379,8 @@ class TC_GAME_API ObjectGuid
|
||||
template<HighGuid type> static std::enable_if_t<ObjectGuidTraits<type>::Format::value == ObjectGuidFormatType::LMMLobby, ObjectGuid> Create(uint32 arg2, uint8 arg3, uint8 arg4, ObjectGuid::LowType counter) { return ObjectGuidFactory::CreateLMMLobby(0, arg2, arg3, arg4, counter); }
|
||||
|
||||
protected:
|
||||
ObjectGuid(uint64 high, uint64 low)
|
||||
ObjectGuid(uint64 high, uint64 low) : _data({{ low, high }})
|
||||
{
|
||||
_data[0] = low;
|
||||
_data[1] = high;
|
||||
}
|
||||
|
||||
std::array<uint64, 2> _data = { };
|
||||
@@ -428,6 +427,35 @@ namespace std
|
||||
};
|
||||
}
|
||||
|
||||
namespace fmt
|
||||
{
|
||||
inline namespace v9
|
||||
{
|
||||
template <typename T, typename Char, typename Enable>
|
||||
struct formatter;
|
||||
|
||||
template <>
|
||||
struct formatter<ObjectGuid, char, void>
|
||||
{
|
||||
template <typename ParseContext>
|
||||
constexpr auto parse(ParseContext& ctx) -> decltype(ctx.begin())
|
||||
{
|
||||
auto begin = ctx.begin(), end = ctx.end();
|
||||
if (begin == end)
|
||||
return begin;
|
||||
|
||||
if (*begin != '}')
|
||||
ctx.on_error("invalid type specifier");
|
||||
|
||||
return begin;
|
||||
}
|
||||
|
||||
template <typename FormatContext>
|
||||
auto format(ObjectGuid const& guid, FormatContext& ctx) const -> decltype(ctx.out());
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
namespace Trinity
|
||||
{
|
||||
namespace Legacy
|
||||
|
||||
@@ -577,7 +577,7 @@ void MotionMaster::MoveTargetedHome()
|
||||
Creature* owner = _owner->ToCreature();
|
||||
if (!owner)
|
||||
{
|
||||
TC_LOG_ERROR("movement.motionmaster", "MotionMaster::MoveTargetedHome: '{}', attempted to move towards target home.", _owner->GetGUID().ToString());
|
||||
TC_LOG_ERROR("movement.motionmaster", "MotionMaster::MoveTargetedHome: '{}', attempted to move towards target home.", _owner->GetGUID());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -586,12 +586,12 @@ void MotionMaster::MoveTargetedHome()
|
||||
Unit* target = owner->GetCharmerOrOwner();
|
||||
if (!target)
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveTargetedHome: '{}', targeted home.", _owner->GetGUID().ToString());
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveTargetedHome: '{}', targeted home.", _owner->GetGUID());
|
||||
Add(new HomeMovementGenerator<Creature>());
|
||||
}
|
||||
else
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveTargetedHome: '{}', starts following '{}'", _owner->GetGUID().ToString(), target->GetGUID().ToString());
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveTargetedHome: '{}', starts following '{}'", _owner->GetGUID(), target->GetGUID());
|
||||
Add(new FollowMovementGenerator(target, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE, {}));
|
||||
}
|
||||
}
|
||||
@@ -600,7 +600,7 @@ void MotionMaster::MoveRandom(float wanderDistance, Optional<Milliseconds> durat
|
||||
{
|
||||
if (_owner->GetTypeId() == TYPEID_UNIT)
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveRandom: '{}', started random movement (spawnDist: {})", _owner->GetGUID().ToString(), wanderDistance);
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveRandom: '{}', started random movement (spawnDist: {})", _owner->GetGUID(), wanderDistance);
|
||||
Add(new RandomMovementGenerator<Creature>(wanderDistance, duration), slot);
|
||||
}
|
||||
}
|
||||
@@ -611,7 +611,7 @@ void MotionMaster::MoveFollow(Unit* target, float dist, ChaseAngle angle, Option
|
||||
if (!target || target == _owner)
|
||||
return;
|
||||
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveFollow: '{}', starts following '{}'", _owner->GetGUID().ToString(), target->GetGUID().ToString());
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveFollow: '{}', starts following '{}'", _owner->GetGUID(), target->GetGUID());
|
||||
Add(new FollowMovementGenerator(target, dist, angle, duration), slot);
|
||||
}
|
||||
|
||||
@@ -621,7 +621,7 @@ void MotionMaster::MoveChase(Unit* target, Optional<ChaseRange> dist, Optional<C
|
||||
if (!target || target == _owner)
|
||||
return;
|
||||
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveChase: '{}', starts chasing '{}'", _owner->GetGUID().ToString(), target->GetGUID().ToString());
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveChase: '{}', starts chasing '{}'", _owner->GetGUID(), target->GetGUID());
|
||||
Add(new ChaseMovementGenerator(target, dist, angle));
|
||||
}
|
||||
|
||||
@@ -629,12 +629,12 @@ void MotionMaster::MoveConfused()
|
||||
{
|
||||
if (_owner->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveConfused: '{}', started confused movement.", _owner->GetGUID().ToString());
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveConfused: '{}', started confused movement.", _owner->GetGUID());
|
||||
Add(new ConfusedMovementGenerator<Player>());
|
||||
}
|
||||
else
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveConfused: '{}', started confused movement.", _owner->GetGUID().ToString());
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveConfused: '{}', started confused movement.", _owner->GetGUID());
|
||||
Add(new ConfusedMovementGenerator<Creature>());
|
||||
}
|
||||
}
|
||||
@@ -644,7 +644,7 @@ void MotionMaster::MoveFleeing(Unit* enemy, Milliseconds time /*= 0ms*/)
|
||||
if (!enemy)
|
||||
return;
|
||||
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveFleeing: '{}', flees from '{}' (time: {}ms)", _owner->GetGUID().ToString(), enemy->GetGUID().ToString(), time.count());
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveFleeing: '{}', flees from '{}' (time: {}ms)", _owner->GetGUID(), enemy->GetGUID(), time.count());
|
||||
if (_owner->GetTypeId() == TYPEID_UNIT && time > 0ms)
|
||||
Add(new TimedFleeingMovementGenerator(enemy->GetGUID(), time));
|
||||
else
|
||||
@@ -660,7 +660,7 @@ void MotionMaster::MovePoint(uint32 id, Position const& pos, bool generatePath/*
|
||||
void MotionMaster::MovePoint(uint32 id, float x, float y, float z, bool generatePath /*= true*/, Optional<float> finalOrient /*= {}*/, Optional<float> speed /*= {}*/,
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode /*= MovementWalkRunSpeedSelectionMode::Default*/, Optional<float> closeEnoughDistance /*= {}*/)
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MovePoint: '{}', targeted point Id: {} (X: {}, Y: {}, Z: {})", _owner->GetGUID().ToString(), id, x, y, z);
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MovePoint: '{}', targeted point Id: {} (X: {}, Y: {}, Z: {})", _owner->GetGUID(), id, x, y, z);
|
||||
Add(new PointMovementGenerator(id, x, y, z, generatePath, speed, finalOrient, nullptr, nullptr, speedSelectionMode, closeEnoughDistance));
|
||||
}
|
||||
|
||||
@@ -690,7 +690,7 @@ void MotionMaster::MoveCloserAndStop(uint32 id, Unit* target, float distance)
|
||||
void MotionMaster::MoveLand(uint32 id, Position const& pos, Optional<int32> tierTransitionId /*= {}*/, Optional<float> velocity /*= {}*/,
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode /*= MovementWalkRunSpeedSelectionMode::Default*/)
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveLand: '{}', landing point Id: {} (X: {}, Y: {}, Z: {})", _owner->GetGUID().ToString(), id, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ());
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveLand: '{}', landing point Id: {} (X: {}, Y: {}, Z: {})", _owner->GetGUID(), id, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ());
|
||||
|
||||
std::function<void(Movement::MoveSplineInit&)> initializer = [=](Movement::MoveSplineInit& init)
|
||||
{
|
||||
@@ -717,7 +717,7 @@ void MotionMaster::MoveLand(uint32 id, Position const& pos, Optional<int32> tier
|
||||
void MotionMaster::MoveTakeoff(uint32 id, Position const& pos, Optional<int32> tierTransitionId /*= {}*/, Optional<float> velocity /*= {}*/,
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode /*= MovementWalkRunSpeedSelectionMode::Default*/)
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveTakeoff: '{}', landing point Id: {} (X: {}, Y: {}, Z: {})", _owner->GetGUID().ToString(), id, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ());
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveTakeoff: '{}', landing point Id: {} (X: {}, Y: {}, Z: {})", _owner->GetGUID(), id, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ());
|
||||
|
||||
std::function<void(Movement::MoveSplineInit&)> initializer = [=](Movement::MoveSplineInit& init)
|
||||
{
|
||||
@@ -748,7 +748,7 @@ void MotionMaster::MoveCharge(float x, float y, float z, float speed /*= SPEED_C
|
||||
if (_slot[MOTION_SLOT_CONTROLLED] && _slot[MOTION_SLOT_CONTROLLED]->GetMovementGeneratorType() != DISTRACT_MOTION_TYPE)
|
||||
return;
|
||||
*/
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveCharge: '{}', charging point Id: {} (X: {}, Y: {}, Z: {})", _owner->GetGUID().ToString(), id, x, y, z);
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveCharge: '{}', charging point Id: {} (X: {}, Y: {}, Z: {})", _owner->GetGUID(), id, x, y, z);
|
||||
PointMovementGenerator* movement = new PointMovementGenerator(id, x, y, z, generatePath, speed, {}, target, spellEffectExtraData);
|
||||
movement->Priority = MOTION_PRIORITY_HIGHEST;
|
||||
movement->BaseUnitState = UNIT_STATE_CHARGING;
|
||||
@@ -834,7 +834,7 @@ void MotionMaster::MoveJump(Position const& pos, float speedXY, float speedZ, ui
|
||||
void MotionMaster::MoveJump(float x, float y, float z, float o, float speedXY, float speedZ, uint32 id /*= EVENT_JUMP*/, bool hasOrientation /* = false*/,
|
||||
JumpArrivalCastArgs const* arrivalCast /*= nullptr*/, Movement::SpellEffectExtraData const* spellEffectExtraData /*= nullptr*/)
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveJump: '{}', jumps to point Id: {} (X: {}, Y: {}, Z: {})", _owner->GetGUID().ToString(), id, x, y, z);
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveJump: '{}', jumps to point Id: {} (X: {}, Y: {}, Z: {})", _owner->GetGUID(), id, x, y, z);
|
||||
if (speedXY < 0.01f)
|
||||
return;
|
||||
|
||||
@@ -870,7 +870,7 @@ void MotionMaster::MoveJump(float x, float y, float z, float o, float speedXY, f
|
||||
void MotionMaster::MoveJumpWithGravity(Position const& pos, float speedXY, float gravity, uint32 id/* = EVENT_JUMP*/, bool hasOrientation/* = false*/,
|
||||
JumpArrivalCastArgs const* arrivalCast /*= nullptr*/, Movement::SpellEffectExtraData const* spellEffectExtraData /*= nullptr*/)
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveJumpWithGravity: '{}', jumps to point Id: {} ({})", _owner->GetGUID().ToString(), id, pos.ToString());
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveJumpWithGravity: '{}', jumps to point Id: {} ({})", _owner->GetGUID(), id, pos.ToString());
|
||||
if (speedXY < 0.01f)
|
||||
return;
|
||||
|
||||
@@ -987,13 +987,13 @@ void MotionMaster::MoveAlongSplineChain(uint32 pointId, uint16 dbChainId, bool w
|
||||
Creature* owner = _owner->ToCreature();
|
||||
if (!owner)
|
||||
{
|
||||
TC_LOG_ERROR("movement.motionmaster", "MotionMaster::MoveAlongSplineChain: '{}', tried to walk along DB spline chain. Ignoring.", _owner->GetGUID().ToString());
|
||||
TC_LOG_ERROR("movement.motionmaster", "MotionMaster::MoveAlongSplineChain: '{}', tried to walk along DB spline chain. Ignoring.", _owner->GetGUID());
|
||||
return;
|
||||
}
|
||||
std::vector<SplineChainLink> const* chain = sScriptSystemMgr->GetSplineChain(owner, dbChainId);
|
||||
if (!chain)
|
||||
{
|
||||
TC_LOG_ERROR("movement.motionmaster", "MotionMaster::MoveAlongSplineChain: '{}', tried to walk along non-existing spline chain with DB Id: {}.", _owner->GetGUID().ToString(), dbChainId);
|
||||
TC_LOG_ERROR("movement.motionmaster", "MotionMaster::MoveAlongSplineChain: '{}', tried to walk along non-existing spline chain with DB Id: {}.", _owner->GetGUID(), dbChainId);
|
||||
return;
|
||||
}
|
||||
MoveAlongSplineChain(pointId, *chain, walk);
|
||||
@@ -1008,7 +1008,7 @@ void MotionMaster::ResumeSplineChain(SplineChainResumeInfo const& info)
|
||||
{
|
||||
if (info.Empty())
|
||||
{
|
||||
TC_LOG_ERROR("movement.motionmaster", "MotionMaster::ResumeSplineChain: '{}', tried to resume a spline chain from empty info.", _owner->GetGUID().ToString());
|
||||
TC_LOG_ERROR("movement.motionmaster", "MotionMaster::ResumeSplineChain: '{}', tried to resume a spline chain from empty info.", _owner->GetGUID());
|
||||
return;
|
||||
}
|
||||
Add(new SplineChainMovementGenerator(info));
|
||||
@@ -1021,7 +1021,7 @@ void MotionMaster::MoveFall(uint32 id/* = 0*/)
|
||||
if (tz <= INVALID_HEIGHT)
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveFall: '{}', unable to retrieve a proper height at map Id: {} (X: {}, Y: {}, Z: {})",
|
||||
_owner->GetGUID().ToString(), _owner->GetMap()->GetId(), _owner->GetPositionX(), _owner->GetPositionY(), _owner->GetPositionZ());
|
||||
_owner->GetGUID(), _owner->GetMap()->GetId(), _owner->GetPositionX(), _owner->GetPositionY(), _owner->GetPositionZ());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1057,7 +1057,7 @@ void MotionMaster::MoveSeekAssistance(float x, float y, float z)
|
||||
{
|
||||
if (Creature* creature = _owner->ToCreature())
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveSeekAssistance: '{}', seeks assistance (X: {}, Y: {}, Z: {})", creature->GetGUID().ToString(), x, y, z);
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveSeekAssistance: '{}', seeks assistance (X: {}, Y: {}, Z: {})", creature->GetGUID(), x, y, z);
|
||||
creature->AttackStop();
|
||||
creature->CastStop();
|
||||
creature->DoNotReacquireSpellFocusTarget();
|
||||
@@ -1065,18 +1065,18 @@ void MotionMaster::MoveSeekAssistance(float x, float y, float z)
|
||||
Add(new AssistanceMovementGenerator(EVENT_ASSIST_MOVE, x, y, z));
|
||||
}
|
||||
else
|
||||
TC_LOG_ERROR("movement.motionmaster", "MotionMaster::MoveSeekAssistance: '{}', attempted to seek assistance.", _owner->GetGUID().ToString());
|
||||
TC_LOG_ERROR("movement.motionmaster", "MotionMaster::MoveSeekAssistance: '{}', attempted to seek assistance.", _owner->GetGUID());
|
||||
}
|
||||
|
||||
void MotionMaster::MoveSeekAssistanceDistract(uint32 time)
|
||||
{
|
||||
if (_owner->GetTypeId() == TYPEID_UNIT)
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveSeekAssistanceDistract: '{}', is distracted after assistance call (Time: {})", _owner->GetGUID().ToString(), time);
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveSeekAssistanceDistract: '{}', is distracted after assistance call (Time: {})", _owner->GetGUID(), time);
|
||||
Add(new AssistanceDistractMovementGenerator(time, _owner->GetOrientation()));
|
||||
}
|
||||
else
|
||||
TC_LOG_ERROR("movement.motionmaster", "MotionMaster::MoveSeekAssistanceDistract: '{}', attempted to call distract assistance.", _owner->GetGUID().ToString());
|
||||
TC_LOG_ERROR("movement.motionmaster", "MotionMaster::MoveSeekAssistanceDistract: '{}', attempted to call distract assistance.", _owner->GetGUID());
|
||||
}
|
||||
|
||||
void MotionMaster::MoveTaxiFlight(uint32 path, uint32 pathnode)
|
||||
@@ -1085,7 +1085,7 @@ void MotionMaster::MoveTaxiFlight(uint32 path, uint32 pathnode)
|
||||
{
|
||||
if (path < sTaxiPathNodesByPath.size())
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveTaxiFlight: '{}', taxi to path Id: {} (node {})", _owner->GetGUID().ToString(), path, pathnode);
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveTaxiFlight: '{}', taxi to path Id: {} (node {})", _owner->GetGUID(), path, pathnode);
|
||||
|
||||
// Only one FLIGHT_MOTION_TYPE is allowed
|
||||
bool hasExisting = HasMovementGenerator([](MovementGenerator const* gen) { return gen->GetMovementGeneratorType() == FLIGHT_MOTION_TYPE; });
|
||||
@@ -1096,10 +1096,10 @@ void MotionMaster::MoveTaxiFlight(uint32 path, uint32 pathnode)
|
||||
Add(movement);
|
||||
}
|
||||
else
|
||||
TC_LOG_ERROR("movement.motionmaster", "MotionMaster::MoveTaxiFlight: '{}', attempted taxi to non-existing path Id: {} (node: {})", _owner->GetGUID().ToString(), path, pathnode);
|
||||
TC_LOG_ERROR("movement.motionmaster", "MotionMaster::MoveTaxiFlight: '{}', attempted taxi to non-existing path Id: {} (node: {})", _owner->GetGUID(), path, pathnode);
|
||||
}
|
||||
else
|
||||
TC_LOG_ERROR("movement.motionmaster", "MotionMaster::MoveTaxiFlight: '{}', attempted taxi to path Id: {} (node: {})", _owner->GetGUID().ToString(), path, pathnode);
|
||||
TC_LOG_ERROR("movement.motionmaster", "MotionMaster::MoveTaxiFlight: '{}', attempted taxi to path Id: {} (node: {})", _owner->GetGUID(), path, pathnode);
|
||||
}
|
||||
|
||||
void MotionMaster::MoveDistract(uint32 timer, float orientation)
|
||||
@@ -1108,7 +1108,7 @@ void MotionMaster::MoveDistract(uint32 timer, float orientation)
|
||||
if (_slot[MOTION_SLOT_CONTROLLED])
|
||||
return;
|
||||
*/
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveDistract: '{}', distracted (timer: {}, orientation: {})", _owner->GetGUID().ToString(), timer, orientation);
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveDistract: '{}', distracted (timer: {}, orientation: {})", _owner->GetGUID(), timer, orientation);
|
||||
Add(new DistractMovementGenerator(timer, orientation));
|
||||
}
|
||||
|
||||
@@ -1120,7 +1120,7 @@ void MotionMaster::MovePath(uint32 pathId, bool repeatable, Optional<Millisecond
|
||||
return;
|
||||
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MovePath: '{}', starts moving over path Id: {} (repeatable: {})",
|
||||
_owner->GetGUID().ToString(), pathId, repeatable ? "YES" : "NO");
|
||||
_owner->GetGUID(), pathId, repeatable ? "YES" : "NO");
|
||||
Add(new WaypointMovementGenerator<Creature>(pathId, repeatable, duration, speed, speedSelectionMode, waitTimeRangeAtPathEnd,
|
||||
wanderDistanceAtPathEnds, followPathBackwardsFromEndToStart, generatePath), MOTION_SLOT_DEFAULT);
|
||||
}
|
||||
@@ -1130,7 +1130,7 @@ void MotionMaster::MovePath(WaypointPath const& path, bool repeatable, Optional<
|
||||
Optional<float> wanderDistanceAtPathEnds, Optional<bool> followPathBackwardsFromEndToStart, bool generatePath)
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MovePath: '{}', starts moving over path Id: {} (repeatable: {})",
|
||||
_owner->GetGUID().ToString(), path.Id, repeatable ? "YES" : "NO");
|
||||
_owner->GetGUID(), path.Id, repeatable ? "YES" : "NO");
|
||||
Add(new WaypointMovementGenerator<Creature>(path, repeatable, duration, speed, speedSelectionMode, waitTimeRangeAtPathEnd,
|
||||
wanderDistanceAtPathEnds, followPathBackwardsFromEndToStart, generatePath), MOTION_SLOT_DEFAULT);
|
||||
}
|
||||
@@ -1139,7 +1139,7 @@ void MotionMaster::MoveRotate(uint32 id, RotateDirection direction, Optional<Mil
|
||||
Optional<float> turnSpeed /*= {}*/, Optional<float> totalTurnAngle /*= {}*/)
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveRotate: '{}', starts rotate (time: {}ms, turnSpeed: {}, totalTurnAngle: {}, direction: {})",
|
||||
_owner->GetGUID().ToString(), time.value_or(0ms).count(), turnSpeed, totalTurnAngle, direction);
|
||||
_owner->GetGUID(), time.value_or(0ms).count(), turnSpeed, totalTurnAngle, direction);
|
||||
|
||||
Add(new RotateMovementGenerator(id, direction, time, turnSpeed, totalTurnAngle));
|
||||
}
|
||||
@@ -1148,7 +1148,7 @@ void MotionMaster::MoveFormation(Unit* leader, float range, float angle, uint32
|
||||
{
|
||||
if (_owner->GetTypeId() == TYPEID_UNIT && leader)
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveFormation: '{}', started to move in a formation with leader {}", _owner->GetGUID().ToString(), leader->GetGUID().ToString());
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveFormation: '{}', started to move in a formation with leader {}", _owner->GetGUID(), leader->GetGUID());
|
||||
Add(new FormationMovementGenerator(leader, range, angle, point1, point2), MOTION_SLOT_DEFAULT);
|
||||
}
|
||||
}
|
||||
@@ -1157,11 +1157,11 @@ void MotionMaster::LaunchMoveSpline(std::function<void(Movement::MoveSplineInit&
|
||||
{
|
||||
if (IsInvalidMovementGeneratorType(type))
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::LaunchMoveSpline: '{}', tried to launch a spline with an invalid MovementGeneratorType: {} (Id: {}, Priority: {})", _owner->GetGUID().ToString(), type, id, priority);
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::LaunchMoveSpline: '{}', tried to launch a spline with an invalid MovementGeneratorType: {} (Id: {}, Priority: {})", _owner->GetGUID(), type, id, priority);
|
||||
return;
|
||||
}
|
||||
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::LaunchMoveSpline: '{}', initiates spline Id: {} (Type: {}, Priority: {})", _owner->GetGUID().ToString(), id, type, priority);
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::LaunchMoveSpline: '{}', initiates spline Id: {} (Type: {}, Priority: {})", _owner->GetGUID(), id, type, priority);
|
||||
|
||||
GenericMovementGenerator* movement = new GenericMovementGenerator(std::move(initializer), type, id);
|
||||
movement->Priority = priority;
|
||||
@@ -1338,7 +1338,7 @@ void MotionMaster::DirectAdd(MovementGenerator* movement, MovementSlot slot/* =
|
||||
void MotionMaster::Delete(MovementGenerator* movement, bool active, bool movementInform)
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::Delete: deleting generator (Priority: {}, Flags: {}, BaseUnitState: {}, Type: {}), owner: '{}'",
|
||||
movement->Priority, movement->Flags, movement->BaseUnitState, movement->GetMovementGeneratorType(), _owner->GetGUID().ToString());
|
||||
movement->Priority, movement->Flags, movement->BaseUnitState, movement->GetMovementGeneratorType(), _owner->GetGUID());
|
||||
|
||||
movement->Finalize(_owner, active, movementInform);
|
||||
ClearBaseUnitState(movement);
|
||||
@@ -1348,7 +1348,7 @@ void MotionMaster::Delete(MovementGenerator* movement, bool active, bool movemen
|
||||
void MotionMaster::DeleteDefault(bool active, bool movementInform)
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::DeleteDefault: deleting generator (Priority: {}, Flags: {}, BaseUnitState: {}, Type: {}), owner: '{}'",
|
||||
_defaultGenerator->Priority, _defaultGenerator->Flags, _defaultGenerator->BaseUnitState, _defaultGenerator->GetMovementGeneratorType(), _owner->GetGUID().ToString());
|
||||
_defaultGenerator->Priority, _defaultGenerator->Flags, _defaultGenerator->BaseUnitState, _defaultGenerator->GetMovementGeneratorType(), _owner->GetGUID());
|
||||
|
||||
_defaultGenerator->Finalize(_owner, active, movementInform);
|
||||
_defaultGenerator = MovementGeneratorPointer(GetIdleMovementGenerator());
|
||||
|
||||
@@ -198,17 +198,13 @@ std::string const & WorldSession::GetPlayerName() const
|
||||
|
||||
std::string WorldSession::GetPlayerInfo() const
|
||||
{
|
||||
std::ostringstream ss;
|
||||
if (_player)
|
||||
return Trinity::StringFormat("[Player: {} {}, Account: {}]", _player->GetName(), _player->GetGUID(), GetAccountId());
|
||||
|
||||
ss << "[Player: ";
|
||||
if (!m_playerLoading.IsEmpty())
|
||||
ss << "Logging in: " << m_playerLoading.ToString() << ", ";
|
||||
else if (_player)
|
||||
ss << _player->GetName() << ' ' << _player->GetGUID().ToString() << ", ";
|
||||
return Trinity::StringFormat("[Player: Logging in: {}, Account: {}]", m_playerLoading, GetAccountId());
|
||||
|
||||
ss << "Account: " << GetAccountId() << "]";
|
||||
|
||||
return ss.str();
|
||||
return Trinity::StringFormat("[Player: Account: {}]", GetAccountId());
|
||||
}
|
||||
|
||||
/// Send a packet to the client
|
||||
|
||||
Reference in New Issue
Block a user