diff --git a/ISLE/isleapp.cpp b/ISLE/isleapp.cpp index 93500783..198389a3 100644 --- a/ISLE/isleapp.cpp +++ b/ISLE/isleapp.cpp @@ -90,7 +90,7 @@ void IsleApp::Close() VideoManager()->Get3DManager()->GetLego3DView()->GetViewManager()->RemoveAll(NULL); - Lego()->RemoveWorld(ds.GetAtomId(), ds.GetUnknown1c()); + Lego()->RemoveWorld(ds.GetAtomId(), ds.GetObjectId()); Lego()->vtable24(ds); TransitionManager()->SetWaitIndicator(NULL); Lego()->vtable3c(); @@ -729,7 +729,7 @@ inline void IsleApp::Tick(BOOL sleepIfNotNextFrame) ds.SetAtomId(stream->atom); ds.SetUnknown24(-1); - ds.SetUnknown1c(0); + ds.SetObjectId(0); VideoManager()->EnableFullScreenMovie(TRUE, TRUE); if (Start(&ds) != SUCCESS) { @@ -738,7 +738,7 @@ inline void IsleApp::Tick(BOOL sleepIfNotNextFrame) } else { ds.SetAtomId(stream->atom); ds.SetUnknown24(-1); - ds.SetUnknown1c(0); + ds.SetObjectId(0); if (Start(&ds) != SUCCESS) { return; } diff --git a/LEGO1/mxdsaction.cpp b/LEGO1/mxdsaction.cpp index d6e1fdb5..7b977d1f 100644 --- a/LEGO1/mxdsaction.cpp +++ b/LEGO1/mxdsaction.cpp @@ -41,3 +41,184 @@ MxDSAction::~MxDSAction() { delete this->m_unk7c; } + +// OFFSET: 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; + + // TODO + // this->m_location.SetVector(p_dsAction.m_location.GetData()); + // this->m_direction.SetVector(p_dsAction.m_direction.GetData()); + // this->m_up.SetVector(p_dsAction.m_up.GetData()); + + FUN_100ADE60(p_dsAction.m_unk80, p_dsAction.m_unk7c); + this->m_unk84 = p_dsAction.m_unk84; + this->m_unk88 = p_dsAction.m_unk88; + this->m_omni = p_dsAction.m_omni; + this->m_someTimingField = p_dsAction.m_someTimingField; +} + +// OFFSET: LEGO1 0x100adc10 +MxDSAction &MxDSAction::operator=(MxDSAction &p_dsAction) +{ + if (this == &p_dsAction) + return *this; + + MxDSObject::operator=(p_dsAction); + this->CopyFrom(p_dsAction); + return *this; +} + +// OFFSET: LEGO1 0x100adbe0 +MxU32 MxDSAction::GetSizeOnDisk() +{ + MxU32 totalSizeOnDisk; + + totalSizeOnDisk = MxDSObject::GetSizeOnDisk() + 90 + this->m_unk80; + this->m_sizeOnDisk = totalSizeOnDisk - MxDSObject::GetSizeOnDisk(); + + return totalSizeOnDisk; +} + +// OFFSET: LEGO1 0x100adf70 +void MxDSAction::Deserialize(char **p_source, MxS16 p_unk24) +{ + MxDSObject::Deserialize(p_source, p_unk24); + + this->m_flags = *(DWORD*) *p_source; + *p_source += sizeof(DWORD); + this->m_startTime = *(DWORD*) *p_source; + *p_source += sizeof(DWORD); + this->m_duration = *(MxLong*) *p_source; + *p_source += sizeof(MxLong); + this->m_loopCount = *(MxS32*) *p_source; + *p_source += sizeof(MxS32); + this->m_location[0] = *(double*) *p_source; + *p_source += sizeof(double); + this->m_location[1] = *(double*) *p_source; + *p_source += sizeof(double); + this->m_location[2] = *(double*) *p_source; + *p_source += sizeof(double); + this->m_direction[0] = *(double*) *p_source; + *p_source += sizeof(double); + this->m_direction[1] = *(double*) *p_source; + *p_source += sizeof(double); + this->m_direction[2] = *(double*) *p_source; + *p_source += sizeof(double); + this->m_up[0] = *(double*) *p_source; + *p_source += sizeof(double); + this->m_up[1] = *(double*) *p_source; + *p_source += sizeof(double); + this->m_up[2] = *(double*) *p_source; + *p_source += sizeof(double); + + MxU16 extralen = *(MxU16*) *p_source; + *p_source += sizeof(MxU16); + if (extralen) { + FUN_100ADE60(extralen, *p_source); + *p_source += extralen; + } +} + +// OFFSET: LEGO1 0x100ad940 +MxLong MxDSAction::GetDuration() +{ + return this->m_duration; +} + +// OFFSET: LEGO1 0x100ad950 +void MxDSAction::SetDuration(MxLong p_duration) +{ + this->m_duration = p_duration; +} + +// OFFSET: LEGO1 0x100adc40 +MxDSAction *MxDSAction::Clone() +{ + MxDSAction *clone = new MxDSAction(); + + if (clone) + *clone = *this; + + return clone; +} + +// OFFSET: 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_direction[2]; + + 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]; + + // TODO + if (p_dsAction.m_unk80 && + p_dsAction.m_unk7c && + *p_dsAction.m_unk7c && + !strncmp("XXX", (const char*) p_dsAction.m_unk7c, 3)) + { + delete this->m_unk7c; + this->m_unk80 = 0; + FUN_100ADE60(p_dsAction.m_unk80, p_dsAction.m_unk7c); + } +} + +// OFFSET: LEGO1 0x100ad960 +MxBool MxDSAction::HasId(MxU32 p_objectId) +{ + return this->GetObjectId() == p_objectId; +} + +// OFFSET: LEGO1 0x100ada40 +void MxDSAction::SetSomeTimingField(MxLong p_someTimingField) +{ + this->m_someTimingField = p_someTimingField; +} + +// OFFSET: LEGO1 0x100ada50 +MxLong MxDSAction::GetSomeTimingField() +{ + return this->m_someTimingField; +} + +// OFFSET: LEGO1 0x100adcd0 +MxLong MxDSAction::GetCurrentTime() +{ + return Timer()->GetTime() - this->m_someTimingField; +} + +// OFFSET: LEGO1 0x100ade60 STUB +void MxDSAction::FUN_100ADE60(MxU16 p_length, void *p_data) +{ + // TOOD +} \ No newline at end of file diff --git a/LEGO1/mxdsaction.h b/LEGO1/mxdsaction.h index 10a14365..069986bf 100644 --- a/LEGO1/mxdsaction.h +++ b/LEGO1/mxdsaction.h @@ -13,6 +13,9 @@ class MxDSAction : public MxDSObject __declspec(dllexport) MxDSAction(); __declspec(dllexport) virtual ~MxDSAction(); + void CopyFrom(MxDSAction &p_dsAction); + MxDSAction &operator=(MxDSAction &p_dsAction); + // OFFSET: LEGO1 0x100ad980 inline virtual const char *ClassName() const override // vtable+0x0c { @@ -25,21 +28,35 @@ 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 MxLong GetDuration(); // vtable+24; + virtual void SetDuration(LONG p_duration); // vtable+28; + 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 MxLong GetSomeTimingField(); // vtable+3c; + virtual MxLong GetCurrentTime(); // vtable+40; + + void FUN_100ADE60(MxU16 p_length, void *p_data); + private: - undefined4 m_unk2c; + MxU32 m_sizeOnDisk; DWORD m_flags; DWORD m_startTime; - LONG m_duration; + MxLong m_duration; MxS32 m_loopCount; MxVector3Data m_location; MxVector3Data m_direction; MxVector3Data m_up; undefined4 *m_unk7c; - undefined2 m_unk80; + MxU16 m_unk80; undefined4 m_unk84; undefined4 m_unk88; MxOmni* m_omni; // 0x8c - MxS32 m_someTimingField; // 0x90 + MxLong m_someTimingField; // 0x90 }; #endif // MXDSACTION_H diff --git a/LEGO1/mxdsobject.cpp b/LEGO1/mxdsobject.cpp index 2b478b88..57663cee 100644 --- a/LEGO1/mxdsobject.cpp +++ b/LEGO1/mxdsobject.cpp @@ -13,7 +13,7 @@ MxDSObject::MxDSObject() this->m_unk14 = 0; this->m_objectName = NULL; this->m_unk24 = -1; - this->m_unk1c = -1; + this->m_objectId = -1; this->m_unk28 = 0; } @@ -30,7 +30,7 @@ void MxDSObject::CopyFrom(MxDSObject &p_dsObject) this->SetSourceName(p_dsObject.m_sourceName); this->m_unk14 = p_dsObject.m_unk14; this->SetObjectName(p_dsObject.m_objectName); - this->m_unk1c = p_dsObject.m_unk1c; + this->m_objectId = p_dsObject.m_objectId; this->m_unk24 = p_dsObject.m_unk24; this->m_atomId = p_dsObject.m_atomId; this->m_unk28 = p_dsObject.m_unk28; @@ -91,39 +91,39 @@ undefined4 MxDSObject::unk14() } // OFFSET: LEGO1 0x100bf9d0 -MxU32 MxDSObject::CalculateUnk08() +MxU32 MxDSObject::GetSizeOnDisk() { - MxU32 unk08; + MxU32 sizeOnDisk; if (this->m_sourceName) - unk08 = strlen(this->m_sourceName) + 3; + sizeOnDisk = strlen(this->m_sourceName) + 3; else - unk08 = 3; + sizeOnDisk = 3; - unk08 += 4; + sizeOnDisk += 4; if (this->m_objectName) - unk08 += strlen(this->m_objectName) + 1; + sizeOnDisk += strlen(this->m_objectName) + 1; else - unk08++; + sizeOnDisk++; - unk08 += 4; - this->m_unk08 = unk08; - return unk08; + sizeOnDisk += 4; + this->m_sizeOnDisk = sizeOnDisk; + return sizeOnDisk; } // OFFSET: LEGO1 0x100bfa20 -void MxDSObject::Parse(char **p_source, MxS16 p_unk24) +void MxDSObject::Deserialize(char **p_source, MxS16 p_unk24) { this->SetSourceName(*p_source); *p_source += strlen(this->m_sourceName) + 1; this->m_unk14 = *(undefined4*) *p_source; - *p_source += 4; + *p_source += sizeof(undefined4); this->SetObjectName(*p_source); *p_source += strlen(this->m_objectName) + 1; - this->m_unk1c = *(undefined4*) *p_source; - *p_source += 4; + this->m_objectId = *(MxU32*) *p_source; + *p_source += sizeof(MxU32); this->m_unk24 = p_unk24; } diff --git a/LEGO1/mxdsobject.h b/LEGO1/mxdsobject.h index a13f382f..5dfc894c 100644 --- a/LEGO1/mxdsobject.h +++ b/LEGO1/mxdsobject.h @@ -28,29 +28,28 @@ class MxDSObject : public MxCore inline virtual MxBool IsA(const char *name) const override { return !strcmp(name, MxDSObject::ClassName()) || MxCore::IsA(name); }; // vtable+10; virtual undefined4 unk14(); // vtable+14; - virtual MxU32 CalculateUnk08(); // vtable+18; - virtual void Parse(char **p_source, MxS16 p_unk24); // vtable+1c; - - inline const MxAtomId& GetAtomId() { return this->m_atomId; } - inline undefined4 GetUnknown1c() { return this->m_unk1c; } - - inline void SetUnknown1c(undefined4 p_unk1c) { this->m_unk1c = p_unk1c; } - inline void SetUnknown24(MxS16 p_unk24) { this->m_unk24 = p_unk24; } - + virtual MxU32 GetSizeOnDisk(); // vtable+18; + virtual void Deserialize(char **p_source, MxS16 p_unk24); // vtable+1c; // OFFSET: ISLE 0x401c40 // OFFSET: LEGO1 0x10005530 - inline void SetAtomId(MxAtomId p_atomId) { this->m_atomId = p_atomId; } + inline virtual void SetAtomId(MxAtomId p_atomId) { this->m_atomId = p_atomId; } // vtable+20; + + inline const MxAtomId& GetAtomId() { return this->m_atomId; } + inline MxU32 GetObjectId() { return this->m_objectId; } + + inline void SetObjectId(MxU32 p_objectId) { this->m_objectId = p_objectId; } + inline void SetUnknown24(MxS16 p_unk24) { this->m_unk24 = p_unk24; } protected: inline void SetType(MxDSType p_type) { this->m_type = p_type; } private: - MxU32 m_unk08; + MxU32 m_sizeOnDisk; MxU16 m_type; char* m_sourceName; undefined4 m_unk14; char *m_objectName; - undefined4 m_unk1c; + MxU32 m_objectId; MxAtomId m_atomId; MxS16 m_unk24; undefined4 m_unk28; diff --git a/LEGO1/mxvector.h b/LEGO1/mxvector.h index f5b8e686..e55e8d56 100644 --- a/LEGO1/mxvector.h +++ b/LEGO1/mxvector.h @@ -60,6 +60,8 @@ class MxVector2 virtual void SetVector(MxVector2 *other); virtual void SetVector(float *other); + inline float& operator[](size_t idx) { return m_data[idx]; } + inline const float operator[](size_t idx) const { return m_data[idx]; } protected: float *m_data; };