Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
Core/Objects: fixed packet guid writing
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovahlord committed Dec 10, 2023
1 parent 4bc6115 commit df646fb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/server/game/Entities/Object/ObjectGuid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint64&>(guid.Guid));
Expand Down
11 changes: 8 additions & 3 deletions src/server/game/Entities/Object/ObjectGuid.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<>
Expand Down

0 comments on commit df646fb

Please sign in to comment.