Implement MxDSSelectAction Clone/operator=/CopyFrom (#154)

This commit is contained in:
Christian Semmler 2023-10-07 14:03:15 -04:00 committed by GitHub
parent e6507b874a
commit 4a674d823b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 116 additions and 38 deletions

View file

@ -163,6 +163,7 @@ add_library(lego1 SHARED
LEGO1/mxstreamcontroller.cpp
LEGO1/mxstreamer.cpp
LEGO1/mxstring.cpp
LEGO1/mxstringlist.cpp
LEGO1/mxthread.cpp
LEGO1/mxticklemanager.cpp
LEGO1/mxtimer.cpp

View file

@ -41,8 +41,8 @@ class MxDSAction : public MxDSObject
return !strcmp(name, MxDSAction::ClassName()) || MxDSObject::IsA(name);
}
virtual MxU32 GetSizeOnDisk(); // vtable+18;
virtual void Deserialize(char **p_source, MxS16 p_unk24); // vtable+1c;
virtual MxU32 GetSizeOnDisk() override; // vtable+18;
virtual void Deserialize(char **p_source, MxS16 p_unk24) override; // vtable+1c;
virtual MxLong GetDuration(); // vtable+24;
virtual void SetDuration(MxLong p_duration); // vtable+28;
virtual MxDSAction *Clone(); // vtable+2c;

View file

@ -27,7 +27,7 @@ class MxDSAnim : public MxDSMediaAction
return !strcmp(name, MxDSAnim::ClassName()) || MxDSMediaAction::IsA(name);
}
virtual MxDSAction *Clone(); // vtable+2c;
virtual MxDSAction *Clone() override; // vtable+2c;
};
#endif // MXDSANIM_H

View file

@ -1,7 +1,6 @@
#ifndef MXDSCHUNK_H
#define MXDSCHUNK_H
#include "mxcore.h"
#include "mxtypes.h"

View file

@ -25,7 +25,7 @@ class MxDSEvent : public MxDSMediaAction
return !strcmp(name, MxDSEvent::ClassName()) || MxDSMediaAction::IsA(name);
}
virtual MxDSAction *Clone(); // vtable+2c;
virtual MxDSAction *Clone() override; // vtable+2c;
};
#endif // MXDSEVENT_H

View file

@ -28,8 +28,8 @@ class MxDSMediaAction : public MxDSAction
return !strcmp(name, MxDSMediaAction::ClassName()) || MxDSAction::IsA(name);
}
virtual MxU32 GetSizeOnDisk(); // vtable+18;
virtual void Deserialize(char **p_source, MxS16 p_unk24); // vtable+1c;
virtual MxU32 GetSizeOnDisk() override; // vtable+18;
virtual void Deserialize(char **p_source, MxS16 p_unk24) override; // vtable+1c;
void CopyMediaSrcPath(const char *p_mediaSrcPath);

View file

@ -28,14 +28,14 @@ class MxDSMultiAction : public MxDSAction
return !strcmp(name, MxDSMultiAction::ClassName()) || MxDSAction::IsA(name);
}
virtual undefined4 unk14(); // vtable+14;
virtual MxU32 GetSizeOnDisk(); // vtable+18;
virtual void Deserialize(char **p_source, MxS16 p_unk24); // vtable+1c;
virtual void SetAtomId(MxAtomId p_atomId); // vtable+20;
virtual MxDSAction *Clone(); // vtable+2c;
virtual void MergeFrom(MxDSAction &p_dsAction); // vtable+30;
virtual MxBool HasId(MxU32 p_objectId); // vtable+34;
virtual void SetSomeTimingField(MxLong p_someTimingField); // vtable+38;
virtual undefined4 unk14() override; // vtable+14;
virtual MxU32 GetSizeOnDisk() override; // vtable+18;
virtual void Deserialize(char **p_source, MxS16 p_unk24) override; // vtable+1c;
virtual void SetAtomId(MxAtomId p_atomId) override; // vtable+20;
virtual MxDSAction *Clone() override; // vtable+2c;
virtual void MergeFrom(MxDSAction &p_dsAction) override; // vtable+30;
virtual MxBool HasId(MxU32 p_objectId) override; // vtable+34;
virtual void SetSomeTimingField(MxLong p_someTimingField) override; // vtable+38;
private:
MxU32 m_sizeOnDisk;

View file

@ -26,7 +26,7 @@ class MxDSObjectAction : public MxDSMediaAction
return !strcmp(name, MxDSObjectAction::ClassName()) || MxDSMediaAction::IsA(name);
}
virtual MxDSAction *Clone(); // vtable+2c;
virtual MxDSAction *Clone() override; // vtable+2c;
virtual void CopyFrom(MxDSObjectAction &p_dsObjectAction); // vtable+44;
};

View file

