Reorganize sources and files (#414)

* Reorganize sources

* Refactor

* Remove relative paths

* Renames

* Fix gitignore

* Remove stuff

* Try fixing format script

* Fix format

* Fix format

* Fix naming script

* Test format

* Fix format
This commit is contained in:
Christian Semmler
2024-01-08 04:58:49 -05:00
committed by GitHub
parent 6a85e62406
commit c47206617d
447 changed files with 347 additions and 346 deletions

View File

@@ -0,0 +1,231 @@
#include "mxdsaction.h"
#include "legoutil.h"
#include "mxomni.h"
#include "mxtimer.h"
#include <float.h>
#include <limits.h>
DECOMP_SIZE_ASSERT(MxDSAction, 0x94)
// GLOBAL: LEGO1 0x10101410
MxU16 g_sep = TWOCC(',', ' ');
// FUNCTION: LEGO1 0x100ad810
MxDSAction::MxDSAction()
{
this->m_flags = MxDSAction::Flag_Enabled;
this->m_startTime = INT_MIN;
this->m_extraData = NULL;
this->m_extraLength = 0;
this->m_duration = INT_MIN;
this->m_loopCount = -1;
this->SetType(MxDSType_Action);
this->m_location.Fill(FLT_MAX);
this->m_direction.Fill(FLT_MAX);
this->m_up.Fill(FLT_MAX);
this->m_unk0x84 = NULL;
this->m_unk0x88 = 0;
this->m_origin = NULL;
this->m_unk0x90 = INT_MIN;
}
// FUNCTION: LEGO1 0x100ad940
MxLong MxDSAction::GetDuration()
{
return this->m_duration;
}
// FUNCTION: LEGO1 0x100ad950
void MxDSAction::SetDuration(MxLong p_duration)
{
this->m_duration = p_duration;
}
// FUNCTION: LEGO1 0x100ad960
MxBool MxDSAction::HasId(MxU32 p_objectId)
{
return this->GetObjectId() == p_objectId;
}
// FUNCTION: LEGO1 0x100ada40
void MxDSAction::SetUnknown90(MxLong p_unk0x90)
{
this->m_unk0x90 = p_unk0x90;
}
// FUNCTION: LEGO1 0x100ada50
MxLong MxDSAction::GetUnknown90()
{
return this->m_unk0x90;
}
// FUNCTION: LEGO1 0x100ada80
MxDSAction::~MxDSAction()
{
delete[] this->m_extraData;
}
// FUNCTION: LEGO1 0x100adaf0
void MxDSAction::CopyFrom(MxDSAction& p_dsAction)
{
this->SetObjectId(p_dsAction.GetObjectId());
this->m_flags = p_dsAction.m_flags;
this->m_startTime = p_dsAction.m_startTime;
this->m_duration = p_dsAction.m_duration;
this->m_loopCount = p_dsAction.m_loopCount;
this->m_location.CopyFrom(p_dsAction.m_location);
this->m_direction.CopyFrom(p_dsAction.m_direction);
this->m_up.CopyFrom(p_dsAction.m_up);
AppendData(p_dsAction.m_extraLength, p_dsAction.m_extraData);
this->m_unk0x84 = p_dsAction.m_unk0x84;
this->m_unk0x88 = p_dsAction.m_unk0x88;
this->m_origin = p_dsAction.m_origin;
this->m_unk0x90 = p_dsAction.m_unk0x90;
}
// FUNCTION: LEGO1 0x100adbe0
MxU32 MxDSAction::GetSizeOnDisk()
{
MxU32 totalSizeOnDisk;
totalSizeOnDisk = MxDSObject::GetSizeOnDisk() + 90 + this->m_extraLength;
this->m_sizeOnDisk = totalSizeOnDisk - MxDSObject::GetSizeOnDisk();
return totalSizeOnDisk;
}
// FUNCTION: LEGO1 0x100adc10
MxDSAction& MxDSAction::operator=(MxDSAction& p_dsAction)
{
if (this == &p_dsAction)
return *this;
MxDSObject::operator=(p_dsAction);
this->CopyFrom(p_dsAction);
return *this;
}
// FUNCTION: LEGO1 0x100adc40
MxDSAction* MxDSAction::Clone()
{
MxDSAction* clone = new MxDSAction();
if (clone)
*clone = *this;
return clone;
}
// FUNCTION: LEGO1 0x100adcd0
MxLong MxDSAction::GetElapsedTime()
{
return Timer()->GetTime() - this->m_unk0x90;
}
// FUNCTION: LEGO1 0x100add00
void MxDSAction::MergeFrom(MxDSAction& p_dsAction)
{
if (p_dsAction.m_startTime != INT_MIN)
this->m_startTime = p_dsAction.m_startTime;
if (p_dsAction.GetDuration() != INT_MIN)
this->m_duration = p_dsAction.GetDuration();
if (p_dsAction.m_loopCount != -1)
this->m_loopCount = p_dsAction.m_loopCount;
if (p_dsAction.m_location[0] != FLT_MAX)
this->m_location[0] = p_dsAction.m_location[0];
if (p_dsAction.m_location[1] != FLT_MAX)
this->m_location[1] = p_dsAction.m_location[1];
if (p_dsAction.m_location[2] != FLT_MAX)
this->m_location[2] = p_dsAction.m_location[2];
if (p_dsAction.m_direction[0] != FLT_MAX)
this->m_direction[0] = p_dsAction.m_direction[0];
if (p_dsAction.m_direction[1] != FLT_MAX)
this->m_direction[1] = p_dsAction.m_direction[1];
if (p_dsAction.m_direction[2] != FLT_MAX)
this->m_direction[2] = p_dsAction.m_up[2]; // This is correct
if (p_dsAction.m_up[0] != FLT_MAX)
this->m_up[0] = p_dsAction.m_up[0];
if (p_dsAction.m_up[1] != FLT_MAX)
this->m_up[1] = p_dsAction.m_up[1];
if (p_dsAction.m_up[2] != FLT_MAX)
this->m_up[2] = p_dsAction.m_up[2];
MxU16 extraLength = p_dsAction.m_extraLength;
char* extraData = p_dsAction.m_extraData;
// Taking those references forces the compiler to move the values onto the stack.
// The original code most likely looked different, but this yields a 100% match.
MxU16& extraLengthRef = extraLength;
char*& extraDataRef = extraData;
if (extraLength && extraData) {
if (!this->m_extraData || !strncmp("XXX", this->m_extraData, 3)) {
delete[] this->m_extraData;
this->m_extraLength = 0;
AppendData(extraLength, extraData);
}
}
}
// FUNCTION: LEGO1 0x100ade60
void MxDSAction::AppendData(MxU16 p_extraLength, const char* p_extraData)
{
if (this->m_extraData == p_extraData || !p_extraData)
return;
if (this->m_extraLength) {
char* concat = new char[p_extraLength + this->m_extraLength + sizeof(g_sep)];
memcpy(concat, this->m_extraData, this->m_extraLength);
*(MxU16*) &concat[this->m_extraLength] = g_sep;
memcpy(&concat[this->m_extraLength + sizeof(g_sep)], p_extraData, p_extraLength);
this->m_extraLength += p_extraLength + sizeof(g_sep);
delete[] this->m_extraData;
this->m_extraData = concat;
}
else {
char* copy = new char[p_extraLength];
this->m_extraData = copy;
if (copy) {
this->m_extraLength = p_extraLength;
memcpy(copy, p_extraData, p_extraLength);
}
}
}
// FUNCTION: LEGO1 0x100adf70
void MxDSAction::Deserialize(MxU8** p_source, MxS16 p_unk0x24)
{
MxDSObject::Deserialize(p_source, p_unk0x24);
GetScalar(p_source, this->m_flags);
GetScalar(p_source, this->m_startTime);
GetScalar(p_source, this->m_duration);
GetScalar(p_source, this->m_loopCount);
GetDouble(p_source, this->m_location[0]);
GetDouble(p_source, this->m_location[1]);
GetDouble(p_source, this->m_location[2]);
GetDouble(p_source, this->m_direction[0]);
GetDouble(p_source, this->m_direction[1]);
GetDouble(p_source, this->m_direction[2]);
GetDouble(p_source, this->m_up[0]);
GetDouble(p_source, this->m_up[1]);
GetDouble(p_source, this->m_up[2]);
MxU16 extraLength = GetScalar((MxU16**) p_source);
if (extraLength) {
AppendData(extraLength, (char*) *p_source);
*p_source += extraLength;
}
}

View File

@@ -0,0 +1,41 @@
#include "mxdsanim.h"
DECOMP_SIZE_ASSERT(MxDSAnim, 0xb8)
// FUNCTION: LEGO1 0x100c8ff0
MxDSAnim::MxDSAnim()
{
this->SetType(MxDSType_Anim);
}
// FUNCTION: LEGO1 0x100c91a0
MxDSAnim::~MxDSAnim()
{
}
// FUNCTION: LEGO1 0x100c91f0
void MxDSAnim::CopyFrom(MxDSAnim& p_dsAnim)
{
}
// FUNCTION: LEGO1 0x100c9200
MxDSAnim& MxDSAnim::operator=(MxDSAnim& p_dsAnim)
{
if (this == &p_dsAnim)
return *this;
MxDSMediaAction::operator=(p_dsAnim);
this->CopyFrom(p_dsAnim);
return *this;
}
// FUNCTION: LEGO1 0x100c9230
MxDSAction* MxDSAnim::Clone()
{
MxDSAnim* clone = new MxDSAnim();
if (clone)
*clone = *this;
return clone;
}

View File

@@ -0,0 +1,41 @@
#include "mxdsevent.h"
DECOMP_SIZE_ASSERT(MxDSEvent, 0xb8)
// FUNCTION: LEGO1 0x100c95f0
MxDSEvent::MxDSEvent()
{
this->SetType(MxDSType_Event);
}
// FUNCTION: LEGO1 0x100c97a0
MxDSEvent::~MxDSEvent()
{
}
// FUNCTION: LEGO1 0x100c97f0
void MxDSEvent::CopyFrom(MxDSEvent& p_dsEvent)
{
}
// FUNCTION: LEGO1 0x100c9800
MxDSEvent& MxDSEvent::operator=(MxDSEvent& p_dsEvent)
{
if (this == &p_dsEvent)
return *this;
MxDSMediaAction::operator=(p_dsEvent);
this->CopyFrom(p_dsEvent);
return *this;
}
// FUNCTION: LEGO1 0x100c9830
MxDSAction* MxDSEvent::Clone()
{
MxDSEvent* clone = new MxDSEvent();
if (clone)
*clone = *this;
return clone;
}

View File

@@ -0,0 +1,94 @@
#include "mxdsmediaaction.h"
#include "legoutil.h"
DECOMP_SIZE_ASSERT(MxDSMediaAction, 0xb8)
// FUNCTION: LEGO1 0x100c8b40
MxDSMediaAction::MxDSMediaAction()
{
this->m_mediaSrcPath = NULL;
this->m_unk0x9c.m_unk0x00 = 0;
this->m_unk0x9c.m_unk0x04 = 0;
this->m_framesPerSecond = 0;
this->m_mediaFormat = 0;
this->m_paletteManagement = 1;
this->m_unk0xb4 = -1;
this->m_sustainTime = 0;
this->SetType(MxDSType_MediaAction);
}
// FUNCTION: LEGO1 0x100c8cf0
MxDSMediaAction::~MxDSMediaAction()
{
delete[] this->m_mediaSrcPath;
}
// FUNCTION: LEGO1 0x100c8d60
void MxDSMediaAction::CopyFrom(MxDSMediaAction& p_dsMediaAction)
{
CopyMediaSrcPath(p_dsMediaAction.m_mediaSrcPath);
this->m_unk0x9c = p_dsMediaAction.m_unk0x9c;
this->m_framesPerSecond = p_dsMediaAction.m_framesPerSecond;
this->m_mediaFormat = p_dsMediaAction.m_mediaFormat;
this->m_paletteManagement = p_dsMediaAction.m_paletteManagement;
this->m_sustainTime = p_dsMediaAction.m_sustainTime;
}
// FUNCTION: LEGO1 0x100c8dc0
MxDSMediaAction& MxDSMediaAction::operator=(MxDSMediaAction& p_dsMediaAction)
{
if (this == &p_dsMediaAction)
return *this;
MxDSAction::operator=(p_dsMediaAction);
this->CopyFrom(p_dsMediaAction);
return *this;
}
// FUNCTION: LEGO1 0x100c8e80
void MxDSMediaAction::CopyMediaSrcPath(const char* p_mediaSrcPath)
{
if (this->m_mediaSrcPath == p_mediaSrcPath)
return;
delete[] this->m_mediaSrcPath;
if (p_mediaSrcPath) {
this->m_mediaSrcPath = new char[strlen(p_mediaSrcPath) + 1];
if (this->m_mediaSrcPath)
strcpy(this->m_mediaSrcPath, p_mediaSrcPath);
}
else
this->m_mediaSrcPath = NULL;
}
// FUNCTION: LEGO1 0x100c8f10
MxU32 MxDSMediaAction::GetSizeOnDisk()
{
MxU32 totalSizeOnDisk = MxDSAction::GetSizeOnDisk();
if (this->m_mediaSrcPath)
totalSizeOnDisk += strlen(this->m_mediaSrcPath) + 1;
else
totalSizeOnDisk++;
totalSizeOnDisk += 24;
this->m_sizeOnDisk = totalSizeOnDisk - MxDSAction::GetSizeOnDisk();
return totalSizeOnDisk;
}
// FUNCTION: LEGO1 0x100c8f60
void MxDSMediaAction::Deserialize(MxU8** p_source, MxS16 p_unk0x24)
{
MxDSAction::Deserialize(p_source, p_unk0x24);
GetString(p_source, &this->m_mediaSrcPath, this, &MxDSMediaAction::CopyMediaSrcPath);
GetScalar(p_source, this->m_unk0x9c.m_unk0x00);
GetScalar(p_source, this->m_unk0x9c.m_unk0x04);
GetScalar(p_source, this->m_framesPerSecond);
GetScalar(p_source, this->m_mediaFormat);
GetScalar(p_source, this->m_paletteManagement);
GetScalar(p_source, this->m_sustainTime);
}

View File

@@ -0,0 +1,156 @@
#include "mxdsmultiaction.h"
DECOMP_SIZE_ASSERT(MxDSMultiAction, 0x9c)
DECOMP_SIZE_ASSERT(MxDSActionList, 0x1c);
DECOMP_SIZE_ASSERT(MxDSActionListCursor, 0x10);
// FUNCTION: LEGO1 0x100c9b90
MxDSMultiAction::MxDSMultiAction()
{
this->SetType(MxDSType_MultiAction);
this->m_actions = new MxDSActionList;
this->m_actions->SetDestroy(MxDSActionList::Destroy);
}
// FUNCTION: LEGO1 0x100ca060
MxDSMultiAction::~MxDSMultiAction()
{
if (this->m_actions)
delete this->m_actions;
}
// FUNCTION: LEGO1 0x100ca0d0
void MxDSMultiAction::CopyFrom(MxDSMultiAction& p_dsMultiAction)
{
this->m_actions->DeleteAll();
MxDSActionListCursor cursor(p_dsMultiAction.m_actions);
MxDSAction* action;
while (cursor.Next(action))
this->m_actions->Append(action->Clone());
}
// FUNCTION: LEGO1 0x100ca260
MxDSMultiAction& MxDSMultiAction::operator=(MxDSMultiAction& p_dsMultiAction)
{
if (this == &p_dsMultiAction)
return *this;
MxDSAction::operator=(p_dsMultiAction);
this->CopyFrom(p_dsMultiAction);
return *this;
}
// FUNCTION: LEGO1 0x100ca290
void MxDSMultiAction::SetUnknown90(MxLong p_unk0x90)
{
this->m_unk0x90 = p_unk0x90;
MxDSActionListCursor cursor(this->m_actions);
MxDSAction* action;
while (cursor.Next(action))
action->SetUnknown90(p_unk0x90);
}
// FUNCTION: LEGO1 0x100ca370
void MxDSMultiAction::MergeFrom(MxDSAction& p_dsMultiAction)
{
MxDSAction::MergeFrom(p_dsMultiAction);
MxDSActionListCursor cursor(this->m_actions);
MxDSAction* action;
while (cursor.Next(action))
action->MergeFrom(p_dsMultiAction);
}
// FUNCTION: LEGO1 0x100ca450
MxBool MxDSMultiAction::HasId(MxU32 p_objectId)
{
if (this->GetObjectId() == p_objectId)
return TRUE;
MxDSActionListCursor cursor(this->m_actions);
MxDSAction* action;
while (cursor.Next(action)) {
if (action->HasId(p_objectId))
return TRUE;
}
return FALSE;
}
// FUNCTION: LEGO1 0x100ca550
MxDSAction* MxDSMultiAction::Clone()
{
MxDSMultiAction* clone = new MxDSMultiAction();
if (clone)
*clone = *this;
return clone;
}
// FUNCTION: LEGO1 0x100ca5e0
undefined4 MxDSMultiAction::VTable0x14()
{
undefined4 result = MxDSAction::VTable0x14();
MxDSActionListCursor cursor(this->m_actions);
MxDSAction* action;
while (cursor.Next(action))
result += action->VTable0x14();
return result;
}
// FUNCTION: 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;
}
// FUNCTION: LEGO1 0x100ca7b0
void MxDSMultiAction::Deserialize(MxU8** p_source, MxS16 p_unk0x24)
{
MxDSAction::Deserialize(p_source, p_unk0x24);
MxU32 extraFlag = *(MxU32*) (*p_source + 4) & 1;
*p_source += 12;
MxU32 count = *(MxU32*) *p_source;
*p_source += sizeof(count);
if (count) {
while (count--) {
MxU32 extraFlag = *(MxU32*) (*p_source + 4) & 1;
*p_source += 8;
MxDSAction* action = (MxDSAction*) DeserializeDSObjectDispatch(p_source, p_unk0x24);
*p_source += extraFlag;
this->m_actions->Append(action);
}
}
*p_source += extraFlag;
}
// FUNCTION: LEGO1 0x100ca8c0
void MxDSMultiAction::SetAtomId(MxAtomId p_atomId)
{
MxDSAction::SetAtomId(p_atomId);
MxDSActionListCursor cursor(this->m_actions);
MxDSAction* action;
while (cursor.Next(action))
action->SetAtomId(p_atomId);
}

