diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a47fc78..d96b0c61 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,6 +109,7 @@ add_library(lego1 SHARED LEGO1/mxdiskstreamprovider.cpp LEGO1/mxdisplaysurface.cpp LEGO1/mxdsaction.cpp + LEGO1/mxdsactionlist.cpp LEGO1/mxdsanim.cpp LEGO1/mxdschunk.cpp LEGO1/mxdsevent.cpp diff --git a/LEGO1/mxdsactionlist.cpp b/LEGO1/mxdsactionlist.cpp new file mode 100644 index 00000000..86c75365 --- /dev/null +++ b/LEGO1/mxdsactionlist.cpp @@ -0,0 +1,21 @@ +#include "mxdsactionlist.h" +#include "mxdsaction.h" + +DECOMP_SIZE_ASSERT(MxDSActionList, 0x1c); + +// OFFSET: LEGO1 0x100c9c90 +MxS8 MxDSActionList::Compare(MxDSAction *p_var0, MxDSAction *p_var1) +{ + if (p_var1 == p_var0) + return 0; + if (p_var1 <= p_var0) + return 1; + return -1; +} + +// OFFSET: LEGO1 0x100c9cb0 +void MxDSActionList::Destroy(MxDSAction *p_action) +{ + if (p_action) + delete p_action; +} \ No newline at end of file diff --git a/LEGO1/mxdsactionlist.h b/LEGO1/mxdsactionlist.h new file mode 100644 index 00000000..4ae6e2a6 --- /dev/null +++ b/LEGO1/mxdsactionlist.h @@ -0,0 +1,28 @@ +#ifndef MXDSACTIONLIST_H +#define MXDSACTIONLIST_H + +#include "decomp.h" +#include "mxlist.h" + +class MxDSAction; + +// VTABLE 0x100dced8 +// SIZE 0x1c +class MxDSActionList : public MxList +{ +public: + MxDSActionList() { + this->m_unk18 = 0; + } + + virtual MxS8 Compare(MxDSAction *, MxDSAction *); // +0x14 + + static void Destroy(MxDSAction *p_action); + +private: + undefined m_unk18; +}; + +typedef MxListCursorChild MxDSActionListCursor; + +#endif // MXDSACTIONLIST_H diff --git a/LEGO1/mxdsmultiaction.cpp b/LEGO1/mxdsmultiaction.cpp index 0328a5fd..6cbccc39 100644 --- a/LEGO1/mxdsmultiaction.cpp +++ b/LEGO1/mxdsmultiaction.cpp @@ -5,12 +5,42 @@ DECOMP_SIZE_ASSERT(MxDSMultiAction, 0x9c) // OFFSET: LEGO1 0x100c9b90 MxDSMultiAction::MxDSMultiAction() { - // TODO this->SetType(MxDSType_MultiAction); + this->m_actions = new MxDSActionList; + this->m_actions->SetDestroy(MxDSActionList::Destroy); } -// OFFSET: LEGO1 0x100ca060 STUB +// OFFSET: LEGO1 0x100ca060 MxDSMultiAction::~MxDSMultiAction() { - // TODO + if (this->m_actions) + delete this->m_actions; } + +// OFFSET: LEGO1 0x100ca5e0 +undefined4 MxDSMultiAction::unk14() +{ + undefined4 result = MxDSAction::unk14(); + + MxDSActionListCursor cursor(this->m_actions); + MxDSAction *action; + while (cursor.Next(action)) + result += action->unk14(); + + return result; +} + +// OFFSET: LEGO1 0x100ca6c0 +MxU32 MxDSMultiAction::GetSizeOnDisk() +{ + MxU32 totalSizeOnDisk = MxDSAction::GetSizeOnDisk() + 16; + + MxDSActionListCursor cursor(this->m_actions); + MxDSAction *action; + while (cursor.Next(action)) + totalSizeOnDisk += action->GetSizeOnDisk(); + + this->m_sizeOnDisk = totalSizeOnDisk - MxDSAction::GetSizeOnDisk(); + + return totalSizeOnDisk; +} \ No newline at end of file diff --git a/LEGO1/mxdsmultiaction.h b/LEGO1/mxdsmultiaction.h index 6e049965..7d4312f4 100644 --- a/LEGO1/mxdsmultiaction.h +++ b/LEGO1/mxdsmultiaction.h @@ -2,7 +2,7 @@ #define MXDSMULTIACTION_H #include "mxdsaction.h" -#include "decomp.h" +#include "mxdsactionlist.h" // VTABLE 0x100dcef0 // SIZE 0x9c @@ -25,8 +25,12 @@ class MxDSMultiAction : public MxDSAction return !strcmp(name, MxDSMultiAction::ClassName()) || MxDSAction::IsA(name); } - undefined4 m_unk0x94; - undefined4 m_unk0x98; + virtual undefined4 unk14(); // vtable+14; + virtual MxU32 GetSizeOnDisk(); // vtable+18; + +private: + MxU32 m_sizeOnDisk; + MxDSActionList *m_actions; }; #endif // MXDSMULTIACTION_H diff --git a/LEGO1/mxlist.h b/LEGO1/mxlist.h index 013ef852..a4231c92 100644 --- a/LEGO1/mxlist.h +++ b/LEGO1/mxlist.h @@ -60,6 +60,7 @@ class MxList : protected MxListParent void Append(T*); MxU32 GetCount() { return m_count; } + void SetDestroy(void (*p_customDestructor)(T *)) { this->m_customDestructor = p_customDestructor; } friend class MxListCursor;