From df646fbe6a57376db0c138f1d168bcd53bb0aab2 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Sun, 10 Dec 2023 03:29:23 +0100 Subject: [PATCH] Core/Objects: fixed packet guid writing --- src/server/game/Entities/Object/ObjectGuid.cpp | 6 ++++++ src/server/game/Entities/Object/ObjectGuid.h | 11 ++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/server/game/Entities/Object/ObjectGuid.cpp b/src/server/game/Entities/Object/ObjectGuid.cpp index 13188c18b1..847d95264d 100644 --- a/src/server/game/Entities/Object/ObjectGuid.cpp +++ b/src/server/game/Entities/Object/ObjectGuid.cpp @@ -117,6 +117,12 @@ ByteBuffer& operator<<(ByteBuffer& buf, PackedGuid const& guid) return buf; } +ByteBuffer& operator<<(ByteBuffer& buf, PackedGuidWriter const& guid) +{ + buf.appendPackGUID(guid.Guid.GetRawValue()); + return buf; +} + ByteBuffer& operator>>(ByteBuffer& buf, PackedGuidReader const& guid) { buf.readPackGUID(reinterpret_cast(guid.Guid)); diff --git a/src/server/game/Entities/Object/ObjectGuid.h b/src/server/game/Entities/Object/ObjectGuid.h index a966a6a418..81a4ebae0f 100644 --- a/src/server/game/Entities/Object/ObjectGuid.h +++ b/src/server/game/Entities/Object/ObjectGuid.h @@ -129,6 +129,12 @@ struct PackedGuidReader ObjectGuid& Guid; }; +struct PackedGuidWriter +{ + explicit PackedGuidWriter(ObjectGuid const& guid) : Guid(guid) { } + ObjectGuid const& Guid; +}; + class TC_GAME_API ObjectGuid { public: @@ -158,7 +164,7 @@ class TC_GAME_API ObjectGuid void Set(uint64 guid) { _data._guid = guid; } void Clear() { _data._guid = 0; } - PackedGuid WriteAsPacked() const; + PackedGuidWriter WriteAsPacked() const { return PackedGuidWriter(*this); } uint64 GetRawValue() const { return _data._guid; } HighGuid GetHigh() const @@ -343,10 +349,9 @@ TC_GAME_API ByteBuffer& operator<<(ByteBuffer& buf, ObjectGuid const& guid); TC_GAME_API ByteBuffer& operator>>(ByteBuffer& buf, ObjectGuid& guid); TC_GAME_API ByteBuffer& operator<<(ByteBuffer& buf, PackedGuid const& guid); +TC_GAME_API ByteBuffer& operator<<(ByteBuffer& buf, PackedGuidWriter const& guid); TC_GAME_API ByteBuffer& operator>>(ByteBuffer& buf, PackedGuidReader const& guid); -inline PackedGuid ObjectGuid::WriteAsPacked() const { return PackedGuid(*this); } - namespace std { template<>