View File

@@ -0,0 +1,194 @@
#include "mxdsobject.h"
#include "legoutil.h"
#include "mxdsaction.h"
#include "mxdsanim.h"
#include "mxdsevent.h"
#include "mxdsmediaaction.h"
#include "mxdsmultiaction.h"
#include "mxdsobjectaction.h"
#include "mxdsparallelaction.h"
#include "mxdsselectaction.h"
#include "mxdsserialaction.h"
#include "mxdssound.h"
#include "mxdsstill.h"
#include "mxdstypes.h"
#include <stdlib.h>
#include <string.h>
DECOMP_SIZE_ASSERT(MxDSObject, 0x2c);
// FUNCTION: LEGO1 0x100bf6a0
MxDSObject::MxDSObject()
{
this->SetType(MxDSType_Object);
this->m_sourceName = NULL;
this->m_unk0x14 = 0;
this->m_objectName = NULL;
this->m_unk0x24 = -1;
this->m_objectId = -1;
this->m_unk0x28 = 0;
}
// FUNCTION: LEGO1 0x100bf7e0
MxDSObject::~MxDSObject()
{
delete[] m_objectName;
delete[] m_sourceName;
}
// FUNCTION: LEGO1 0x100bf870
void MxDSObject::CopyFrom(MxDSObject& p_dsObject)
{
this->SetSourceName(p_dsObject.m_sourceName);
this->m_unk0x14 = p_dsObject.m_unk0x14;
this->SetObjectName(p_dsObject.m_objectName);
this->m_objectId = p_dsObject.m_objectId;
this->m_unk0x24 = p_dsObject.m_unk0x24;
this->m_atomId = p_dsObject.m_atomId;
this->m_unk0x28 = p_dsObject.m_unk0x28;
}
// FUNCTION: LEGO1 0x100bf8c0
MxDSObject& MxDSObject::operator=(MxDSObject& p_dsObject)
{
if (this == &p_dsObject)
return *this;
this->CopyFrom(p_dsObject);
return *this;
}
// FUNCTION: LEGO1 0x100bf8e0
void MxDSObject::SetObjectName(const char* p_objectName)
{
if (p_objectName != this->m_objectName) {
delete[] this->m_objectName;
if (p_objectName) {
this->m_objectName = new char[strlen(p_objectName) + 1];
if (this->m_objectName) {
strcpy(this->m_objectName, p_objectName);
}
}
else {
this->m_objectName = NULL;
}
}
}
// FUNCTION: LEGO1 0x100bf950
void MxDSObject::SetSourceName(const char* p_sourceName)
{
if (p_sourceName != this->m_sourceName) {
delete[] this->m_sourceName;
if (p_sourceName) {
this->m_sourceName = new char[strlen(p_sourceName) + 1];
if (this->m_sourceName) {
strcpy(this->m_sourceName, p_sourceName);
}
}
else {
this->m_sourceName = NULL;
}
}
}
// FUNCTION: LEGO1 0x100bf9c0
undefined4 MxDSObject::VTable0x14()
{
return 10;
}
// FUNCTION: LEGO1 0x100bf9d0
MxU32 MxDSObject::GetSizeOnDisk()
{
MxU32 sizeOnDisk;
if (this->m_sourceName)
sizeOnDisk = strlen(this->m_sourceName) + 3;
else
sizeOnDisk = 3;
sizeOnDisk += 4;
if (this->m_objectName)
sizeOnDisk += strlen(this->m_objectName) + 1;
else
sizeOnDisk++;
sizeOnDisk += 4;
this->m_sizeOnDisk = sizeOnDisk;
return sizeOnDisk;
}
// FUNCTION: LEGO1 0x100bfa20
void MxDSObject::Deserialize(MxU8** p_source, MxS16 p_unk0x24)
{
GetString(p_source, &this->m_sourceName, this, &MxDSObject::SetSourceName);
GetScalar(p_source, this->m_unk0x14);
GetString(p_source, &this->m_objectName, this, &MxDSObject::SetObjectName);
GetScalar(p_source, this->m_objectId);
this->m_unk0x24 = p_unk0x24;
}
// FUNCTION: LEGO1 0x100bfb30
MxDSObject* DeserializeDSObjectDispatch(MxU8** p_source, MxS16 p_flags)
{
MxU16 type = *(MxU16*) *p_source;
*p_source += 2;
MxDSObject* obj = NULL;
switch (type) {
default:
return NULL;
case MxDSType_Object:
obj = new MxDSObject();
break;
case MxDSType_Action:
obj = new MxDSAction();
break;
case MxDSType_MediaAction:
obj = new MxDSMediaAction();
break;
case MxDSType_Anim:
obj = new MxDSAnim();
break;
case MxDSType_Sound:
obj = new MxDSSound();
break;
case MxDSType_MultiAction:
obj = new MxDSMultiAction();
break;
case MxDSType_SerialAction:
obj = new MxDSSerialAction();
break;
case MxDSType_ParallelAction:
obj = new MxDSParallelAction();
break;
case MxDSType_Event:
obj = new MxDSEvent();
break;
case MxDSType_SelectAction:
obj = new MxDSSelectAction();
break;
case MxDSType_Still:
obj = new MxDSStill();
break;
case MxDSType_ObjectAction:
obj = new MxDSObjectAction();
break;
}
if (obj) {
obj->Deserialize(p_source, p_flags);
}
return obj;
}