@ -27,8 +27,8 @@ class MxDSParallelAction : public MxDSMultiAction
return !strcmp(name, MxDSParallelAction::ClassName()) || MxDSMultiAction::IsA(name);
}
virtual MxLong GetDuration(); // vtable+24;
virtual MxDSAction *Clone(); // vtable+2c;
virtual MxLong GetDuration() override; // vtable+24;
virtual MxDSAction *Clone() override; // vtable+2c;
};
#endif // MXDSPARALLELACTION_H

View file

@ -15,3 +15,37 @@ MxDSSelectAction::~MxDSSelectAction()
if (this->m_unk0xac)
delete this->m_unk0xac;
}
// OFFSET: LEGO1 0x100cb950
void MxDSSelectAction::CopyFrom(MxDSSelectAction &p_dsSelectAction)
{
this->m_unk0x9c = p_dsSelectAction.m_unk0x9c;
this->m_unk0xac->DeleteAll();
MxStringListCursor cursor(p_dsSelectAction.m_unk0xac);
MxString string;
while (cursor.Next(string))
this->m_unk0xac->OtherAppend(string);
}
// OFFSET: LEGO1 0x100cbd50
MxDSSelectAction &MxDSSelectAction::operator=(MxDSSelectAction &p_dsSelectAction)
{
if (this != &p_dsSelectAction) {
MxDSParallelAction::operator=(p_dsSelectAction);
this->CopyFrom(p_dsSelectAction);
}
return *this;
}
// OFFSET: LEGO1 0x100cbd80
MxDSAction *MxDSSelectAction::Clone()
{
MxDSSelectAction *clone = new MxDSSelectAction();
if (clone)
*clone = *this;
return clone;
}

View file

@ -13,6 +13,9 @@ class MxDSSelectAction : public MxDSParallelAction
MxDSSelectAction();
virtual ~MxDSSelectAction() override;
void CopyFrom(MxDSSelectAction &p_dsSelectAction);
MxDSSelectAction &operator=(MxDSSelectAction &p_dsSelectAction);
// OFFSET: LEGO1 0x100cb6f0
inline virtual const char *ClassName() const override // vtable+0x0c
{
@ -26,6 +29,11 @@ class MxDSSelectAction : public MxDSParallelAction
return !strcmp(name, MxDSSelectAction::ClassName()) || MxDSParallelAction::IsA(name);
}
//virtual MxU32 GetSizeOnDisk() override; // vtable+18;
//virtual void Deserialize(char **p_source, MxS16 p_unk24) override; // vtable+1c;
//virtual MxLong GetDuration() override; // vtable+24;
virtual MxDSAction *Clone() override; // vtable+2c;
private:
MxString m_unk0x9c;
MxStringList *m_unk0xac;

View file

@ -28,9 +28,9 @@ class MxDSSerialAction : public MxDSMultiAction
return !strcmp(name, MxDSSerialAction::ClassName()) || MxDSMultiAction::IsA(name);
}
virtual MxLong GetDuration(); // vtable+24;
virtual void SetDuration(MxLong p_duration); // vtable+28;
virtual MxDSAction *Clone(); // vtable+2c;
virtual MxLong GetDuration() override; // vtable+24;
virtual void SetDuration(MxLong p_duration) override; // vtable+28;
virtual MxDSAction *Clone() override; // vtable+2c;
private:
MxDSActionListCursor *m_cursor;

View file

@ -27,9 +27,9 @@ class MxDSSound : public MxDSMediaAction
return !strcmp(name, MxDSSound::ClassName()) || MxDSMediaAction::IsA(name);
}
virtual MxU32 GetSizeOnDisk(); // vtable+18;
virtual void Deserialize(char **p_source, MxS16 p_unk24); // vtable+1c;
virtual MxDSAction *Clone(); // vtable+2c;
virtual MxU32 GetSizeOnDisk() override; // vtable+18;
virtual void Deserialize(char **p_source, MxS16 p_unk24) override; // vtable+1c;
virtual MxDSAction *Clone() override; // vtable+2c;
private:
MxU32 m_sizeOnDisk;

View file

@ -27,7 +27,7 @@ class MxDSStill : public MxDSMediaAction
return !strcmp(name, MxDSStill::ClassName()) || MxDSMediaAction::IsA(name);
}
virtual MxDSAction *Clone(); // vtable+2c;
virtual MxDSAction *Clone() override; // vtable+2c;
};
#endif // MXDSSTILL_H

View file

@ -24,7 +24,7 @@ class MxDSStreamingAction : public MxDSAction
return *this;
}
virtual MxBool HasId(MxU32 p_objectId); // vtable+34;
virtual MxBool HasId(MxU32 p_objectId) override; // vtable+34;
MxResult Init();
void SetInternalAction(MxDSAction *p_dsAction);

View file

