mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-02 16:52:45 +03:00
chore(util): restructure guid code and add WOWGUID typedef
This commit is contained in:
parent
5e4ca1980d
commit
364fba9f34
@ -1,12 +1,13 @@
|
|||||||
#ifndef OBJECT_CLIENT_CG_CONTAINER_HPP
|
#ifndef OBJECT_CLIENT_CG_CONTAINER_HPP
|
||||||
#define OBJECT_CLIENT_CG_CONTAINER_HPP
|
#define OBJECT_CLIENT_CG_CONTAINER_HPP
|
||||||
|
|
||||||
|
#include "util/GUID.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
struct CGContainerData {
|
struct CGContainerData {
|
||||||
uint32_t numSlots;
|
uint32_t numSlots;
|
||||||
uint32_t pad;
|
uint32_t pad;
|
||||||
uint64_t slots[36];
|
WOWGUID slots[36];
|
||||||
};
|
};
|
||||||
|
|
||||||
class CGContainer {
|
class CGContainer {
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
#ifndef OBJECT_CLIENT_CG_ITEM_HPP
|
#ifndef OBJECT_CLIENT_CG_ITEM_HPP
|
||||||
#define OBJECT_CLIENT_CG_ITEM_HPP
|
#define OBJECT_CLIENT_CG_ITEM_HPP
|
||||||
|
|
||||||
|
#include "util/GUID.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
struct ItemEnchantment {
|
struct ItemEnchantment {
|
||||||
@ -10,10 +11,10 @@ struct ItemEnchantment {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct CGItemData {
|
struct CGItemData {
|
||||||
uint64_t owner;
|
WOWGUID owner;
|
||||||
uint64_t containedIn;
|
WOWGUID containedIn;
|
||||||
uint64_t creator;
|
WOWGUID creator;
|
||||||
uint64_t giftCreator;
|
WOWGUID giftCreator;
|
||||||
uint32_t stackCount;
|
uint32_t stackCount;
|
||||||
int32_t expiration;
|
int32_t expiration;
|
||||||
int32_t spellCharges[5];
|
int32_t spellCharges[5];
|
||||||
|
|||||||
@ -2,10 +2,11 @@
|
|||||||
#define OBJECT_CLIENT_CG_OBJECT_HPP
|
#define OBJECT_CLIENT_CG_OBJECT_HPP
|
||||||
|
|
||||||
#include "object/Types.hpp"
|
#include "object/Types.hpp"
|
||||||
|
#include "util/GUID.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
struct CGObjectData {
|
struct CGObjectData {
|
||||||
uint64_t m_guid;
|
WOWGUID m_guid;
|
||||||
OBJECT_TYPE m_type;
|
OBJECT_TYPE m_type;
|
||||||
int32_t m_entryID;
|
int32_t m_entryID;
|
||||||
float m_scale;
|
float m_scale;
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
#ifndef OBJECT_CLIENT_CG_OBJECT_C_HPP
|
#ifndef OBJECT_CLIENT_CG_OBJECT_C_HPP
|
||||||
#define OBJECT_CLIENT_CG_OBJECT_C_HPP
|
#define OBJECT_CLIENT_CG_OBJECT_C_HPP
|
||||||
|
|
||||||
#include "object/client/CGObject.hpp"
|
|
||||||
#include "object/Types.hpp"
|
#include "object/Types.hpp"
|
||||||
#include "util/CHashKeyGUID.hpp"
|
#include "object/client/CGObject.hpp"
|
||||||
|
#include "util/GUID.hpp"
|
||||||
#include <storm/Hash.hpp>
|
#include <storm/Hash.hpp>
|
||||||
|
|
||||||
class CGObject_C : public CGObject, public TSHashObject<CGObject_C, CHashKeyGUID> {
|
class CGObject_C : public CGObject, public TSHashObject<CGObject_C, CHashKeyGUID> {
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
#define OBJECT_CLIENT_CG_PLAYER_HPP
|
#define OBJECT_CLIENT_CG_PLAYER_HPP
|
||||||
|
|
||||||
#include "object/Types.hpp"
|
#include "object/Types.hpp"
|
||||||
|
#include "util/GUID.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
struct CQuestLogData {
|
struct CQuestLogData {
|
||||||
@ -19,7 +20,7 @@ struct CVisibleItemData {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct CGPlayerData {
|
struct CGPlayerData {
|
||||||
uint64_t duelArbiter;
|
WOWGUID duelArbiter;
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
uint32_t guildID;
|
uint32_t guildID;
|
||||||
uint32_t guildRank;
|
uint32_t guildRank;
|
||||||
@ -33,18 +34,18 @@ struct CGPlayerData {
|
|||||||
int32_t chosenTitle;
|
int32_t chosenTitle;
|
||||||
int32_t fakeInebriation;
|
int32_t fakeInebriation;
|
||||||
int32_t pad4;
|
int32_t pad4;
|
||||||
uint64_t invSlots[NUM_INVENTORY_SLOTS];
|
WOWGUID invSlots[NUM_INVENTORY_SLOTS];
|
||||||
uint64_t packSlots[16];
|
WOWGUID packSlots[16];
|
||||||
uint64_t bankSlots[28];
|
WOWGUID bankSlots[28];
|
||||||
uint64_t bankBagSlots[7];
|
WOWGUID bankBagSlots[7];
|
||||||
uint64_t vendorBuybackSlots[12];
|
WOWGUID vendorBuybackSlots[12];
|
||||||
uint64_t keyringSlots[32];
|
WOWGUID keyringSlots[32];
|
||||||
uint64_t currencyTokenSlots[32];
|
WOWGUID currencyTokenSlots[32];
|
||||||
uint64_t farsightObject;
|
WOWGUID farsightObject;
|
||||||
uint64_t knownTitles;
|
WOWGUID knownTitles;
|
||||||
uint64_t knownTitles2;
|
WOWGUID knownTitles2;
|
||||||
uint64_t knownTitles3;
|
WOWGUID knownTitles3;
|
||||||
uint64_t knownCurrencies;
|
WOWGUID knownCurrencies;
|
||||||
uint32_t xp;
|
uint32_t xp;
|
||||||
uint32_t nextLevelXP;
|
uint32_t nextLevelXP;
|
||||||
// TODO
|
// TODO
|
||||||
|
|||||||
@ -1,17 +1,18 @@
|
|||||||
#ifndef OBJECT_CLIENT_CG_UNIT_HPP
|
#ifndef OBJECT_CLIENT_CG_UNIT_HPP
|
||||||
#define OBJECT_CLIENT_CG_UNIT_HPP
|
#define OBJECT_CLIENT_CG_UNIT_HPP
|
||||||
|
|
||||||
|
#include "util/GUID.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
struct CGUnitData {
|
struct CGUnitData {
|
||||||
uint64_t charm;
|
WOWGUID charm;
|
||||||
uint64_t summon;
|
WOWGUID summon;
|
||||||
uint64_t critter;
|
WOWGUID critter;
|
||||||
uint64_t charmedBy;
|
WOWGUID charmedBy;
|
||||||
uint64_t summonedBy;
|
WOWGUID summonedBy;
|
||||||
uint64_t createdBy;
|
WOWGUID createdBy;
|
||||||
uint64_t target;
|
WOWGUID target;
|
||||||
uint64_t channelObject;
|
WOWGUID channelObject;
|
||||||
int32_t channelSpell;
|
int32_t channelSpell;
|
||||||
int32_t pad1;
|
int32_t pad1;
|
||||||
int32_t health;
|
int32_t health;
|
||||||
|
|||||||
@ -8,7 +8,7 @@ class ClientConnection;
|
|||||||
class ClntObjMgr {
|
class ClntObjMgr {
|
||||||
public:
|
public:
|
||||||
// Member variables
|
// Member variables
|
||||||
uint64_t m_activePlayer = 0;
|
WOWGUID m_activePlayer = 0;
|
||||||
uint32_t m_mapID = 0;
|
uint32_t m_mapID = 0;
|
||||||
ClientConnection* m_net = nullptr;
|
ClientConnection* m_net = nullptr;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -53,7 +53,7 @@ int32_t ExtractDirtyMasks(CDataStore* msg, uint8_t* maskCount, uint32_t* masks)
|
|||||||
* Given an object type hierarchy and GUID, return the number of DWORD blocks backing the object's
|
* Given an object type hierarchy and GUID, return the number of DWORD blocks backing the object's
|
||||||
* data storage.
|
* data storage.
|
||||||
*/
|
*/
|
||||||
uint32_t GetNumDwordBlocks(OBJECT_TYPE type, uint64_t guid) {
|
uint32_t GetNumDwordBlocks(OBJECT_TYPE type, WOWGUID guid) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case HIER_TYPE_OBJECT:
|
case HIER_TYPE_OBJECT:
|
||||||
return CGObject::TotalFields();
|
return CGObject::TotalFields();
|
||||||
@ -150,7 +150,7 @@ int32_t IsMaskBitSet(uint32_t* masks, uint32_t block) {
|
|||||||
return masks[block / 32] & (1 << (block % 32));
|
return masks[block / 32] & (1 << (block % 32));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t FillInPartialObjectData(CGObject_C* object, uint64_t guid, CDataStore* msg, bool forFullUpdate, bool zeroZeroBits) {
|
int32_t FillInPartialObjectData(CGObject_C* object, WOWGUID guid, CDataStore* msg, bool forFullUpdate, bool zeroZeroBits) {
|
||||||
uint8_t changeMaskCount;
|
uint8_t changeMaskCount;
|
||||||
uint32_t changeMasks[MAX_CHANGE_MASKS];
|
uint32_t changeMasks[MAX_CHANGE_MASKS];
|
||||||
if (!ExtractDirtyMasks(msg, &changeMaskCount, changeMasks)) {
|
if (!ExtractDirtyMasks(msg, &changeMaskCount, changeMasks)) {
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
#ifndef OBJECT_CLIENT_MIRROR_HPP
|
#ifndef OBJECT_CLIENT_MIRROR_HPP
|
||||||
#define OBJECT_CLIENT_MIRROR_HPP
|
#define OBJECT_CLIENT_MIRROR_HPP
|
||||||
|
|
||||||
|
#include "util/GUID.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
class CDataStore;
|
class CDataStore;
|
||||||
class CGObject_C;
|
class CGObject_C;
|
||||||
|
|
||||||
int32_t FillInPartialObjectData(CGObject_C* object, uint64_t guid, CDataStore* msg, bool forFullUpdate, bool zeroZeroBits);
|
int32_t FillInPartialObjectData(CGObject_C* object, WOWGUID guid, CDataStore* msg, bool forFullUpdate, bool zeroZeroBits);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -66,7 +66,7 @@ void MirrorInitialize() {
|
|||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void* ClntObjMgrAllocObject(OBJECT_TYPE_ID typeID, uint64_t guid) {
|
void* ClntObjMgrAllocObject(OBJECT_TYPE_ID typeID, WOWGUID guid) {
|
||||||
auto playerGUID = ClntObjMgrGetActivePlayer();
|
auto playerGUID = ClntObjMgrGetActivePlayer();
|
||||||
|
|
||||||
// Heap allocate player object for current player
|
// Heap allocate player object for current player
|
||||||
@ -89,7 +89,7 @@ void* ClntObjMgrAllocObject(OBJECT_TYPE_ID typeID, uint64_t guid) {
|
|||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t ClntObjMgrGetActivePlayer() {
|
WOWGUID ClntObjMgrGetActivePlayer() {
|
||||||
if (!s_curMgr) {
|
if (!s_curMgr) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -156,7 +156,7 @@ void ClntObjMgrPush(ClntObjMgr* mgr) {
|
|||||||
s_curMgr = mgr;
|
s_curMgr = mgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClntObjMgrSetActivePlayer(uint64_t guid) {
|
void ClntObjMgrSetActivePlayer(WOWGUID guid) {
|
||||||
s_curMgr->m_activePlayer = guid;
|
s_curMgr->m_activePlayer = guid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,9 +6,9 @@
|
|||||||
#include "object/Types.hpp"
|
#include "object/Types.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
void* ClntObjMgrAllocObject(OBJECT_TYPE_ID typeID, uint64_t guid);
|
void* ClntObjMgrAllocObject(OBJECT_TYPE_ID typeID, WOWGUID guid);
|
||||||
|
|
||||||
uint64_t ClntObjMgrGetActivePlayer();
|
WOWGUID ClntObjMgrGetActivePlayer();
|
||||||
|
|
||||||
ClntObjMgr* ClntObjMgrGetCurrent();
|
ClntObjMgr* ClntObjMgrGetCurrent();
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ void ClntObjMgrPop();
|
|||||||
|
|
||||||
void ClntObjMgrPush(ClntObjMgr* mgr);
|
void ClntObjMgrPush(ClntObjMgr* mgr);
|
||||||
|
|
||||||
void ClntObjMgrSetActivePlayer(uint64_t guid);
|
void ClntObjMgrSetActivePlayer(WOWGUID guid);
|
||||||
|
|
||||||
void ClntObjMgrSetHandlers();
|
void ClntObjMgrSetHandlers();
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
file(GLOB PRIVATE_SOURCES
|
file(GLOB PRIVATE_SOURCES
|
||||||
"*.cpp"
|
"*.cpp"
|
||||||
|
"guid/*.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
if(WHOA_SYSTEM_MAC)
|
if(WHOA_SYSTEM_MAC)
|
||||||
|
|||||||
8
src/util/GUID.hpp
Normal file
8
src/util/GUID.hpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#ifndef UTIL_GUID_HPP
|
||||||
|
#define UTIL_GUID_HPP
|
||||||
|
|
||||||
|
#include "util/guid/CHashKeyGUID.hpp"
|
||||||
|
#include "util/guid/SmartGUID.hpp"
|
||||||
|
#include "util/guid/Types.hpp"
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -1,17 +0,0 @@
|
|||||||
#ifndef UTIL_SMART_GUID_HPP
|
|
||||||
#define UTIL_SMART_GUID_HPP
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
class CDataStore;
|
|
||||||
|
|
||||||
struct SmartGUID {
|
|
||||||
uint64_t guid;
|
|
||||||
|
|
||||||
operator uint64_t() const;
|
|
||||||
SmartGUID& operator=(uint64_t value);
|
|
||||||
};
|
|
||||||
|
|
||||||
CDataStore& operator>>(CDataStore& msg, SmartGUID& guid);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@ -1,9 +1,9 @@
|
|||||||
#include "util/CHashKeyGUID.hpp"
|
#include "util/guid/CHashKeyGUID.hpp"
|
||||||
|
|
||||||
CHashKeyGUID::CHashKeyGUID() {
|
CHashKeyGUID::CHashKeyGUID() {
|
||||||
this->m_guid = 0;
|
this->m_guid = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CHashKeyGUID::CHashKeyGUID(uint64_t guid) {
|
CHashKeyGUID::CHashKeyGUID(WOWGUID guid) {
|
||||||
this->m_guid = guid;
|
this->m_guid = guid;
|
||||||
}
|
}
|
||||||
@ -1,17 +1,18 @@
|
|||||||
#ifndef UTIL_C_HASH_KEY_GUID_HPP
|
#ifndef UTIL_GUID_C_HASH_KEY_GUID_HPP
|
||||||
#define UTIL_C_HASH_KEY_GUID_HPP
|
#define UTIL_GUID_C_HASH_KEY_GUID_HPP
|
||||||
|
|
||||||
|
#include "util/guid/Types.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
class CHashKeyGUID {
|
class CHashKeyGUID {
|
||||||
public:
|
public:
|
||||||
// Public member functions
|
// Public member functions
|
||||||
CHashKeyGUID();
|
CHashKeyGUID();
|
||||||
CHashKeyGUID(uint64_t guid);
|
CHashKeyGUID(WOWGUID guid);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Private member variables
|
// Private member variables
|
||||||
uint64_t m_guid;
|
WOWGUID m_guid;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -1,11 +1,11 @@
|
|||||||
#include "util/SmartGUID.hpp"
|
#include "util/guid/SmartGUID.hpp"
|
||||||
#include <common/DataStore.hpp>
|
#include <common/DataStore.hpp>
|
||||||
|
|
||||||
SmartGUID::operator uint64_t() const {
|
SmartGUID::operator WOWGUID() const {
|
||||||
return this->guid;
|
return this->guid;
|
||||||
}
|
}
|
||||||
|
|
||||||
SmartGUID& SmartGUID::operator=(uint64_t guid) {
|
SmartGUID& SmartGUID::operator=(WOWGUID guid) {
|
||||||
this->guid = guid;
|
this->guid = guid;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
18
src/util/guid/SmartGUID.hpp
Normal file
18
src/util/guid/SmartGUID.hpp
Normal file
@ -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
|
||||||
8
src/util/guid/Types.hpp
Normal file
8
src/util/guid/Types.hpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#ifndef UTIL_GUID_TYPES_HPP
|
||||||
|
#define UTIL_GUID_TYPES_HPP
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
typedef uint64_t WOWGUID;
|
||||||
|
|
||||||
|
#endif
|
||||||
Loading…
Reference in New Issue
Block a user