Bootstrap MxDSMultiAction

This commit is contained in:
Christian Semmler 2023-09-20 09:18:29 -04:00
parent 1d3c1bdbd1
commit c8f67bb2bb
6 changed files with 91 additions and 3 deletions

View File

@ -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

14
LEGO1/mxdsactionlist.cpp Normal file
View File

@ -0,0 +1,14 @@
#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;
}

25
LEGO1/mxdsactionlist.h Normal file
View File

@ -0,0 +1,25 @@
#ifndef MXDSACTIONLIST_H
#define MXDSACTIONLIST_H
#include "decomp.h"
#include "mxlist.h"
class MxDSAction;
// VTABLE 0x100dced8
// SIZE 0x1c
class MxDSActionList : public MxList<MxDSAction>
{
public:
MxDSActionList() {
unk18 = 0;
}
virtual MxS8 Compare(MxDSAction *, MxDSAction *); // +0x14
undefined unk18;
};
typedef MxListCursorChild<MxDSAction> MxDSActionListCursor;
#endif // MXDSACTIONLIST_H

View File

@ -3,12 +3,49 @@
// OFFSET: LEGO1 0x100c9b90
MxDSMultiAction::MxDSMultiAction()
{
// TODO
this->SetType(MxDSType_MultiAction);
this->m_actions = new MxDSActionList;
this->m_actions->SetDestroy(MxDSMultiAction::DestroyListElement);
}
// OFFSET: LEGO1 0x100ca060 STUB
// OFFSET: LEGO1 0x100c9cb0
void MxDSMultiAction::DestroyListElement(MxDSAction *p_action)
{
if (p_action)
delete p_action;
}
// OFFSET: LEGO1 0x100ca060
MxDSMultiAction::~MxDSMultiAction()
{
// TODO
if (this->m_actions)
delete this->m_actions;
}
// OFFSET: LEGO1 0x100ca5e0
undefined4 MxDSMultiAction::unk14()
{
undefined4 result = MxDSObject::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;
}

View File

@ -2,6 +2,7 @@
#define MXDSMULTIACTION_H
#include "mxdsaction.h"
#include "mxdsactionlist.h"
// VTABLE 0x100dcef0
// SIZE 0x9c
@ -23,6 +24,15 @@ class MxDSMultiAction : public MxDSAction
{
return !strcmp(name, MxDSMultiAction::ClassName()) || MxDSAction::IsA(name);
}
virtual undefined4 unk14(); // vtable+14;
virtual MxU32 GetSizeOnDisk(); // vtable+18;
private:
MxU32 m_sizeOnDisk;
MxDSActionList *m_actions;
static void DestroyListElement(MxDSAction *p_action);
};
#endif // MXDSMULTIACTION_H

View File

@ -60,6 +60,7 @@ class MxList : protected MxListParent<T>
void Append(T*);
MxU32 GetCount() { return m_count; }
void SetDestroy(void (*p_customDestructor)(T *)) { this->m_customDestructor = p_customDestructor; }
friend class MxListCursor<T>;