From 830c0827aff55766894c5f817552ace954eade2c Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Thu, 25 Apr 2024 10:24:06 -0400 Subject: [PATCH] Implement/match LegoAnimPresenter::Destroy (#849) * WIP Destroy * Match --- .../lego/legoomni/include/legoanimpresenter.h | 3 +- .../legoomni/src/video/legoanimpresenter.cpp | 75 ++++++++++++++++++- 2 files changed, 73 insertions(+), 5 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoanimpresenter.h b/LEGO1/lego/legoomni/include/legoanimpresenter.h index 30f858b0..36683461 100644 --- a/LEGO1/lego/legoomni/include/legoanimpresenter.h +++ b/LEGO1/lego/legoomni/include/legoanimpresenter.h @@ -97,6 +97,7 @@ class LegoAnimPresenter : public MxVideoPresenter { void FUN_10069b10(); void FUN_1006a3c0(LegoAnimPresenterMap& p_map, LegoTreeNode* p_node, LegoROI* p_roi); void FUN_1006a4f0(LegoAnimPresenterMap& p_map, LegoAnimNodeData* p_data, const LegoChar* p_und, LegoROI* p_roi); + void FUN_1006aa60(); void FUN_1006ab70(); LegoBool FUN_1006aba0(); MxBool FUN_1006abb0(LegoTreeNode* p_node, LegoROI* p_roi); @@ -123,7 +124,7 @@ class LegoAnimPresenter : public MxVideoPresenter { undefined m_unk0x97; // 0x97 LegoAnimSubstMap* m_substMap; // 0x98 MxS16 m_unk0x9c; // 0x9c - undefined4 m_unk0xa0; // 0xa0 + undefined4* m_unk0xa0; // 0xa0 undefined4 m_unk0xa4; // 0xa4 Mx3DPointFloat m_unk0xa8; // 0xa8 }; diff --git a/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp b/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp index c3b8c107..a038e042 100644 --- a/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp @@ -8,6 +8,7 @@ #include "legovideomanager.h" #include "legoworld.h" #include "misc.h" +#include "mxautolock.h" #include "mxcompositepresenter.h" #include "mxdsanim.h" #include "mxmisc.h" @@ -55,14 +56,74 @@ void LegoAnimPresenter::Init() m_unk0x90 = NULL; m_unk0x94 = 0; m_unk0x96 = TRUE; - m_unk0xa0 = 0; + m_unk0xa0 = NULL; } -// STUB: LEGO1 0x10068770 +// FUNCTION: LEGO1 0x10068770 +// FUNCTION: BETA10 0x1004e833 void LegoAnimPresenter::Destroy(MxBool p_fromDestructor) { - // TODO - MxVideoPresenter::Destroy(p_fromDestructor); + { + AUTOLOCK(m_criticalSection); + + if (m_anim != NULL) { + delete m_anim; + } + + if (m_roiMap != NULL) { + delete[] m_roiMap; + } + + if (m_unk0x70 != NULL) { + delete m_unk0x70; + } + + if (m_unk0x74 != NULL) { + FUN_1006aa60(); + delete m_unk0x74; + } + + if (m_unk0x78 != NULL) { + delete m_unk0x78; + } + + if (m_substMap != NULL) { + MxVariableTable* variableTable = VariableTable(); + + for (LegoAnimSubstMap::iterator it = m_substMap->begin(); it != m_substMap->end(); it++) { + variableTable->SetVariable((*it).first, ""); + + delete[] const_cast((*it).first); + delete[] const_cast((*it).second); + } + + delete m_substMap; + } + + if (m_unk0x90 != NULL) { + for (MxS32 i = 0; i < m_unk0x94; i++) { + if (m_unk0x90[i] != NULL) { + delete[] m_unk0x90[i]; + } + } + + delete[] m_unk0x90; + } + + if (m_unk0x8c != NULL) { + delete[] m_unk0x8c; + } + + if (m_unk0xa0 != NULL) { + delete m_unk0xa0; // TODO + } + + Init(); + } + + if (!p_fromDestructor) { + MxVideoPresenter::Destroy(FALSE); + } } // FUNCTION: LEGO1 0x10068fb0 @@ -453,6 +514,12 @@ void LegoAnimPresenter::FUN_1006a4f0( } } +// STUB: LEGO1 0x1006aa60 +void LegoAnimPresenter::FUN_1006aa60() +{ + // TODO +} + // FUNCTION: LEGO1 0x1006ab70 void LegoAnimPresenter::FUN_1006ab70() {