View File

@@ -0,0 +1,41 @@
#include "mxdsobjectaction.h"
DECOMP_SIZE_ASSERT(MxDSObjectAction, 0xb8)
// FUNCTION: LEGO1 0x100c8870
MxDSObjectAction::MxDSObjectAction()
{
this->SetType(MxDSType_ObjectAction);
}
// FUNCTION: LEGO1 0x100c8a20
MxDSObjectAction::~MxDSObjectAction()
{
}
// FUNCTION: LEGO1 0x100c8a70
void MxDSObjectAction::CopyFrom(MxDSObjectAction& p_dsObjectAction)
{
}
// FUNCTION: LEGO1 0x100c8a80
MxDSObjectAction& MxDSObjectAction::operator=(MxDSObjectAction& p_dsObjectAction)
{
if (this == &p_dsObjectAction)
return *this;
MxDSMediaAction::operator=(p_dsObjectAction);
this->CopyFrom(p_dsObjectAction);
return *this;
}
// FUNCTION: LEGO1 0x100c8ab0
MxDSAction* MxDSObjectAction::Clone()
{
MxDSObjectAction* clone = new MxDSObjectAction();
if (clone)
*clone = *this;
return clone;
}

View File

@@ -0,0 +1,87 @@
#include "mxdsparallelaction.h"
#include "mxdsmediaaction.h"
DECOMP_SIZE_ASSERT(MxDSParallelAction, 0x9c)
// FUNCTION: LEGO1 0x100cae80
MxDSParallelAction::MxDSParallelAction()
{
this->SetType(MxDSType_ParallelAction);
}
// FUNCTION: LEGO1 0x100cb040
MxDSParallelAction::~MxDSParallelAction()
{
}
// FUNCTION: LEGO1 0x100cb090
void MxDSParallelAction::CopyFrom(MxDSParallelAction& p_dsParallelAction)
{
}
// FUNCTION: LEGO1 0x100cb0a0
MxDSParallelAction& MxDSParallelAction::operator=(MxDSParallelAction& p_dsParallelAction)
{
if (this == &p_dsParallelAction)
return *this;
MxDSMultiAction::operator=(p_dsParallelAction);
this->CopyFrom(p_dsParallelAction);
return *this;
}
// FUNCTION: LEGO1 0x100cb0d0
MxDSAction* MxDSParallelAction::Clone()
{
MxDSParallelAction* clone = new MxDSParallelAction();
if (clone)
*clone = *this;
return clone;
}
// FUNCTION: LEGO1 0x100cb160
MxLong MxDSParallelAction::GetDuration()
{
if (this->m_duration)
return this->m_duration;
MxDSActionListCursor cursor(this->m_actions);
MxDSAction* action;
while (cursor.Next(action)) {
if (!action)
continue;
MxLong duration = action->GetDuration();
if (duration == -1) {
this->m_duration = -1;
break;
}
duration += action->GetStartTime();
if (action->IsA("MxDSMediaAction")) {
MxLong sustainTime = ((MxDSMediaAction*) action)->GetSustainTime();
if (sustainTime == -1)
duration = -1;
else if (sustainTime)
duration += sustainTime;
}
if (duration == -1) {
this->m_duration = -1;
break;
}
if (this->m_duration < duration)
this->m_duration = duration;
}
if (this->IsBit3())
this->m_duration *= this->m_loopCount;
return this->m_duration;
}

