From 7f7e6e37dd73e85c70103332964977c5e330b042 Mon Sep 17 00:00:00 2001 From: Misha <106913236+MishaProductions@users.noreply.github.com> Date: Sat, 13 Jan 2024 20:34:54 -0500 Subject: [PATCH] implement LegoOmni::FindByEntityIdOrAtomId (#435) * push changes * Match and add annotations * Fix annotations --------- Co-authored-by: Christian Semmler --- LEGO1/lego/legoomni/include/legoworldlist.h | 25 +++++++++++++++++++++ LEGO1/lego/legoomni/src/main/legoomni.cpp | 15 +++++++++++-- LEGO1/omni/include/mxdsactionlist.h | 1 + LEGO1/omni/include/mxentity.h | 3 +++ LEGO1/omni/include/mxlist.h | 3 +++ LEGO1/omni/include/mxstreamchunklist.h | 1 + LEGO1/omni/include/mxstringlist.h | 1 + LEGO1/omni/src/action/mxdsselectaction.cpp | 2 ++ 8 files changed, 49 insertions(+), 2 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoworldlist.h b/LEGO1/lego/legoomni/include/legoworldlist.h index 22cf5838..e8acbb69 100644 --- a/LEGO1/lego/legoomni/include/legoworldlist.h +++ b/LEGO1/lego/legoomni/include/legoworldlist.h @@ -28,6 +28,19 @@ public: }; // vtable+0x14 }; +// VTABLE: LEGO1 0x100d75b8 +// class MxListCursor + +// VTABLE: LEGO1 0x100d7588 +// class MxPtrListCursor + +// VTABLE: LEGO1 0x100d75a0 +// SIZE 0x10 +class LegoWorldListCursor : public MxPtrListCursor { +public: + LegoWorldListCursor(LegoWorldList* p_list) : MxPtrListCursor(p_list){}; +}; + // TEMPLATE: LEGO1 0x100598f0 // MxCollection::Compare @@ -52,4 +65,16 @@ public: // 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/main/legoomni.cpp b/LEGO1/lego/legoomni/src/main/legoomni.cpp index ef7cca9b..5bb47d0c 100644 --- a/LEGO1/lego/legoomni/src/main/legoomni.cpp +++ b/LEGO1/lego/legoomni/src/main/legoomni.cpp @@ -23,6 +23,7 @@ #include "mxtransitionmanager.h" DECOMP_SIZE_ASSERT(LegoWorldList, 0x18); +DECOMP_SIZE_ASSERT(LegoWorldListCursor, 0x10); // GLOBAL: LEGO1 0x100f451c MxAtomId* g_copterScript = NULL; @@ -597,10 +598,20 @@ void LegoOmni::RemoveWorld(const MxAtomId&, MxLong) // TODO } -// STUB: LEGO1 0x1005b0c0 +// FUNCTION: LEGO1 0x1005b0c0 LegoEntity* LegoOmni::FindByEntityIdOrAtomId(const MxAtomId& p_atom, MxS32 p_entityid) { - // TODO + if (m_worldList) { + LegoWorld* world; + LegoWorldListCursor cursor(m_worldList); + + while (cursor.Next(world)) { + if ((p_entityid == -1 || world->GetEntityId() == p_entityid) && + (!p_atom.GetInternal() || world->GetAtom() == p_atom)) + return world; + } + } + return NULL; } diff --git a/LEGO1/omni/include/mxdsactionlist.h b/LEGO1/omni/include/mxdsactionlist.h index fbccd5cf..60c3db6d 100644 --- a/LEGO1/omni/include/mxdsactionlist.h +++ b/LEGO1/omni/include/mxdsactionlist.h @@ -35,6 +35,7 @@ private: // class MxListCursor // VTABLE: LEGO1 0x100d7e50 +// SIZE 0x10 class MxDSActionListCursor : public MxListCursor { public: MxDSActionListCursor(MxDSActionList* p_list) : MxListCursor(p_list){}; diff --git a/LEGO1/omni/include/mxentity.h b/LEGO1/omni/include/mxentity.h index 40742896..cc77cea2 100644 --- a/LEGO1/omni/include/mxentity.h +++ b/LEGO1/omni/include/mxentity.h @@ -45,6 +45,9 @@ public: return SUCCESS; } + inline MxS32 GetEntityId() { return m_mxEntityId; } + inline MxAtomId& GetAtom() { return m_atom; } + protected: MxS32 m_mxEntityId; // 0x8 MxAtomId m_atom; // 0xc diff --git a/LEGO1/omni/include/mxlist.h b/LEGO1/omni/include/mxlist.h index 911d5a36..99330975 100644 --- a/LEGO1/omni/include/mxlist.h +++ b/LEGO1/omni/include/mxlist.h @@ -69,6 +69,7 @@ protected: MxListEntry* InsertEntry(T, MxListEntry*, MxListEntry*); }; +// SIZE 0x18 template class MxPtrList : public MxList { public: @@ -82,6 +83,7 @@ public: } }; +// SIZE 0x10 template class MxListCursor : public MxCore { public: @@ -128,6 +130,7 @@ private: MxListEntry* m_match; // 0x0c }; +// SIZE 0x10 template class MxPtrListCursor : public MxListCursor { public: diff --git a/LEGO1/omni/include/mxstreamchunklist.h b/LEGO1/omni/include/mxstreamchunklist.h index 02dcd2d9..12507961 100644 --- a/LEGO1/omni/include/mxstreamchunklist.h +++ b/LEGO1/omni/include/mxstreamchunklist.h @@ -29,6 +29,7 @@ public: }; // VTABLE: LEGO1 0x100dc510 +// SIZE 0x10 class MxStreamChunkListCursor : public MxListCursor { public: MxStreamChunkListCursor(MxStreamChunkList* p_list) : MxListCursor(p_list){}; diff --git a/LEGO1/omni/include/mxstringlist.h b/LEGO1/omni/include/mxstringlist.h index 6e75683d..8651f4c4 100644 --- a/LEGO1/omni/include/mxstringlist.h +++ b/LEGO1/omni/include/mxstringlist.h @@ -9,6 +9,7 @@ class MxStringList : public MxList {}; // VTABLE: LEGO1 0x100dd058 +// SIZE 0x10 class MxStringListCursor : public MxListCursor { public: MxStringListCursor(MxStringList* p_list) : MxListCursor(p_list){}; diff --git a/LEGO1/omni/src/action/mxdsselectaction.cpp b/LEGO1/omni/src/action/mxdsselectaction.cpp index 27f3a9cf..e2db17e2 100644 --- a/LEGO1/omni/src/action/mxdsselectaction.cpp +++ b/LEGO1/omni/src/action/mxdsselectaction.cpp @@ -5,6 +5,8 @@ #include "mxvariabletable.h" DECOMP_SIZE_ASSERT(MxDSSelectAction, 0xb0) +DECOMP_SIZE_ASSERT(MxStringList, 0x18) +DECOMP_SIZE_ASSERT(MxStringListCursor, 0x10) DECOMP_SIZE_ASSERT(MxListEntry, 0x18) // FUNCTION: LEGO1 0x100cb2b0