feat(object): add ClntObjMgrAllocObject

This commit is contained in:
fallenoak 2026-01-09 20:46:37 -06:00
parent 59b0cfc80d
commit b4c8c78fe5
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
2 changed files with 27 additions and 0 deletions

View File

@ -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<CGObject_C*>(mem)->m_memHandle = memHandle;
return mem;
}
uint64_t ClntObjMgrGetActivePlayer() {
if (!s_curMgr) {
return 0;

View File

@ -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 <cstdint>
void* ClntObjMgrAllocObject(OBJECT_TYPE_ID typeID, uint64_t guid);
uint64_t ClntObjMgrGetActivePlayer();
ClntObjMgr* ClntObjMgrGetCurrent();