View File

@@ -0,0 +1,133 @@
#include "mxdsselectaction.h"
#include "mxomni.h"
#include "mxtimer.h"
#include "mxvariabletable.h"
DECOMP_SIZE_ASSERT(MxDSSelectAction, 0xb0)
DECOMP_SIZE_ASSERT(MxListEntry<MxString>, 0x18)
// FUNCTION: LEGO1 0x100cb2b0
MxDSSelectAction::MxDSSelectAction()
{
this->SetType(MxDSType_SelectAction);
this->m_unk0xac = new MxStringList;
}
// FUNCTION: LEGO1 0x100cb8d0
MxDSSelectAction::~MxDSSelectAction()
{
if (this->m_unk0xac)
delete this->m_unk0xac;
}
// FUNCTION: 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->Append(string);
}
// FUNCTION: LEGO1 0x100cbd50
MxDSSelectAction& MxDSSelectAction::operator=(MxDSSelectAction& p_dsSelectAction)
{
if (this != &p_dsSelectAction) {
MxDSParallelAction::operator=(p_dsSelectAction);
this->CopyFrom(p_dsSelectAction);
}
return *this;
}
// FUNCTION: LEGO1 0x100cbd80
MxDSAction* MxDSSelectAction::Clone()
{
MxDSSelectAction* clone = new MxDSSelectAction();
if (clone)
*clone = *this;
return clone;
}
// FUNCTION: LEGO1 0x100cbe10
MxU32 MxDSSelectAction::GetSizeOnDisk()
{
MxU32 totalSizeOnDisk = MxDSParallelAction::GetSizeOnDisk();
totalSizeOnDisk += strlen(this->m_unk0x9c.GetData()) + 1;
MxStringListCursor cursor(this->m_unk0xac);
MxString string;
while (cursor.Next(string))
totalSizeOnDisk += strlen(string.GetData()) + 1;
// Note: unlike the other classes, MxDSSelectAction does not have its own
// sizeOnDisk member. Instead, it overrides the one from MxDSMultiAction.
this->m_sizeOnDisk = totalSizeOnDisk;
return totalSizeOnDisk;
}
// FUNCTION: LEGO1 0x100cbf60
void MxDSSelectAction::Deserialize(MxU8** p_source, MxS16 p_unk0x24)
{
MxString string;
MxDSAction::Deserialize(p_source, p_unk0x24);
MxU32 extraFlag = *(MxU32*) (*p_source + 4) & 1;
*p_source += 12;
this->m_unk0x9c = (char*) *p_source;
if (!strnicmp(this->m_unk0x9c.GetData(), "RANDOM_", strlen("RANDOM_"))) {
char buffer[10];
MxS16 value = atoi(&this->m_unk0x9c.GetData()[strlen("RANDOM_")]);
srand(Timer()->GetTime());
MxS32 random = rand() % value;
string = itoa((MxS16) random, buffer, 10);
}
else
string = VariableTable()->GetVariable((char*) *p_source);
*p_source += strlen((char*) *p_source) + 1;
MxU32 count = *(MxU32*) *p_source;
*p_source += sizeof(MxU32);
if (count) {
MxS32 index = -1;
this->m_unk0xac->DeleteAll();
MxU32 i;
for (i = 0; i < count; i++) {
if (!strcmp(string.GetData(), (char*) *p_source))
index = i;
this->m_unk0xac->Append((char*) *p_source);
*p_source += strlen((char*) *p_source) + 1;
}
for (i = 0; i < count; i++) {
MxU32 extraFlag = *(MxU32*) (*p_source + 4) & 1;
*p_source += 8;
MxDSAction* action = (MxDSAction*) DeserializeDSObjectDispatch(p_source, p_unk0x24);
if (index == i)
this->m_actions->Append(action);
else
delete action;
*p_source += extraFlag;
}
}
*p_source += extraFlag;
}

