feat(object): add GetNumDwordBlocks

This commit is contained in:
fallenoak 2026-01-11 16:01:28 -06:00
parent bd0d7c63d2
commit 860d6978fd
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
2 changed files with 49 additions and 1 deletions

View File

@ -1,4 +1,48 @@
#include "object/client/Utils.hpp"
#include "object/client/CGContainer.hpp"
#include "object/client/CGCorpse.hpp"
#include "object/client/CGDynamicObject.hpp"
#include "object/client/CGGameObject.hpp"
#include "object/client/CGItem.hpp"
#include "object/client/CGObject_C.hpp"
#include "object/client/CGPlayer.hpp"
#include "object/client/CGUnit.hpp"
#include "object/client/ObjMgr.hpp"
/**
* Given an object type hierarchy and GUID, return the number of DWORD blocks backing the object's
* data storage.
*/
uint32_t GetNumDwordBlocks(OBJECT_TYPE type, uint64_t guid) {
switch (type) {
case HIER_TYPE_OBJECT:
return CGObject::TotalFields();
case HIER_TYPE_ITEM:
return CGItem::TotalFields();
case HIER_TYPE_CONTAINER:
return CGContainer::TotalFields();
case HIER_TYPE_UNIT:
return CGUnit::TotalFields();
case HIER_TYPE_PLAYER:
return guid == ClntObjMgrGetActivePlayer() ? CGPlayer::TotalFields() : CGPlayer::TotalRemoteFields();
case HIER_TYPE_GAMEOBJECT:
return CGGameObject::TotalFields();
case HIER_TYPE_DYNAMICOBJECT:
return CGDynamicObject::TotalFields();
case HIER_TYPE_CORPSE:
return CGCorpse::TotalFields();
default:
return 0;
}
}
/**
* Accounting for the full hierarchy of the given object, return the next inherited type ID after

View File

@ -1,8 +1,12 @@
#ifndef OBJECT_CLIENT_UTILS_HPP
#define OBJECT_CLIENT_UTILS_HPP
#include "object/client/CGObject_C.hpp"
#include "object/Types.hpp"
#include <cstdint>
class CGObject_C;
uint32_t GetNumDwordBlocks(OBJECT_TYPE type, uint64_t guid);
OBJECT_TYPE_ID IncTypeID(CGObject_C* object, OBJECT_TYPE_ID curTypeID);