feat(object): add ClntObjMgrInitializeShared

This commit is contained in:
fallenoak 2026-01-08 16:26:32 -06:00
parent 267890cafe
commit a93d9a7964
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
4 changed files with 97 additions and 1 deletions

View File

@ -80,6 +80,7 @@ int32_t ClientIdle(const void* data, void* param) {
void ClientInitializeGame(uint32_t mapId, C3Vector position) {
// TODO
ClntObjMgrInitializeShared();
ClntObjMgrInitializeStd(mapId);
// TODO

View File

@ -38,6 +38,31 @@ enum INVENTORY_SLOTS {
NUM_BAG_SLOTS = INVSLOT_BAGLAST - INVSLOT_BAGFIRST + 1,
};
enum OBJECT_TYPE {
TYPE_OBJECT = 0x1,
TYPE_ITEM = 0x2,
TYPE_CONTAINER = 0x4,
TYPE_UNIT = 0x8,
TYPE_PLAYER = 0x10,
TYPE_GAMEOBJECT = 0x20,
TYPE_DYNAMICOBJECT = 0x40,
TYPE_CORPSE = 0x80,
// TODO
};
enum OBJECT_TYPE_ID {
ID_OBJECT = 0,
ID_ITEM = 1,
ID_CONTAINER = 2,
ID_UNIT = 3,
ID_PLAYER = 4,
ID_GAMEOBJECT = 5,
ID_DYNAMICOBJECT = 6,
ID_CORPSE = 7,
NUM_CLIENT_OBJECT_TYPES,
// TODO
};
enum SHEATHE_TYPE {
SHEATHE_0 = 0,
SHEATHE_1 = 1,

View File

@ -1,15 +1,69 @@
#include "object/client/ObjMgr.hpp"
#include "client/ClientServices.hpp"
#include "console/Command.hpp"
#include "net/Connection.hpp"
#include "object/client/CGContainer_C.hpp"
#include "object/client/CGCorpse_C.hpp"
#include "object/client/CGDynamicObject_C.hpp"
#include "object/client/CGGameObject_C.hpp"
#include "object/client/CGItem_C.hpp"
#include "object/client/CGObject_C.hpp"
#include "object/client/CGPlayer_C.hpp"
#include "object/client/CGUnit_C.hpp"
#include "util/Unimplemented.hpp"
#include <common/ObjectAlloc.hpp>
#include <storm/Memory.hpp>
static bool s_heapsAllocated;
static uint32_t s_objHeapId[8];
static ClntObjMgr* s_savMgr;
#if defined(WHOA_SYSTEM_WIN)
static thread_local ClntObjMgr* s_curMgr;
#else
static ClntObjMgr* s_curMgr;
#endif
static ClntObjMgr* s_savMgr;
static uint32_t s_objTotalSize[] = {
static_cast<uint32_t>(sizeof(CGObject_C) + sizeof(CGObjectData) + (sizeof(uint32_t) * CGObject::TotalFieldsSaved())),
static_cast<uint32_t>(sizeof(CGItem_C) + sizeof(CGItemData) + (sizeof(uint32_t) * CGItem::TotalFieldsSaved())),
static_cast<uint32_t>(sizeof(CGContainer_C) + sizeof(CGContainerData) + (sizeof(uint32_t) * CGContainer::TotalFieldsSaved())),
static_cast<uint32_t>(sizeof(CGUnit_C) + sizeof(CGUnitData) + (sizeof(uint32_t) * CGUnit::TotalFieldsSaved())),
static_cast<uint32_t>(sizeof(CGPlayer_C) + sizeof(CGPlayerData) + (sizeof(uint32_t) * CGPlayer::TotalFieldsSaved())),
static_cast<uint32_t>(sizeof(CGGameObject_C) + sizeof(CGGameObjectData) + (sizeof(uint32_t) * CGGameObject::TotalFieldsSaved())),
static_cast<uint32_t>(sizeof(CGDynamicObject_C) + sizeof(CGDynamicObjectData) + (sizeof(uint32_t) * CGDynamicObject::TotalFieldsSaved())),
static_cast<uint32_t>(sizeof(CGCorpse_C) + sizeof(CGCorpseData) + (sizeof(uint32_t) * CGCorpse::TotalFieldsSaved())),
};
static const char* s_objNames[] = {
"CGObject_C",
"CGItem_C",
"CGContainer_C",
"CGUnit_C",
"CGPlayer_C",
"CGGameObject_C",
"CGDynamicObject_C",
"CGCorpse_C",
};
static uint32_t s_heapSizes[] = {
0,
512,
32,
64,
64,
64,
32,
32,
};
int32_t CCommand_ObjUsage(const char* command, const char* arguments) {
WHOA_UNIMPLEMENTED(0);
}
void MirrorInitialize() {
// TODO
}
uint64_t ClntObjMgrGetActivePlayer() {
if (!s_curMgr) {
@ -31,6 +85,20 @@ uint32_t ClntObjMgrGetMapID() {
return s_curMgr->m_mapID;
}
void ClntObjMgrInitializeShared() {
if (!s_heapsAllocated) {
for (int32_t i = ID_ITEM; i < NUM_CLIENT_OBJECT_TYPES; i++) {
s_objHeapId[i] = ObjectAllocAddHeap(s_objTotalSize[i], s_heapSizes[i], s_objNames[i], true);
}
s_heapsAllocated = true;
}
MirrorInitialize();
ConsoleCommandRegister("ObjUsage", &CCommand_ObjUsage, GAME, nullptr);
}
void ClntObjMgrInitializeStd(uint32_t mapID) {
// TODO last instance time

View File

@ -10,6 +10,8 @@ ClntObjMgr* ClntObjMgrGetCurrent();
uint32_t ClntObjMgrGetMapID();
void ClntObjMgrInitializeShared();
void ClntObjMgrInitializeStd(uint32_t mapID);
void ClntObjMgrPop();