32 struct FormatPadding { std::ptrdiff_t Value;
constexpr operator std::ptrdiff_t()
const {
return Value; } };
34 template <std::ptrdiff_t W
idth>
35 static constexpr inline FormatPadding padding{ .Value = Width };
36 static constexpr inline FormatPadding no_padding{ .Value = 0 };
38 struct FormatBase {
int32 Value;
constexpr operator int32()
const {
return Value; } };
40 static constexpr inline FormatBase dec{ 10 };
41 static constexpr inline FormatBase hex{ 16 };
43 static fmt::appender AppendTypeName(fmt::format_context& ctx, std::string_view type)
45 return std::copy(type.begin(), type.end(), ctx.out());
48 template <FormatPadding W
idth, FormatBase Base>
49 static fmt::appender AppendComponent(fmt::format_context& ctx,
uint64 component)
51 std::array<char, 20> buf;
52 auto [end, err] = std::to_chars(buf.data(), buf.data() + buf.size(), component, Base);
54 ASSERT(err == std::errc(),
"Failed to convert guid part to string");
56 if constexpr (Width != 0)
58 if (std::distance(buf.data(), end) < Width)
59 std::fill_n(ctx.out(), Width - std::distance(buf.data(), end),
'0');
62 if constexpr (Base > 10)
63 return std::transform(buf.data(), end, ctx.out(),
charToUpper);
65 return std::copy(buf.data(), end, ctx.out());
70template <
typename FormatContext>
73 ctx.advance_to(ObjectGuidInfo::AppendTypeName(ctx,
"GUID Full: 0x"));
74 ctx.advance_to(ObjectGuidInfo::AppendComponent<ObjectGuidInfo::padding<16>, ObjectGuidInfo::hex>(ctx, guid.GetRawValue()));
75 ctx.advance_to(ObjectGuidInfo::AppendTypeName(ctx,
" Type: "));
76 ctx.advance_to(ObjectGuidInfo::AppendTypeName(ctx, guid.GetTypeName()));
77 if (
uint32 entry = guid.GetEntry())
79 ctx.advance_to(ObjectGuidInfo::AppendTypeName(ctx, guid.IsPet() ?
" Pet number: " :
" Entry: "));
80 ctx.advance_to(ObjectGuidInfo::AppendComponent<ObjectGuidInfo::no_padding, ObjectGuidInfo::dec>(ctx, entry));
82 ctx.advance_to(ObjectGuidInfo::AppendTypeName(ctx,
" Low: "));
83 ctx.advance_to(ObjectGuidInfo::AppendComponent<ObjectGuidInfo::no_padding, ObjectGuidInfo::dec>(ctx, guid.GetCounter()));
124 for (
uint8 i = 0; i < 8; ++i)
126 uint8 byte = (raw >> (i * 8)) & 0xFF;
186 sWorld->TriggerGuidAlert();
188 sWorld->TriggerGuidWarning();
#define TC_LOG_ERROR(filterType__,...)
ByteBuffer & operator<<(ByteBuffer &buf, ObjectGuid const &guid)
ByteBuffer & operator>>(ByteBuffer &buf, ObjectGuid &guid)
struct CharToUpper charToUpper
void appendPackGUID(uint64 guid)
void readPackGUID(uint64 &guid)
ObjectGuid::LowType _nextGuid
void HandleCounterOverflow()
ObjectGuid::LowType Generate()
static ObjectGuid const Empty
void SetRawValue(uint64 guid)
std::string ToHexString() const
uint64 GetRawValue() const
std::string ToString() const
std::string_view GetTypeName() const
LowType GetMaxCounter() const
std::array< uint8, PACKED_GUID_MIN_BUFFER_SIZE > _packedGuid
void Set(ObjectGuid const &guid)
static void StopNow(uint8 exitcode)
@ CONFIG_RESPAWN_GUIDALERTLEVEL
@ CONFIG_RESPAWN_GUIDWARNLEVEL
std::string StringFormat(FormatString< Args... > fmt, Args &&... args)
Default TC string format function.