From 939c09139f5ddac54353296d0f3c30e487cce704 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Tue, 14 May 2024 08:13:27 -0400 Subject: [PATCH] Match LegoOmni::Destroy and related (#917) * Match LegoOmni::Destroy and related * Write COMPAT_MODE macro differently * fix lint issue --- .../legoomni/include/legocharactermanager.h | 1 + .../legoomni/include/legopathcontroller.h | 2 ++ .../src/common/legocharactermanager.cpp | 20 +++++++++++++++++++ LEGO1/lego/legoomni/src/main/legomain.cpp | 13 +++++------- .../legoomni/src/paths/legopathcontroller.cpp | 19 ++++++++++++++++++ LEGO1/lego/sources/misc/legocontainer.h | 12 +++++++++++ tools/decomplint/decomplint.py | 1 + 7 files changed, 60 insertions(+), 8 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legocharactermanager.h b/LEGO1/lego/legoomni/include/legocharactermanager.h index 878e1f41..aaeb584d 100644 --- a/LEGO1/lego/legoomni/include/legocharactermanager.h +++ b/LEGO1/lego/legoomni/include/legocharactermanager.h @@ -49,6 +49,7 @@ typedef map LegoCharacterMap; class LegoCharacterManager { public: LegoCharacterManager(); + ~LegoCharacterManager(); MxResult Write(LegoStorage* p_storage); MxResult Read(LegoStorage* p_storage); diff --git a/LEGO1/lego/legoomni/include/legopathcontroller.h b/LEGO1/lego/legoomni/include/legopathcontroller.h index aeb8c03c..46c4935c 100644 --- a/LEGO1/lego/legoomni/include/legopathcontroller.h +++ b/LEGO1/lego/legoomni/include/legopathcontroller.h @@ -103,7 +103,9 @@ class LegoPathController : public MxCore { LegoPathBoundary* GetPathBoundary(const char* p_name); void Enable(MxBool p_enable); void FUN_10046bb0(LegoWorld* p_world); + static MxResult Init(); + static MxResult Reset(); private: void FUN_10046970(); diff --git a/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp b/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp index 3548529e..7b0c3995 100644 --- a/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp @@ -52,6 +52,26 @@ LegoCharacterManager::LegoCharacterManager() VariableTable()->SetVariable(m_customizeAnimFile); } +// FUNCTION: LEGO1 0x10083180 +// FUNCTION: BETA10 0x10073dad +LegoCharacterManager::~LegoCharacterManager() +{ + LegoCharacter* character = NULL; + LegoCharacterMap::iterator it; + + for (it = m_characters->begin(); it != m_characters->end(); it++) { + character = (*it).second; + + RemoveROI(character->m_roi); + + delete[] (*it).first; + delete (*it).second; + } + + delete m_characters; + delete[] g_customizeAnimFile; +} + // FUNCTION: LEGO1 0x10083270 void LegoCharacterManager::Init() { diff --git a/LEGO1/lego/legoomni/src/main/legomain.cpp b/LEGO1/lego/legoomni/src/main/legomain.cpp index 7635ca2c..7b559faa 100644 --- a/LEGO1/lego/legoomni/src/main/legomain.cpp +++ b/LEGO1/lego/legoomni/src/main/legomain.cpp @@ -114,6 +114,7 @@ void LegoOmni::Destroy() } if (m_textureContainer) { + m_textureContainer->Clear(); delete m_textureContainer; m_textureContainer = NULL; } @@ -128,16 +129,10 @@ void LegoOmni::Destroy() m_inputManager = NULL; } - if (m_inputManager) { - delete m_inputManager; - m_inputManager = NULL; - } - - // todo FUN_10046de0 + LegoPathController::Reset(); if (m_bkgAudioManager) { m_bkgAudioManager->Stop(); - delete m_bkgAudioManager; m_bkgAudioManager = NULL; } @@ -150,7 +145,9 @@ void LegoOmni::Destroy() m_action.ClearAtom(); DestroyScripts(); - delete[] m_scripts; + if (m_scripts) { + delete[] m_scripts; + } MxOmni::Destroy(); } diff --git a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp index bc692002..2f8eefe8 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp @@ -428,6 +428,25 @@ MxResult LegoPathController::Init() return SUCCESS; } +// FUNCTION: LEGO1 0x10046de0 +// FUNCTION: BETA10 0x100b779e +MxResult LegoPathController::Reset() +{ + if (g_ctrlBoundariesA == NULL || g_ctrlEdgesA == NULL) { + return FAILURE; + } + + delete[] g_ctrlBoundariesA; + delete[] g_ctrlEdgesA; + delete[] g_ctrlBoundariesB; + delete[] g_ctrlEdgesB; + g_ctrlBoundariesA = NULL; + g_ctrlEdgesA = NULL; + g_ctrlBoundariesB = NULL; + g_ctrlEdgesB = NULL; + return SUCCESS; +} + // FUNCTION: LEGO1 0x10046e50 // FUNCTION: BETA10 0x100b781f MxResult LegoPathController::Read(LegoStorage* p_storage) diff --git a/LEGO1/lego/sources/misc/legocontainer.h b/LEGO1/lego/sources/misc/legocontainer.h index 2b5fc0e1..7ddad1de 100644 --- a/LEGO1/lego/sources/misc/legocontainer.h +++ b/LEGO1/lego/sources/misc/legocontainer.h @@ -45,6 +45,18 @@ class LegoContainer { } } + void Clear() + { +#ifdef COMPAT_MODE + for (typename LegoContainerInfo::iterator it = m_map.begin(); it != m_map.end(); it++) +#else + for (LegoContainerInfo::iterator it = m_map.begin(); it != m_map.end(); it++) +#endif + { + delete (*it).second; + } + } + // FUNCTION: BETA10 0x1007bc00 inline T* Get(const char* p_name) { diff --git a/tools/decomplint/decomplint.py b/tools/decomplint/decomplint.py index 6c7c1b4c..4ff28168 100755 --- a/tools/decomplint/decomplint.py +++ b/tools/decomplint/decomplint.py @@ -81,6 +81,7 @@ def process_files(files, module=None): def main(): args = parse_args() + files_to_check = [] if os.path.isdir(args.target): files_to_check = list(walk_source_dir(args.target)) elif os.path.isfile(args.target) and is_file_cpp(args.target):