diff --git a/src/object/client/ObjMgr.cpp b/src/object/client/ObjMgr.cpp index ecc94ce..6fc2489 100644 --- a/src/object/client/ObjMgr.cpp +++ b/src/object/client/ObjMgr.cpp @@ -66,6 +66,29 @@ void MirrorInitialize() { // TODO } +void* ClntObjMgrAllocObject(OBJECT_TYPE_ID typeID, uint64_t guid) { + auto playerGUID = ClntObjMgrGetActivePlayer(); + + // Heap allocate player object for current player + if (guid == playerGUID) { + return STORM_ALLOC(sizeof(CGPlayer_C) + sizeof(CGPlayerData) + (sizeof(uint32_t) * CGPlayer::TotalFieldsSaved())); + } + + // TODO GarbageCollect(typeID, 10000); + + uint32_t memHandle; + void* mem; + + if (!ObjectAlloc(s_objHeapId[typeID], &memHandle, &mem, false)) { + return nullptr; + } + + // TODO pointer should be fetched via ObjectPtr + static_cast(mem)->m_memHandle = memHandle; + + return mem; +} + uint64_t ClntObjMgrGetActivePlayer() { if (!s_curMgr) { return 0; diff --git a/src/object/client/ObjMgr.hpp b/src/object/client/ObjMgr.hpp index 33f21b2..6d3b6ca 100644 --- a/src/object/client/ObjMgr.hpp +++ b/src/object/client/ObjMgr.hpp @@ -1,9 +1,13 @@ #ifndef OBJECT_CLIENT_OBJ_MGR_HPP #define OBJECT_CLIENT_OBJ_MGR_HPP +#include "object/client/CGObject_C.hpp" #include "object/client/ClntObjMgr.hpp" +#include "object/Types.hpp" #include +void* ClntObjMgrAllocObject(OBJECT_TYPE_ID typeID, uint64_t guid); + uint64_t ClntObjMgrGetActivePlayer(); ClntObjMgr* ClntObjMgrGetCurrent();