From ea51e2e20f1a480880df23be8c45a062d00bae61 Mon Sep 17 00:00:00 2001 From: fallenoak Date: Tue, 28 Oct 2025 21:05:03 -0500 Subject: [PATCH] feat(component): add CCharacterComponent::UpdateItemDisplay --- src/component/CCharacterComponent.cpp | 29 +++++++++++++++++++++++++++ src/component/CCharacterComponent.hpp | 2 ++ 2 files changed, 31 insertions(+) diff --git a/src/component/CCharacterComponent.cpp b/src/component/CCharacterComponent.cpp index f09da37..baea4ca 100644 --- a/src/component/CCharacterComponent.cpp +++ b/src/component/CCharacterComponent.cpp @@ -1146,6 +1146,35 @@ void CCharacterComponent::SetSkinColor(int32_t skinColorID, bool a3, bool a4, co this->m_flags &= ~0x8; } +int32_t CCharacterComponent::UpdateItemDisplay(COMPONENT_SECTIONS section, const ItemDisplayInfoRec* newDisplayRec, int32_t priority) { + bool isNPC = this->m_data.flags & 0x1; + + if (isNPC) { + return 0; + } + + if (this->m_itemDisplays[section].displayID[priority]) { + auto curDisplayID = this->m_itemDisplays[section].displayID[priority]; + auto curDisplayRec = g_itemDisplayInfoDB.GetRecord(curDisplayID); + + // New display is same as old display + if (curDisplayRec && curDisplayRec->m_texture[section] == newDisplayRec->m_texture[section]) { + return 0; + } + } + + this->m_itemDisplays[section].priorityDirty &= ~(1 << priority); + + if (this->m_itemDisplays[section].texture[priority]) { + TextureCacheDestroyTexture(this->m_itemDisplays[section].texture[priority]); + this->m_itemDisplays[section].texture[priority] = nullptr; + } + + this->m_itemDisplays[section].displayID[priority] = newDisplayRec->m_ID; + + return 1; +} + int32_t CCharacterComponent::VariationsLoaded(int32_t a2) { TCTEXTUREINFO info; diff --git a/src/component/CCharacterComponent.hpp b/src/component/CCharacterComponent.hpp index 9f1d2cd..e3fb036 100644 --- a/src/component/CCharacterComponent.hpp +++ b/src/component/CCharacterComponent.hpp @@ -8,6 +8,7 @@ class CACHEENTRY; class CCharacterComponent; class CharSectionsRec; +class ItemDisplayInfoRec; struct BlpPalPixel; struct MipBits; @@ -96,6 +97,7 @@ class CCharacterComponent { void SetHairColor(int32_t hairColorID, bool a3, const char* a4); void SetHairStyle(int32_t hairStyleID, const char* a3); void SetSkinColor(int32_t skinColorID, bool a3, bool a4, const char* a5); + int32_t UpdateItemDisplay(COMPONENT_SECTIONS section, const ItemDisplayInfoRec* newDisplayRec, int32_t priority); int32_t VariationsLoaded(int32_t a2); };