mirror of
https://github.com/whoahq/whoa.git
synced 2026-11-27 16:22:32 +03:00
chore(util): restructure guid code and add WOWGUID typedef
This commit is contained in:
19 files changed
+90
-65
No files matched your search
@@ -0,0 +1,9 @@
|
||||
#include "util/guid/CHashKeyGUID.hpp"
|
||||
|
||||
CHashKeyGUID::CHashKeyGUID() {
|
||||
this->m_guid = 0;
|
||||
}
|
||||
|
||||
CHashKeyGUID::CHashKeyGUID(WOWGUID guid) {
|
||||
this->m_guid = guid;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef UTIL_GUID_C_HASH_KEY_GUID_HPP
|
||||
#define UTIL_GUID_C_HASH_KEY_GUID_HPP
|
||||
|
||||
#include "util/guid/Types.hpp"
|
||||
#include <cstdint>
|
||||
|
||||
class CHashKeyGUID {
|
||||
public:
|
||||
// Public member functions
|
||||
CHashKeyGUID();
|
||||
CHashKeyGUID(WOWGUID guid);
|
||||
|
||||
private:
|
||||
// Private member variables
|
||||
WOWGUID m_guid;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,29 @@
|
||||
#include "util/guid/SmartGUID.hpp"
|
||||
#include <common/DataStore.hpp>
|
||||
|
||||
SmartGUID::operator WOWGUID() const {
|
||||
return this->guid;
|
||||
}
|
||||
|
||||
SmartGUID& SmartGUID::operator=(WOWGUID guid) {
|
||||
this->guid = guid;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CDataStore& operator>>(CDataStore& msg, SmartGUID& guid) {
|
||||
guid = 0;
|
||||
|
||||
uint8_t mask;
|
||||
msg.Get(mask);
|
||||
|
||||
for (int32_t i = 0; i < 8; i++) {
|
||||
if (mask & (1 << i)) {
|
||||
uint8_t byte;
|
||||
msg.Get(byte);
|
||||
|
||||
guid.guid |= static_cast<uint64_t>(byte) << (i * 8);
|
||||
}
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef UTIL_GUID_SMART_GUID_HPP
|
||||
#define UTIL_GUID_SMART_GUID_HPP
|
||||
|
||||
#include "util/guid/Types.hpp"
|
||||
#include <cstdint>
|
||||
|
||||
class CDataStore;
|
||||
|
||||
struct SmartGUID {
|
||||
WOWGUID guid;
|
||||
|
||||
operator WOWGUID() const;
|
||||
SmartGUID& operator=(WOWGUID value);
|
||||
};
|
||||
|
||||
CDataStore& operator>>(CDataStore& msg, SmartGUID& guid);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef UTIL_GUID_TYPES_HPP
|
||||
#define UTIL_GUID_TYPES_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
typedef uint64_t WOWGUID;
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user