View File

@@ -0,0 +1,81 @@
#include "mxdsserialaction.h"
#include "mxdsmediaaction.h"
DECOMP_SIZE_ASSERT(MxDSSerialAction, 0xa8)
// FUNCTION: LEGO1 0x100ca9d0
MxDSSerialAction::MxDSSerialAction()
{
this->SetType(MxDSType_SerialAction);
this->m_cursor = new MxDSActionListCursor(this->m_actions);
this->m_unk0xa0 = 0;
}
// FUNCTION: LEGO1 0x100caac0
void MxDSSerialAction::SetDuration(MxLong p_duration)
{
this->m_duration = p_duration;
}
// FUNCTION: LEGO1 0x100cac10
MxDSSerialAction::~MxDSSerialAction()
{
if (this->m_cursor)
delete this->m_cursor;
this->m_cursor = NULL;
}
// FUNCTION: LEGO1 0x100cac90
void MxDSSerialAction::CopyFrom(MxDSSerialAction& p_dsSerialAction)
{
}
// FUNCTION: LEGO1 0x100caca0
MxDSSerialAction& MxDSSerialAction::operator=(MxDSSerialAction& p_dsSerialAction)
{
if (this == &p_dsSerialAction)
return *this;
MxDSMultiAction::operator=(p_dsSerialAction);
this->CopyFrom(p_dsSerialAction);
return *this;
}
// FUNCTION: LEGO1 0x100cacd0
MxDSAction* MxDSSerialAction::Clone()
{
MxDSSerialAction* clone = new MxDSSerialAction();
if (clone)
*clone = *this;
return clone;
}
// FUNCTION: LEGO1 0x100cad60
MxLong MxDSSerialAction::GetDuration()
{
if (this->m_duration)
return this->m_duration;
MxDSActionListCursor cursor(this->m_actions);
MxDSAction* action;
while (cursor.Next(action)) {
if (!action)
continue;
this->m_duration += action->GetDuration() + action->GetStartTime();
if (action->IsA("MxDSMediaAction")) {
MxLong sustainTime = ((MxDSMediaAction*) action)->GetSustainTime();
if (sustainTime && sustainTime != -1)
this->m_duration += sustainTime;
}
}
return this->m_duration;
}

