Core/Misc: PackedGuid refactoring to remove ByteBuffer.h include from ObjectGuid
This commit is contained in:
1 parent
b4f6bee92c
commit
bf51eda550
3 files changed
+28
-11
No files matched your search
@@ -70,7 +70,7 @@ constexpr float VisibilityDistances[AsUnderlyingType(VisibilityDistanceType::Max
|
|||||||
MAX_VISIBILITY_DISTANCE
|
MAX_VISIBILITY_DISTANCE
|
||||||
};
|
};
|
||||||
|
|
||||||
Object::Object() : m_PackGUID(sizeof(uint64)+1)
|
Object::Object()
|
||||||
{
|
{
|
||||||
m_objectTypeId = TYPEID_OBJECT;
|
m_objectTypeId = TYPEID_OBJECT;
|
||||||
m_objectType = TYPEMASK_OBJECT;
|
m_objectType = TYPEMASK_OBJECT;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#include "ObjectGuid.h"
|
#include "ObjectGuid.h"
|
||||||
#include "Errors.h"
|
#include "Errors.h"
|
||||||
#include "Hash.h"
|
#include "ByteBuffer.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
@@ -83,6 +83,22 @@ ObjectGuid ObjectGuid::MapSpecific(HighGuid type, uint32 entry, LowType counter)
|
|||||||
return ObjectGuid(type, entry, counter);
|
return ObjectGuid(type, entry, counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PackedGuid::Set(ObjectGuid guid)
|
||||||
|
{
|
||||||
|
_packedSize = 1;
|
||||||
|
uint64 raw = guid.GetRawValue();
|
||||||
|
for (uint8 i = 0; i < 8; ++i)
|
||||||
|
{
|
||||||
|
uint8 byte = (raw >> (i * 8)) & 0xFF;
|
||||||
|
_packedGuid[_packedSize] = byte;
|
||||||
|
if (byte)
|
||||||
|
{
|
||||||
|
_packedGuid[0] |= uint8(1 << i);
|
||||||
|
++_packedSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ByteBuffer& operator<<(ByteBuffer& buf, ObjectGuid const& guid)
|
ByteBuffer& operator<<(ByteBuffer& buf, ObjectGuid const& guid)
|
||||||
{
|
{
|
||||||
buf << uint64(guid.GetRawValue());
|
buf << uint64(guid.GetRawValue());
|
||||||
@@ -97,7 +113,7 @@ ByteBuffer& operator>>(ByteBuffer& buf, ObjectGuid& guid)
|
|||||||
|
|
||||||
ByteBuffer& operator<<(ByteBuffer& buf, PackedGuid const& guid)
|
ByteBuffer& operator<<(ByteBuffer& buf, PackedGuid const& guid)
|
||||||
{
|
{
|
||||||
buf.append(guid._packedGuid);
|
buf.append(guid._packedGuid.data(), guid._packedSize);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,11 +19,12 @@
|
|||||||
#define ObjectGuid_h__
|
#define ObjectGuid_h__
|
||||||
|
|
||||||
#include "Define.h"
|
#include "Define.h"
|
||||||
#include "ByteBuffer.h"
|
#include <array>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <string>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -118,6 +119,7 @@ GUID_TRAIT_MAP_SPECIFIC(HighGuid::AreaTrigger);
|
|||||||
#undef GUID_TRAIT_REALM_SPECIFIC
|
#undef GUID_TRAIT_REALM_SPECIFIC
|
||||||
#undef GUID_TRAIT_MAP_SPECIFIC
|
#undef GUID_TRAIT_MAP_SPECIFIC
|
||||||
|
|
||||||
|
class ByteBuffer;
|
||||||
class ObjectGuid;
|
class ObjectGuid;
|
||||||
class PackedGuid;
|
class PackedGuid;
|
||||||
|
|
||||||
@@ -291,17 +293,16 @@ class TC_GAME_API PackedGuid
|
|||||||
friend TC_GAME_API ByteBuffer& operator<<(ByteBuffer& buf, PackedGuid const& guid);
|
friend TC_GAME_API ByteBuffer& operator<<(ByteBuffer& buf, PackedGuid const& guid);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PackedGuid() : _packedGuid(PACKED_GUID_MIN_BUFFER_SIZE) { _packedGuid.appendPackGUID(0); }
|
explicit PackedGuid() : _packedSize(1), _packedGuid() { }
|
||||||
explicit PackedGuid(uint64 guid) : _packedGuid(PACKED_GUID_MIN_BUFFER_SIZE) { _packedGuid.appendPackGUID(guid); }
|
explicit PackedGuid(ObjectGuid guid) { Set(guid); }
|
||||||
explicit PackedGuid(ObjectGuid guid) : _packedGuid(PACKED_GUID_MIN_BUFFER_SIZE) { _packedGuid.appendPackGUID(guid.GetRawValue()); }
|
|
||||||
|
|
||||||
void Set(uint64 guid) { _packedGuid.wpos(0); _packedGuid.appendPackGUID(guid); }
|
void Set(ObjectGuid guid);
|
||||||
void Set(ObjectGuid guid) { _packedGuid.wpos(0); _packedGuid.appendPackGUID(guid.GetRawValue()); }
|
|
||||||
|
|
||||||
std::size_t size() const { return _packedGuid.size(); }
|
std::size_t size() const { return _packedSize; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ByteBuffer _packedGuid;
|
uint8 _packedSize;
|
||||||
|
std::array<uint8, PACKED_GUID_MIN_BUFFER_SIZE> _packedGuid;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TC_GAME_API ObjectGuidGeneratorBase
|
class TC_GAME_API ObjectGuidGeneratorBase
|
||||||
|
|||||||
Reference in new issue
Block a user