From e7aec124a2cb49e9b9e4626a7dcc36fb3fa0bc3f Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Wed, 17 Apr 2024 11:03:17 -0400 Subject: [PATCH] Implement/match LegoPhonemePresenter::EndAction (#816) --- .../legoomni/include/legocharactermanager.h | 1 + .../src/common/legocharactermanager.cpp | 7 +++ .../src/video/legophonemepresenter.cpp | 49 +++++++++++++++++-- LEGO1/lego/sources/misc/legocontainer.cpp | 16 +++--- LEGO1/lego/sources/misc/legocontainer.h | 10 ++-- 5 files changed, 66 insertions(+), 17 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legocharactermanager.h b/LEGO1/lego/legoomni/include/legocharactermanager.h index 6177a144..e7274f78 100644 --- a/LEGO1/lego/legoomni/include/legocharactermanager.h +++ b/LEGO1/lego/legoomni/include/legocharactermanager.h @@ -59,6 +59,7 @@ class LegoCharacterManager { void FUN_100832a0(); MxU32 GetRefCount(LegoROI* p_roi); + void FUN_10083c30(const char* p_name); void FUN_10083db0(LegoROI* p_roi); void FUN_10083f10(LegoROI* p_roi); MxBool FUN_100849a0(LegoROI* p_roi, LegoTextureInfo* p_textureInfo); diff --git a/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp b/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp index 577cb4cd..5b60129d 100644 --- a/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp @@ -239,6 +239,13 @@ MxU32 LegoCharacterManager::GetRefCount(LegoROI* p_roi) return 0; } +// STUB: LEGO1 0x10083c30 +// FUNCTION: BETA10 0x10074701 +void LegoCharacterManager::FUN_10083c30(const char* p_name) +{ + // TODO +} + // FUNCTION: LEGO1 0x10083db0 void LegoCharacterManager::FUN_10083db0(LegoROI* p_roi) { diff --git a/LEGO1/lego/legoomni/src/video/legophonemepresenter.cpp b/LEGO1/lego/legoomni/src/video/legophonemepresenter.cpp index 2ffcc71c..5c0dd322 100644 --- a/LEGO1/lego/legoomni/src/video/legophonemepresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legophonemepresenter.cpp @@ -62,7 +62,7 @@ void LegoPhonemePresenter::StartingTickle() LegoPhonemeListCursor cursor(phonemeList); if (!cursor.Find(phoneme)) { - LegoTextureInfo* textureInfo = TextureContainer()->AddToList(m_textureInfo); + LegoTextureInfo* textureInfo = TextureContainer()->GetCached(m_textureInfo); CharacterManager()->FUN_100849a0(entityROI, textureInfo); @@ -117,12 +117,53 @@ void LegoPhonemePresenter::PutFrame() } } -// STUB: LEGO1 0x1004e870 +// FUNCTION: LEGO1 0x1004e870 +// FUNCTION: BETA10 0x100c3c24 void LegoPhonemePresenter::EndAction() { - // TODO - if (m_action != NULL) { MxFlcPresenter::EndAction(); + + LegoPhonemeList* phonemeList = VideoManager()->GetPhonemeList(); + LegoPhoneme* phoneme = new LegoPhoneme(m_roiName.GetData(), 1); + + LegoPhonemeListCursor cursor(phonemeList); + + if (cursor.Find(phoneme)) { + LegoPhoneme* newPhoneme = phoneme; + cursor.Current(phoneme); + delete newPhoneme; + + if (phoneme->VTable0x00() == 1) { + LegoROI* roi; + + if (m_unk0x84) { + roi = FindROI(m_roiName.GetData()); + } + else { + roi = CharacterManager()->GetROI(m_roiName.GetData(), TRUE); + } + + if (roi != NULL) { + CharacterManager()->FUN_100849a0(roi, NULL); + } + + if (!m_unk0x84) { + CharacterManager()->FUN_10083c30(m_roiName.GetData()); + } + + TextureContainer()->EraseCached(phoneme->VTable0x10()); + TextureContainer()->EraseCached(phoneme->VTable0x08()); + cursor.Destroy(); + } + else { + phoneme->VTable0x04(phoneme->VTable0x00() - 1); + cursor.SetValue(phoneme); + } + + if (!m_unk0x84) { + CharacterManager()->FUN_10083c30(m_roiName.GetData()); + } + } } } diff --git a/LEGO1/lego/sources/misc/legocontainer.cpp b/LEGO1/lego/sources/misc/legocontainer.cpp index 6d5fa7fe..dddb979a 100644 --- a/LEGO1/lego/sources/misc/legocontainer.cpp +++ b/LEGO1/lego/sources/misc/legocontainer.cpp @@ -14,7 +14,7 @@ LegoTextureContainer::~LegoTextureContainer() } // FUNCTION: LEGO1 0x100998e0 -LegoTextureInfo* LegoTextureContainer::AddToList(LegoTextureInfo* p_textureInfo) +LegoTextureInfo* LegoTextureContainer::GetCached(LegoTextureInfo* p_textureInfo) { DDSURFACEDESC desc, newDesc; DWORD width, height; @@ -27,7 +27,7 @@ LegoTextureInfo* LegoTextureContainer::AddToList(LegoTextureInfo* p_textureInfo) p_textureInfo->m_surface->Unlock(desc.lpSurface); } - for (LegoTextureList::iterator it = m_list.begin(); it != m_list.end(); it++) { + for (LegoCachedTextureList::iterator it = m_cached.begin(); it != m_cached.end(); it++) { if ((*it).second == FALSE && (*it).first->m_texture->AddRef() != 0 && (*it).first->m_texture->Release() == 1) { if (!strcmp((*it).first->m_name, p_textureInfo->m_name)) { LPDIRECTDRAWSURFACE surface = (*it).first->m_surface; @@ -92,7 +92,7 @@ LegoTextureInfo* LegoTextureContainer::AddToList(LegoTextureInfo* p_textureInfo) } else { textureInfo->m_texture->SetAppData((DWORD) textureInfo); - m_list.push_back(LegoTextureListElement(textureInfo, TRUE)); + m_cached.push_back(LegoCachedTexture(textureInfo, TRUE)); textureInfo->m_texture->AddRef(); @@ -111,24 +111,24 @@ LegoTextureInfo* LegoTextureContainer::AddToList(LegoTextureInfo* p_textureInfo) } // FUNCTION: LEGO1 0x10099cc0 -void LegoTextureContainer::EraseFromList(LegoTextureInfo* p_textureInfo) +void LegoTextureContainer::EraseCached(LegoTextureInfo* p_textureInfo) { if (p_textureInfo == NULL) { return; } #ifdef COMPAT_MODE - LegoTextureList::iterator it; - for (it = m_list.begin(); it != m_list.end(); it++) { + LegoCachedTextureList::iterator it; + for (it = m_cached.begin(); it != m_cached.end(); it++) { #else - for (LegoTextureList::iterator it = m_list.begin(); it != m_list.end(); it++) { + for (LegoCachedTextureList::iterator it = m_cached.begin(); it != m_cached.end(); it++) { #endif if ((*it).first == p_textureInfo) { (*it).second = FALSE; if (p_textureInfo->m_texture->Release() == TRUE) { delete p_textureInfo; - m_list.erase(it); + m_cached.erase(it); } return; diff --git a/LEGO1/lego/sources/misc/legocontainer.h b/LEGO1/lego/sources/misc/legocontainer.h index a4fb53b0..05732367 100644 --- a/LEGO1/lego/sources/misc/legocontainer.h +++ b/LEGO1/lego/sources/misc/legocontainer.h @@ -98,8 +98,8 @@ class LegoContainer { // VTABLE: LEGO1 0x100d86d4 // class LegoContainer -typedef pair LegoTextureListElement; -typedef list LegoTextureList; +typedef pair LegoCachedTexture; +typedef list LegoCachedTextureList; // VTABLE: LEGO1 0x100d86fc // SIZE 0x24 @@ -108,11 +108,11 @@ class LegoTextureContainer : public LegoContainer { LegoTextureContainer() { m_ownership = TRUE; } ~LegoTextureContainer() override; - LegoTextureInfo* AddToList(LegoTextureInfo* p_textureInfo); - void EraseFromList(LegoTextureInfo* p_textureInfo); + LegoTextureInfo* GetCached(LegoTextureInfo* p_textureInfo); + void EraseCached(LegoTextureInfo* p_textureInfo); protected: - LegoTextureList m_list; // 0x18 + LegoCachedTextureList m_cached; // 0x18 }; // TEMPLATE: LEGO1 0x10059c50