View File

@@ -0,0 +1,63 @@
#include "mxdssound.h"
#include "legoutil.h"
DECOMP_SIZE_ASSERT(MxDSSound, 0xc0)
// FUNCTION: LEGO1 0x100c92c0
MxDSSound::MxDSSound()
{
this->m_volume = 0x4f;
this->SetType(MxDSType_Sound);
}
// FUNCTION: LEGO1 0x100c9470
MxDSSound::~MxDSSound()
{
}
// FUNCTION: LEGO1 0x100c94c0
void MxDSSound::CopyFrom(MxDSSound& p_dsSound)
{
this->SetType(p_dsSound.GetType());
this->m_volume = p_dsSound.m_volume;
}
// FUNCTION: LEGO1 0x100c94e0
MxDSSound& MxDSSound::operator=(MxDSSound& p_dsSound)
{
if (this == &p_dsSound)
return *this;
MxDSMediaAction::operator=(p_dsSound);
this->CopyFrom(p_dsSound);
return *this;
}
// FUNCTION: LEGO1 0x100c9510
MxDSAction* MxDSSound::Clone()
{
MxDSSound* clone = new MxDSSound();
if (clone)
*clone = *this;
return clone;
}
// FUNCTION: LEGO1 0x100c95a0
void MxDSSound::Deserialize(MxU8** p_source, MxS16 p_unk0x24)
{
MxDSMediaAction::Deserialize(p_source, p_unk0x24);
GetScalar(p_source, this->m_volume);
}
// FUNCTION: LEGO1 0x100c95d0
MxU32 MxDSSound::GetSizeOnDisk()
{
MxU32 totalSizeOnDisk = MxDSMediaAction::GetSizeOnDisk();
this->m_sizeOnDisk = sizeof(this->m_volume);
return totalSizeOnDisk + 4;
}

