From 4df7dee037771e6641e9e6e5eafd4f804d3240ad Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 27 Jan 2024 10:10:09 -0500 Subject: [PATCH] Implement/match LegoWorld::Remove (#491) * Implement/match LegoWorld::Remove * Fix comparison * Match 100% --- .../legoomni/include/legocachesoundlist.h | 10 +++- LEGO1/lego/legoomni/include/legoentitylist.h | 3 ++ LEGO1/lego/legoomni/include/legoworld.h | 26 ++-------- LEGO1/lego/legoomni/src/entity/legoworld.cpp | 52 ++++++++++++++++++- LEGO1/omni/include/mxpresenterlist.h | 24 +++++++++ 5 files changed, 89 insertions(+), 26 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legocachesoundlist.h b/LEGO1/lego/legoomni/include/legocachesoundlist.h index 13d8f96c..c97d578f 100644 --- a/LEGO1/lego/legoomni/include/legocachesoundlist.h +++ b/LEGO1/lego/legoomni/include/legocachesoundlist.h @@ -74,7 +74,7 @@ class LegoCacheSoundListCursor : public MxPtrListCursor { // SYNTHETIC: LEGO1 0x1001f350 // LegoCacheSoundListCursor::`scalar deleting destructor' -// FUNCTION: LEGO1 0x1001f3c0 +// TEMPLATE: LEGO1 0x1001f3c0 // MxPtrListCursor::~MxPtrListCursor // SYNTHETIC: LEGO1 0x1001f410 @@ -83,7 +83,7 @@ class LegoCacheSoundListCursor : public MxPtrListCursor { // SYNTHETIC: LEGO1 0x1001f480 // MxPtrListCursor::`scalar deleting destructor' -// FUNCTION: LEGO1 0x1001f4f0 +// TEMPLATE: LEGO1 0x1001f4f0 // MxListCursor::~MxListCursor // FUNCTION: LEGO1 0x1001f540 @@ -95,4 +95,10 @@ class LegoCacheSoundListCursor : public MxPtrListCursor { // TEMPLATE: LEGO1 0x100224e0 // MxList::InsertEntry +// TEMPLATE: LEGO1 0x10022590 +// MxListCursor::Find + +// TEMPLATE: LEGO1 0x10022680 +// MxList::DeleteEntry + #endif // LEGOCACHESOUNDLIST_H diff --git a/LEGO1/lego/legoomni/include/legoentitylist.h b/LEGO1/lego/legoomni/include/legoentitylist.h index 4f212279..aa691da8 100644 --- a/LEGO1/lego/legoomni/include/legoentitylist.h +++ b/LEGO1/lego/legoomni/include/legoentitylist.h @@ -95,4 +95,7 @@ class LegoEntityListCursor : public MxPtrListCursor { // TEMPLATE: LEGO1 0x10022430 // MxList::InsertEntry +// TEMPLATE: LEGO1 0x10022630 +// MxList::DeleteEntry + #endif // LEGOENTITYLIST_H diff --git a/LEGO1/lego/legoomni/include/legoworld.h b/LEGO1/lego/legoomni/include/legoworld.h index 074728e3..51b47fbf 100644 --- a/LEGO1/lego/legoomni/include/legoworld.h +++ b/LEGO1/lego/legoomni/include/legoworld.h @@ -15,7 +15,7 @@ class LegoPathBoundary; class LegoHideAnimPresenter; struct CoreSetCompare { - MxS32 operator()(MxCore* const& p_a, MxCore* const& p_b) const { return p_a > p_b; } + MxS32 operator()(MxCore* const& p_a, MxCore* const& p_b) const { return (MxS32) p_a < (MxS32) p_b; } }; typedef set MxCoreSet; @@ -122,27 +122,6 @@ class LegoWorld : public LegoEntity { // TEMPLATE: LEGO1 0x1001df00 // Set::~Set -// SYNTHETIC: LEGO1 0x1001eed0 -// MxPresenterListCursor::`scalar deleting destructor' - -// TEMPLATE: LEGO1 0x1001ef40 -// MxPtrListCursor::~MxPtrListCursor - -// SYNTHETIC: LEGO1 0x1001ef90 -// MxListCursor::`scalar deleting destructor' - -// SYNTHETIC: LEGO1 0x1001f000 -// MxPtrListCursor::`scalar deleting destructor' - -// TEMPLATE: LEGO1 0x1001f070 -// MxListCursor::~MxListCursor - -// FUNCTION: LEGO1 0x1001f0c0 -// MxPresenterListCursor::~MxPresenterListCursor - -// TEMPLATE: LEGO1 0x10020760 -// MxListCursor::MxListCursor - // TEMPLATE: LEGO1 0x100208b0 // _Tree >::_Kfn,CoreSetCompare,allocator >::insert @@ -163,6 +142,9 @@ class LegoWorld : public LegoEntity { // TEMPLATE: LEGO1 0x10020eb0 // _Tree >::_Kfn,CoreSetCompare,allocator >::_Rrotate +// TEMPLATE: LEGO1 0x10021340 +// _Tree >::_Kfn,CoreSetCompare,allocator >::find + // TEMPLATE: LEGO1 0x10022360 // _Construct diff --git a/LEGO1/lego/legoomni/src/entity/legoworld.cpp b/LEGO1/lego/legoomni/src/entity/legoworld.cpp index a39a957e..7454e5cd 100644 --- a/LEGO1/lego/legoomni/src/entity/legoworld.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoworld.cpp @@ -7,6 +7,7 @@ #include "legoutil.h" #include "legovideomanager.h" #include "mxactionnotificationparam.h" +#include "mxcontrolpresenter.h" #include "mxnotificationmanager.h" #include "mxnotificationparam.h" #include "mxomni.h" @@ -215,10 +216,57 @@ void LegoWorld::Add(MxCore* p_object) } } -// STUB: LEGO1 0x10020f10 +// FUNCTION: LEGO1 0x10020f10 void LegoWorld::Remove(MxCore* p_object) { - // TODO + if (p_object) { + MxCoreSet::iterator it; + + if (p_object->IsA("MxControlPresenter")) { + MxPresenterListCursor cursor(&m_controlPresenters); + + if (cursor.Find((MxControlPresenter*) p_object)) { + cursor.Detach(); + ((MxControlPresenter*) p_object)->GetAction()->SetOrigin(Lego()); + ((MxControlPresenter*) p_object)->VTable0x68(TRUE); + } + } + else if (p_object->IsA("LegoLocomotionAnimPresenter") || p_object->IsA("LegoHideAnimPresenter") || p_object->IsA("LegoLoopingAnimPresenter")) { + MxPresenterListCursor cursor(&m_animPresenters); + + if (cursor.Find((MxPresenter*) p_object)) + cursor.Detach(); + + if (p_object->IsA("LegoHideAnimPresenter")) + m_hideAnimPresenter = NULL; + } + else if (p_object->IsA("MxEntity")) { + if (p_object->IsA("LegoPathActor")) + FUN_1001fc80((IslePathActor*) p_object); + + if (m_entityList) { + LegoEntityListCursor cursor(m_entityList); + + if (cursor.Find((LegoEntity*) p_object)) + cursor.Detach(); + } + } + else if (p_object->IsA("LegoCacheSound")) { + LegoCacheSoundListCursor cursor(m_cacheSoundList); + + if (cursor.Find((LegoCacheSound*) p_object)) + cursor.Detach(); + } + else { + it = m_set0xa8.find(p_object); + if (it != m_set0xa8.end()) + m_set0xa8.erase(it); + } + + it = m_set0xd0.find(p_object); + if (it != m_set0xd0.end()) + m_set0xd0.erase(it); + } } // FUNCTION: LEGO1 0x100213a0 diff --git a/LEGO1/omni/include/mxpresenterlist.h b/LEGO1/omni/include/mxpresenterlist.h index 238dedfb..8b22a18b 100644 --- a/LEGO1/omni/include/mxpresenterlist.h +++ b/LEGO1/omni/include/mxpresenterlist.h @@ -71,7 +71,31 @@ class MxPresenterListCursor : public MxPtrListCursor { // SYNTHETIC: LEGO1 0x1001d100 // MxPresenterList::~MxPresenterList +// SYNTHETIC: LEGO1 0x1001eed0 +// MxPresenterListCursor::`scalar deleting destructor' + +// TEMPLATE: LEGO1 0x1001ef40 +// MxPtrListCursor::~MxPtrListCursor + +// SYNTHETIC: LEGO1 0x1001ef90 +// MxListCursor::`scalar deleting destructor' + +// SYNTHETIC: LEGO1 0x1001f000 +// MxPtrListCursor::`scalar deleting destructor' + +// TEMPLATE: LEGO1 0x1001f070 +// MxListCursor::~MxListCursor + +// FUNCTION: LEGO1 0x1001f0c0 +// MxPresenterListCursor::~MxPresenterListCursor + +// TEMPLATE: LEGO1 0x10020760 +// MxListCursor::MxListCursor + // TEMPLATE: LEGO1 0x10022380 // MxList::InsertEntry +// TEMPLATE: LEGO1 0x100225e0 +// MxList::DeleteEntry + #endif // MXPRESENTERLIST_H