@ -4,7 +4,6 @@
#include "mxtypes.h"
#include "mxcore.h"
// SIZE 0xc
template <class T>
class MxListEntry
{
@ -15,6 +14,11 @@ class MxListEntry
m_prev = p_prev;
m_next = NULL;
}
MxListEntry(T p_obj, MxListEntry *p_prev, MxListEntry *p_next) {
m_obj = p_obj;
m_prev = p_prev;
m_next = p_next;
}
T GetValue() { return this->m_obj; }
@ -26,7 +30,6 @@ class MxListEntry
MxListEntry *m_next;
};
// VTABLE 0x100d6350
// SIZE 0x10
template <class T>
class MxListParent : public MxCore
@ -46,7 +49,6 @@ class MxListParent : public MxCore
void (*m_customDestructor)(T); // +0xc
};
// VTABLE 0x100d6368
// SIZE 0x18
template <class T>
class MxList : protected MxListParent<T>
@ -60,6 +62,7 @@ class MxList : protected MxListParent<T>
virtual ~MxList();
void Append(T);
void OtherAppend(T p_obj) { _InsertEntry(p_obj, this->m_last, NULL); };
void DeleteAll();
MxU32 GetCount() { return m_count; }
void SetDestroy(void (*p_customDestructor)(T)) { this->m_customDestructor = p_customDestructor; }
@ -71,9 +74,9 @@ class MxList : protected MxListParent<T>
private:
void _DeleteEntry(MxListEntry<T> *match);
void _InsertEntry(T, MxListEntry<T> *, MxListEntry<T> *);
};
// VTABLE 0x100d6488
template <class T>
class MxListCursor : public MxCore
{
@ -96,7 +99,6 @@ class MxListCursor : public MxCore
};
// Unclear purpose
// VTABLE 0x100d6530
template <class T>
class MxListCursorChild : public MxListCursor<T>
{
@ -105,7 +107,6 @@ class MxListCursorChild : public MxListCursor<T>
};
// Unclear purpose
// VTABLE 0x100d6470
template <class T>
class MxListCursorChildChild : public MxListCursorChild<T>
{
@ -152,6 +153,24 @@ inline void MxList<T>::Append(T p_newobj)
this->m_count++;
}
template <class T>
inline void MxList<T>::_InsertEntry(T p_newobj, MxListEntry<T> *p_prev, MxListEntry<T> *p_next)
{
MxListEntry<T> *newEntry = new MxListEntry<T>(p_newobj, p_prev, p_next);
if (p_prev)
p_prev->m_next = newEntry;
else
this->m_first = newEntry;
if (p_next)
p_next->m_prev = newEntry;
else
this->m_last = newEntry;
this->m_count++;
}
template <class T>
inline void MxList<T>::_DeleteEntry(MxListEntry<T> *match)
{
@ -198,7 +217,7 @@ inline MxBool MxListCursor<T>::Next(T& p_obj)
m_match = m_match->m_next;
if (m_match)
p_obj = m_match->m_obj;
p_obj = m_match->GetValue();
return m_match != NULL;
}

View file

@ -56,14 +56,14 @@ void MxString::ToLowerCase()
}
// OFFSET: LEGO1 0x100ae4b0
MxString &MxString::operator=(MxString *param)
MxString &MxString::operator=(MxString &param)
{
if (this->m_data != param->m_data)
if (this->m_data != param.m_data)
{
delete[] this->m_data;
this->m_length = param->m_length;
this->m_length = param.m_length;
this->m_data = new char[this->m_length + 1];
strcpy(this->m_data, param->m_data);
strcpy(this->m_data, param.m_data);
}
return *this;

View file

@ -15,7 +15,7 @@ class MxString : public MxCore
MxString(const char *);
void ToUpperCase();
void ToLowerCase();
MxString& operator=(MxString *);
MxString& operator=(MxString &);
MxString operator+(const char *);
MxString& operator+=(const char *);

5
LEGO1/mxstringlist.cpp Normal file
View file

@ -0,0 +1,5 @@
#include "mxstringlist.h"
#include "decomp.h"
DECOMP_SIZE_ASSERT(MxListEntry<MxString>, 0x18)

View file

@ -8,6 +8,9 @@
// SIZE 0x18
class MxStringList : public MxList<MxString> {};
// VTABLE 0x100dd058
typedef MxListCursorChild<MxString> MxStringListCursor;
// OFFSET: LEGO1 0x100cb3c0 TEMPLATE
// MxListParent<MxString>::Compare
@ -17,6 +20,15 @@ class MxStringList : public MxList<MxString> {};
// OFFSET: LEGO1 0x100cb4c0 TEMPLATE
// MxList<MxString>::~MxList<MxString>
// OFFSET: LEGO1 0x100cbb40 TEMPLATE
// MxList<MxString>::OtherAppend
// OFFSET: LEGO1 0x100cc2d0 TEMPLATE
// MxList<MxString>::_InsertEntry
// OFFSET: LEGO1 0x100cc3c0 TEMPLATE
// MxListEntry<MxString>::MxListEntry<MxString>
// OFFSET: LEGO1 0x100cc450 TEMPLATE
// MxListEntry<MxString>::GetValue