TrinityCore
Loading...
Searching...
No Matches
ObjectGuid.cpp File Reference
#include "ObjectGuid.h"
#include "ByteBuffer.h"
#include "Errors.h"
#include "Hash.h"
#include "Log.h"
#include "Realm.h"
#include "Util.h"
#include "World.h"
+ Include dependency graph for ObjectGuid.cpp:

Go to the source code of this file.

Macros

#define SET_GUID_INFO(type, format, parse)
 

Functions

static uint32 GetRealmIdForObjectGuid (uint32 realmId)
 
ByteBufferoperator<< (ByteBuffer &buf, ObjectGuid const &guid)
 
ByteBufferoperator>> (ByteBuffer &buf, ObjectGuid &guid)
 

Macro Definition Documentation

◆ SET_GUID_INFO

#define SET_GUID_INFO (   type,
  format,
  parse 
)
Value:
Names[AsUnderlyingType(HighGuid::type)] = #type;\
ClientFormatFunction[AsUnderlyingType(HighGuid::type)] = &ObjectGuidInfo::format;\
ClientParseFunction[AsUnderlyingType(HighGuid::type)] = &ObjectGuidInfo::parse
constexpr std::underlying_type< E >::type AsUnderlyingType(E enumValue)
Definition: Util.h:475

Function Documentation

◆ GetRealmIdForObjectGuid()

static uint32 GetRealmIdForObjectGuid ( uint32  realmId)
inlinestatic

Definition at line 590 of file ObjectGuid.cpp.

591{
592 if (realmId)
593 return realmId;
594
595 return realm.Id.Realm;
596}
Realm realm
Definition: World.cpp:3968
Battlenet::RealmHandle Id
Definition: Realm.h:80
+ Here is the caller graph for this function:

◆ operator<<()

ByteBuffer & operator<< ( ByteBuffer buf,
ObjectGuid const &  guid 
)

Definition at line 758 of file ObjectGuid.cpp.

759{
760 uint8 lowMask = 0;
761 uint8 highMask = 0;
762 buf.FlushBits(); // flush any unwritten bits to make wpos return a meaningful value
763 std::size_t pos = buf.wpos();
764 buf << uint8(lowMask);
765 buf << uint8(highMask);
766
767 uint8 packed[8];
768 if (size_t packedSize = ByteBuffer::PackUInt64(guid._data[0], &lowMask, packed))
769 buf.append(packed, packedSize);
770 if (size_t packedSize = ByteBuffer::PackUInt64(guid._data[1], &highMask, packed))
771 buf.append(packed, packedSize);
772
773 buf.put(pos, lowMask);
774 buf.put(pos + 1, highMask);
775
776 return buf;
777}
uint8_t uint8
Definition: Define.h:145
static size_t PackUInt64(uint64 value, uint8 *mask, uint8 *result)
Definition: ByteBuffer.h:607
void append(T value)
Definition: ByteBuffer.h:143
size_t wpos() const
Definition: ByteBuffer.h:412
void put(std::size_t pos, T value)
Definition: ByteBuffer.h:220
void FlushBits()
Definition: ByteBuffer.h:155
+ Here is the caller graph for this function:

◆ operator>>()

ByteBuffer & operator>> ( ByteBuffer buf,
ObjectGuid guid 
)

Definition at line 779 of file ObjectGuid.cpp.

780{
781 uint8 lowMask, highMask;
782 buf >> lowMask >> highMask;
783 buf.ReadPackedUInt64(lowMask, guid._data[0]);
784 buf.ReadPackedUInt64(highMask, guid._data[1]);
785 return buf;
786}
void ReadPackedUInt64(uint64 &guid)
Definition: ByteBuffer.h:485
std::array< uint64, 2 > _data
Definition: ObjectGuid.h:385