From a4c4ee656f14cbe270fc10d145c200c58e1f5031 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Mon, 15 Jan 2024 15:44:04 -0500 Subject: [PATCH] Implement lists used in LegoWorld (#443) * Add LegoEntityList * Add MxCoreList, match LegoWorld::Create --- LEGO1/lego/legoomni/include/legoentitylist.h | 92 +++++++++++++++++++ LEGO1/lego/legoomni/include/legoworld.h | 10 ++- LEGO1/lego/legoomni/include/legoworldlist.h | 24 ++--- LEGO1/lego/legoomni/src/entity/legoworld.cpp | 36 +++++--- LEGO1/omni/include/mxcorelist.h | 95 ++++++++++++++++++++ 5 files changed, 229 insertions(+), 28 deletions(-) create mode 100644 LEGO1/lego/legoomni/include/legoentitylist.h create mode 100644 LEGO1/omni/include/mxcorelist.h diff --git a/LEGO1/lego/legoomni/include/legoentitylist.h b/LEGO1/lego/legoomni/include/legoentitylist.h new file mode 100644 index 00000000..1d29e65d --- /dev/null +++ b/LEGO1/lego/legoomni/include/legoentitylist.h @@ -0,0 +1,92 @@ +#ifndef LEGOENTITYLIST_H +#define LEGOENTITYLIST_H + +#include "mxlist.h" +#include "mxtypes.h" + +class LegoEntity; + +// VTABLE: LEGO1 0x100d6410 +// class MxCollection + +// VTABLE: LEGO1 0x100d6428 +// class MxList + +// VTABLE: LEGO1 0x100d6440 +// class MxPtrList + +// VTABLE: LEGO1 0x100d6458 +// SIZE 0x18 +class LegoEntityList : public MxPtrList { +public: + LegoEntityList(MxBool p_ownership = FALSE) : MxPtrList(p_ownership) {} + + // FUNCTION: LEGO1 0x1001e2d0 + virtual MxS8 Compare(LegoEntity* p_a, LegoEntity* p_b) override + { + return p_a == p_b ? 0 : p_a < p_b ? -1 : 1; + }; // vtable+0x14 +}; + +// VTABLE: LEGO1 0x100d64e8 +// class MxListCursor + +// VTABLE: LEGO1 0x100d64b8 +// class MxPtrListCursor + +// VTABLE: LEGO1 0x100d64d0 +// SIZE 0x10 +class LegoEntityListCursor : public MxPtrListCursor { +public: + LegoEntityListCursor(LegoEntityList* p_list) : MxPtrListCursor(p_list){}; +}; + +// TEMPLATE: LEGO1 0x1001e2f0 +// MxCollection::Compare + +// TEMPLATE: LEGO1 0x1001e300 +// MxCollection::~MxCollection + +// TEMPLATE: LEGO1 0x1001e350 +// MxCollection::Destroy + +// TEMPLATE: LEGO1 0x1001e360 +// MxList::~MxList + +// TEMPLATE: LEGO1 0x1001e3f0 +// MxPtrList::Destroy + +// SYNTHETIC: LEGO1 0x1001e400 +// LegoEntityList::`scalar deleting destructor' + +// TEMPLATE: LEGO1 0x1001e470 +// MxPtrList::~MxPtrList + +// SYNTHETIC: LEGO1 0x1001e4c0 +// MxCollection::`scalar deleting destructor' + +// SYNTHETIC: LEGO1 0x1001e530 +// MxList::`scalar deleting destructor' + +// SYNTHETIC: LEGO1 0x1001e5e0 +// MxPtrList::`scalar deleting destructor' + +// SYNTHETIC: LEGO1 0x1001f110 +// LegoEntityListCursor::`scalar deleting destructor' + +// FUNCTION: LEGO1 0x1001f180 +// MxPtrListCursor::~MxPtrListCursor + +// SYNTHETIC: LEGO1 0x1001f1d0 +// MxListCursor::`scalar deleting destructor' + +// SYNTHETIC: LEGO1 0x1001f240 +// MxPtrListCursor::`scalar deleting destructor' + +// FUNCTION: LEGO1 0x1001f2b0 +// MxListCursor::~MxListCursor + +// FUNCTION: LEGO1 0x1001edc6 +// LegoEntityListCursor::~LegoEntityListCursor + +#endif // LEGOENTITYLIST_H diff --git a/LEGO1/lego/legoomni/include/legoworld.h b/LEGO1/lego/legoomni/include/legoworld.h index 7cacf766..4ac7ca37 100644 --- a/LEGO1/lego/legoomni/include/legoworld.h +++ b/LEGO1/lego/legoomni/include/legoworld.h @@ -3,7 +3,9 @@ #include "legocameracontroller.h" #include "legoentity.h" +#include "legoentitylist.h" #include "legopathcontrollerlist.h" +#include "mxcorelist.h" #include "mxpresenter.h" #include "mxpresenterlist.h" @@ -38,8 +40,10 @@ class LegoWorld : public LegoEntity { virtual LegoCameraController* VTable0x54(); // vtable+0x54 virtual void VTable0x58(MxCore* p_object); // vtable+0x58 virtual MxBool VTable0x5c(); // vtable+0x5c + // FUNCTION: LEGO1 0x100010a0 - virtual void VTable0x60() {} // vtable+0x60 + virtual void VTable0x60() {} // vtable+0x60 + virtual MxBool VTable0x64(); // vtable+0x64 virtual void VTable0x68(MxBool p_add); // vtable+0x68 @@ -59,7 +63,9 @@ class LegoWorld : public LegoEntity { LegoPathControllerList m_list0x68; // 0x68 MxPresenterList m_list0x80; // 0x80 LegoCameraController* m_cameraController; // 0x98 - undefined m_unk0x9c[0x1c]; // 0x9c + LegoEntityList* m_entityList; // 0x9c + MxCoreList* m_coreList; // 0xa0 + undefined m_unk0xa4[0x14]; // 0xa4 MxPresenterList m_list0xb8; // 0xb8 undefined m_unk0xd0[0x1c]; // 0xd0 undefined4 m_unk0xec; // 0xec diff --git a/LEGO1/lego/legoomni/include/legoworldlist.h b/LEGO1/lego/legoomni/include/legoworldlist.h index e8acbb69..2e52de47 100644 --- a/LEGO1/lego/legoomni/include/legoworldlist.h +++ b/LEGO1/lego/legoomni/include/legoworldlist.h @@ -41,6 +41,18 @@ class LegoWorldListCursor : public MxPtrListCursor { LegoWorldListCursor(LegoWorldList* p_list) : MxPtrListCursor(p_list){}; }; +// SYNTHETIC: LEGO1 0x1003e870 +// LegoWorldListCursor::`scalar deleting destructor' + +// FUNCTION: LEGO1 0x1003e8e0 +// MxPtrListCursor::~MxPtrListCursor + +// FUNCTION: LEGO1 0x1003ea10 +// MxListCursor::~MxListCursor + +// FUNCTION: LEGO1 0x1003ea60 +// LegoWorldListCursor::~LegoWorldListCursor + // TEMPLATE: LEGO1 0x100598f0 // MxCollection::Compare @@ -65,16 +77,4 @@ class LegoWorldListCursor : public MxPtrListCursor { // SYNTHETIC: LEGO1 0x10059be0 // MxPtrList::`scalar deleting destructor' -// SYNTHETIC: LEGO1 0x1003e870 -// LegoWorldListCursor::`scalar deleting destructor' - -// FUNCTION: LEGO1 0x1003e8e0 -// MxPtrListCursor::~MxPtrListCursor - -// FUNCTION: LEGO1 0x1003ea10 -// MxListCursor::~MxListCursor - -// FUNCTION: LEGO1 0x1003ea60 -// LegoWorldListCursor::~LegoWorldListCursor - #endif // LEGOWORLDLIST_H diff --git a/LEGO1/lego/legoomni/src/entity/legoworld.cpp b/LEGO1/lego/legoomni/src/entity/legoworld.cpp index c7a2608a..c9e24038 100644 --- a/LEGO1/lego/legoomni/src/entity/legoworld.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoworld.cpp @@ -40,29 +40,37 @@ LegoWorld::~LegoWorld() // TODO } -// STUB: LEGO1 0x1001e0b0 +// FUNCTION: LEGO1 0x1001e0b0 MxResult LegoWorld::Create(MxDSAction& p_dsAction) { MxEntity::Create(p_dsAction); - // TODO: Intitialize lists + m_entityList = new LegoEntityList(TRUE); - if (VTable0x54()) { - if (p_dsAction.GetFlags() & MxDSAction::Flag_Enabled) { - if (GetCurrentWorld()) { - GetCurrentWorld()->VTable0x68(0); - } + if (!m_entityList) + return FAILURE; - SetCurrentWorld(this); - ControlManager()->FUN_10028df0(&m_list0xb8); + m_coreList = new MxCoreList(TRUE); + + if (!m_coreList) + return FAILURE; + + if (!VTable0x54()) + return FAILURE; + + if (p_dsAction.GetFlags() & MxDSAction::Flag_Enabled) { + if (GetCurrentWorld()) { + GetCurrentWorld()->VTable0x68(0); } - SetIsWorldActive(TRUE); - m_unk0xec = -1; - - return SUCCESS; + SetCurrentWorld(this); + ControlManager()->FUN_10028df0(&m_list0xb8); } - return FAILURE; + + SetIsWorldActive(TRUE); + m_unk0xec = -1; + + return SUCCESS; } // FUNCTION: LEGO1 0x1001f5e0 diff --git a/LEGO1/omni/include/mxcorelist.h b/LEGO1/omni/include/mxcorelist.h new file mode 100644 index 00000000..15ae7c9b --- /dev/null +++ b/LEGO1/omni/include/mxcorelist.h @@ -0,0 +1,95 @@ +#ifndef MXCORELIST_H +#define MXCORELIST_H + +#include "mxlist.h" +#include "mxtypes.h" + +class MxCore; + +// VTABLE: LEGO1 0x100d63b0 +// class MxCollection + +// VTABLE: LEGO1 0x100d63c8 +// class MxList + +// VTABLE: LEGO1 0x100d63e0 +// class MxPtrList + +// VTABLE: LEGO1 0x100d63f8 +// SIZE 0x18 +class MxCoreList : public MxPtrList { +public: + MxCoreList(MxBool p_ownership = FALSE) : MxPtrList(p_ownership) {} + + // FUNCTION: LEGO1 0x1001e650 + virtual MxS8 Compare(MxCore* p_a, MxCore* p_b) override + { + return p_a == p_b ? 0 : p_a < p_b ? -1 : 1; + }; // vtable+0x14 +}; + +// VTABLE: LEGO1 0x100d64a0 +// class MxListCursor + +// VTABLE: LEGO1 0x100d6500 +// class MxPtrListCursor + +// VTABLE: LEGO1 0x100d6518 +// SIZE 0x10 +class MxCoreListCursor : public MxPtrListCursor { +public: + MxCoreListCursor(MxCoreList* p_list) : MxPtrListCursor(p_list){}; +}; + +// TEMPLATE: LEGO1 0x1001e670 +// MxCollection::Compare + +// TEMPLATE: LEGO1 0x1001e680 +// MxCollection::~MxCollection + +// TEMPLATE: LEGO1 0x1001e6d0 +// MxCollection::Destroy + +// TEMPLATE: LEGO1 0x1001e6e0 +// MxList::~MxList + +// TEMPLATE: LEGO1 0x1001e770 +// MxPtrList::Destroy + +// SYNTHETIC: LEGO1 0x1001e780 +// MxCoreList::`scalar deleting destructor' + +// TEMPLATE: LEGO1 0x1001e7f0 +// MxPtrList::~MxPtrList + +// SYNTHETIC: LEGO1 0x1001e840 +// MxCollection::`scalar deleting destructor' + +// SYNTHETIC: LEGO1 0x1001e8b0 +// MxList::`scalar deleting destructor' + +// SYNTHETIC: LEGO1 0x1001e960 +// MxPtrList::`scalar deleting destructor' + +// SYNTHETIC: LEGO1 0x1001f350 +// MxCoreListCursor::`scalar deleting destructor' + +// FUNCTION: LEGO1 0x1001f3c0 +// MxPtrListCursor::~MxPtrListCursor + +// SYNTHETIC: LEGO1 0x1001f410 +// MxListCursor::`scalar deleting destructor' + +// SYNTHETIC: LEGO1 0x1001f480 +// MxPtrListCursor::`scalar deleting destructor' + +// FUNCTION: LEGO1 0x1001f4f0 +// MxListCursor::~MxListCursor + +// FUNCTION: LEGO1 0x1001f540 +// MxCoreListCursor::~MxCoreListCursor + +// TEMPLATE: LEGO1 0x10020840 +// MxListCursor::MxListCursor + +#endif // MXCORELIST_H