feat(component): add CCharacterComponent::FreeComponent

This commit is contained in:
fallenoak 2026-01-01 21:39:53 -06:00
parent 09acc6f421
commit 1cba1cc66d
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
2 changed files with 30 additions and 0 deletions

View File

@ -286,6 +286,11 @@ HTEXTURE CCharacterComponent::CreateTexture(const char* fileName, CStatus* statu
return TextureCreate(fileName, texFlags, status, 0); return TextureCreate(fileName, texFlags, status, 0);
} }
void CCharacterComponent::FreeComponent(CCharacterComponent* component) {
component->~CCharacterComponent();
ObjectFree(*s_componentHeap, component->m_memHandle);
}
GEOCOMPONENTLINKS CCharacterComponent::GetSheatheLink(SHEATHE_TYPE sheatheType, bool a2) { GEOCOMPONENTLINKS CCharacterComponent::GetSheatheLink(SHEATHE_TYPE sheatheType, bool a2) {
switch (sheatheType) { switch (sheatheType) {
case SHEATHE_1: case SHEATHE_1:
@ -823,6 +828,29 @@ void CCharacterComponent::UpdateBaseTexture(EGxTexCommand cmd, uint32_t width, u
} }
} }
CCharacterComponent::~CCharacterComponent() {
// TODO destroy base texture
if (this->m_data.model) {
this->m_data.model->Release();
this->m_data.model = nullptr;
}
for (auto& texture : this->m_texture) {
TextureCacheDestroyTexture(texture);
texture = nullptr;
}
for (auto& itemDisplay : this->m_itemDisplays) {
for (auto& texture : itemDisplay.texture) {
TextureCacheDestroyTexture(texture);
texture = nullptr;
}
}
// TODO
}
void CCharacterComponent::AddItem(ITEM_SLOT itemSlot, int32_t displayID, int32_t a4) { void CCharacterComponent::AddItem(ITEM_SLOT itemSlot, int32_t displayID, int32_t a4) {
if (displayID <= 0) { if (displayID <= 0) {
return; return;

View File

@ -54,6 +54,7 @@ class CCharacterComponent {
static void ComponentCloseFingers(CM2Model* model, COMP_HAND_SLOT handSlot); static void ComponentCloseFingers(CM2Model* model, COMP_HAND_SLOT handSlot);
static void ComponentOpenFingers(CM2Model* model, COMP_HAND_SLOT handSlot); static void ComponentOpenFingers(CM2Model* model, COMP_HAND_SLOT handSlot);
static HTEXTURE CreateTexture(const char* fileName, CStatus* status); static HTEXTURE CreateTexture(const char* fileName, CStatus* status);
static void FreeComponent(CCharacterComponent* component);
static GEOCOMPONENTLINKS GetSheatheLink(SHEATHE_TYPE sheatheType, bool a2); static GEOCOMPONENTLINKS GetSheatheLink(SHEATHE_TYPE sheatheType, bool a2);
static void Initialize(); static void Initialize();
static void Initialize(EGxTexFormat textureFormat, uint32_t textureLevel, int32_t thread, int32_t compress); static void Initialize(EGxTexFormat textureFormat, uint32_t textureLevel, int32_t thread, int32_t compress);
@ -81,6 +82,7 @@ class CCharacterComponent {
int32_t m_items[NUM_ITEM_SLOT] = {}; int32_t m_items[NUM_ITEM_SLOT] = {};
// Member functions // Member functions
~CCharacterComponent();
void AddItem(ITEM_SLOT itemSlot, int32_t displayID, int32_t a4); void AddItem(ITEM_SLOT itemSlot, int32_t displayID, int32_t a4);
void AddItem(ITEM_SLOT itemSlot, const ItemDisplayInfoRec* displayRec, int32_t a4); void AddItem(ITEM_SLOT itemSlot, const ItemDisplayInfoRec* displayRec, int32_t a4);
void AddItemBySlot(INVENTORY_SLOTS invSlot, int32_t displayID, int32_t a4); void AddItemBySlot(INVENTORY_SLOTS invSlot, int32_t displayID, int32_t a4);