View File

@@ -0,0 +1,41 @@
#include "mxdsstill.h"
DECOMP_SIZE_ASSERT(MxDSStill, 0xb8)
// FUNCTION: LEGO1 0x100c98c0
MxDSStill::MxDSStill()
{
this->SetType(MxDSType_Still);
}
// FUNCTION: LEGO1 0x100c9a70
MxDSStill::~MxDSStill()
{
}
// FUNCTION: LEGO1 0x100c9ac0
void MxDSStill::CopyFrom(MxDSStill& p_dsStill)
{
}
// FUNCTION: LEGO1 0x100c9ad0
MxDSStill& MxDSStill::operator=(MxDSStill& p_dsStill)
{
if (this == &p_dsStill)
return *this;
MxDSMediaAction::operator=(p_dsStill);
this->CopyFrom(p_dsStill);
return *this;
}
// FUNCTION: LEGO1 0x100c9b00
MxDSAction* MxDSStill::Clone()
{
MxDSStill* clone = new MxDSStill();
if (clone)
*clone = *this;
return clone;
}

View File

@@ -0,0 +1,92 @@
#include "mxdsstreamingaction.h"
#include "mxdsbuffer.h"
DECOMP_SIZE_ASSERT(MxDSStreamingAction, 0xb4)
// FUNCTION: LEGO1 0x100cd010
MxDSStreamingAction::MxDSStreamingAction(MxDSAction& p_dsAction, MxU32 p_offset)
{
Init();
*this = p_dsAction;
this->m_unk0x94 = p_offset;
this->m_bufferOffset = p_offset;
}
// FUNCTION: LEGO1 0x100cd090
MxBool MxDSStreamingAction::HasId(MxU32 p_objectId)
{
if (this->m_internalAction)
return this->m_internalAction->HasId(p_objectId);
return FALSE;
}
// FUNCTION: LEGO1 0x100cd0d0
MxDSStreamingAction::MxDSStreamingAction(MxDSStreamingAction& p_dsStreamingAction)
{
Init();
CopyFrom(p_dsStreamingAction);
}
// FUNCTION: LEGO1 0x100cd150
MxDSStreamingAction::~MxDSStreamingAction()
{
if (this->m_unk0xa0)
delete this->m_unk0xa0;
if (this->m_unk0xa4)
delete this->m_unk0xa4;
if (this->m_internalAction)
delete this->m_internalAction;
}
// FUNCTION: LEGO1 0x100cd1e0
MxResult MxDSStreamingAction::Init()
{
this->m_unk0x94 = 0;
this->m_bufferOffset = 0;
this->m_unk0x9c = 0;
this->m_unk0xa0 = NULL;
this->m_unk0xa4 = NULL;
this->m_unk0xa8 = 0;
this->m_unk0xac = 2;
this->m_internalAction = NULL;
return SUCCESS;
}
// FUNCTION: LEGO1 0x100cd220
MxDSStreamingAction* MxDSStreamingAction::CopyFrom(MxDSStreamingAction& p_dsStreamingAction)
{
*this = p_dsStreamingAction;
this->m_unk0x94 = p_dsStreamingAction.m_unk0x94;
this->m_bufferOffset = p_dsStreamingAction.m_bufferOffset;
this->m_unk0x9c = p_dsStreamingAction.m_unk0x9c;
this->m_unk0xa0 = NULL;
this->m_unk0xa4 = NULL;
this->m_unk0xac = p_dsStreamingAction.m_unk0xac;
this->m_unk0xa8 = p_dsStreamingAction.m_unk0xa8;
SetInternalAction(p_dsStreamingAction.m_internalAction ? p_dsStreamingAction.m_internalAction->Clone() : NULL);
return this;
}
// FUNCTION: LEGO1 0x100cd2a0
void MxDSStreamingAction::SetInternalAction(MxDSAction* p_dsAction)
{
if (this->m_internalAction)
delete this->m_internalAction;
this->m_internalAction = p_dsAction;
}
// FUNCTION: LEGO1 0x100cd2d0
void MxDSStreamingAction::FUN_100cd2d0()
{
if (this->m_duration == -1)
return;
MxLong duration = this->m_duration / this->m_loopCount;
this->m_loopCount--;
this->m_duration -= duration;
this->m_unk0xa8 += duration;
}