mirror of
https://github.com/isledecomp/isle-portable.git
synced 2024-11-22 15:37:55 -05:00
Implement MxDSAction::AppendData (#105)
* Implement MxDSAction::ConcatData * use GLOBAL * Update mxdsaction.cpp * Update mxdsaction.h * Move TWOCC/FOURCC to common header file * Fix * Fix deletes
This commit is contained in:
parent
88bfb3c419
commit
a02e07c4d7
4 changed files with 53 additions and 25 deletions
|
@ -3,13 +3,18 @@
|
|||
#include <float.h>
|
||||
#include <limits.h>
|
||||
|
||||
DECOMP_SIZE_ASSERT(MxDSAction, 0x94)
|
||||
|
||||
// GLOBAL OFFSET: LEGO1 0x10101410
|
||||
MxU16 g_unkSep = TWOCC(',', ' ');
|
||||
|
||||
// OFFSET: LEGO1 0x100ad810
|
||||
MxDSAction::MxDSAction()
|
||||
{
|
||||
this->m_flags = 32;
|
||||
this->m_startTime = INT_MIN;
|
||||
this->m_unk7c = NULL;
|
||||
this->m_unk80 = 0;
|
||||
this->m_unkData = NULL;
|
||||
this->m_unkLength = 0;
|
||||
this->m_duration = INT_MIN;
|
||||
this->m_loopCount = -1;
|
||||
|
||||
|
@ -39,7 +44,7 @@ MxDSAction::MxDSAction()
|
|||
// OFFSET: LEGO1 0x100ada80
|
||||
MxDSAction::~MxDSAction()
|
||||
{
|
||||
delete this->m_unk7c;
|
||||
delete[] this->m_unkData;
|
||||
}
|
||||
|
||||
// OFFSET: LEGO1 0x100adaf0
|
||||
|
@ -55,7 +60,7 @@ void MxDSAction::CopyFrom(MxDSAction &p_dsAction)
|
|||
this->m_direction.CopyFrom(p_dsAction.m_direction);
|
||||
this->m_up.CopyFrom(p_dsAction.m_up);
|
||||
|
||||
FUN_100ADE60(p_dsAction.m_unk80, p_dsAction.m_unk7c);
|
||||
AppendData(p_dsAction.m_unkLength, p_dsAction.m_unkData);
|
||||
this->m_unk84 = p_dsAction.m_unk84;
|
||||
this->m_unk88 = p_dsAction.m_unk88;
|
||||
this->m_omni = p_dsAction.m_omni;
|
||||
|
@ -78,7 +83,7 @@ MxU32 MxDSAction::GetSizeOnDisk()
|
|||
{
|
||||
MxU32 totalSizeOnDisk;
|
||||
|
||||
totalSizeOnDisk = MxDSObject::GetSizeOnDisk() + 90 + this->m_unk80;
|
||||
totalSizeOnDisk = MxDSObject::GetSizeOnDisk() + 90 + this->m_unkLength;
|
||||
this->m_sizeOnDisk = totalSizeOnDisk - MxDSObject::GetSizeOnDisk();
|
||||
|
||||
return totalSizeOnDisk;
|
||||
|
@ -116,11 +121,11 @@ void MxDSAction::Deserialize(char **p_source, MxS16 p_unk24)
|
|||
this->m_up[2] = *(double*) *p_source;
|
||||
*p_source += sizeof(double);
|
||||
|
||||
MxU16 extralen = *(MxU16*) *p_source;
|
||||
MxU16 unkLength = *(MxU16*) *p_source;
|
||||
*p_source += sizeof(MxU16);
|
||||
if (extralen) {
|
||||
FUN_100ADE60(extralen, *p_source);
|
||||
*p_source += extralen;
|
||||
if (unkLength) {
|
||||
AppendData(unkLength, *p_source);
|
||||
*p_source += unkLength;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,14 +186,14 @@ void MxDSAction::MergeFrom(MxDSAction &p_dsAction)
|
|||
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);
|
||||
MxU16 unkLength = p_dsAction.m_unkLength;
|
||||
char *unkData = p_dsAction.m_unkData;
|
||||
if (unkLength && unkData) {
|
||||
if (!this->m_unkData || !strncmp("XXX", this->m_unkData, 3)) {
|
||||
delete[] this->m_unkData;
|
||||
this->m_unkLength = 0;
|
||||
AppendData(unkLength, unkData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -216,8 +221,30 @@ MxLong MxDSAction::GetCurrentTime()
|
|||
return Timer()->GetTime() - this->m_someTimingField;
|
||||
}
|
||||
|
||||
// OFFSET: LEGO1 0x100ade60 STUB
|
||||
void MxDSAction::FUN_100ADE60(MxU16 p_length, void *p_data)
|
||||
// OFFSET: LEGO1 0x100ade60
|
||||
void MxDSAction::AppendData(MxU16 p_unkLength, const char *p_unkData)
|
||||
{
|
||||
// TOOD
|
||||
if (this->m_unkData == p_unkData || !p_unkData)
|
||||
return;
|
||||
|
||||
if (this->m_unkLength) {
|
||||
char *concat = new char[p_unkLength + this->m_unkLength + sizeof(g_unkSep)];
|
||||
memcpy(concat, this->m_unkData, this->m_unkLength);
|
||||
|
||||
*(MxU16*) &concat[this->m_unkLength] = g_unkSep;
|
||||
memcpy(&concat[this->m_unkLength + sizeof(g_unkSep)], p_unkData, p_unkLength);
|
||||
|
||||
this->m_unkLength += p_unkLength + sizeof(g_unkSep);
|
||||
delete[] this->m_unkData;
|
||||
this->m_unkData = concat;
|
||||
}
|
||||
else {
|
||||
char *copy = new char[p_unkLength];
|
||||
this->m_unkData = copy;
|
||||
|
||||
if (copy) {
|
||||
this->m_unkLength = p_unkLength;
|
||||
memcpy(copy, p_unkData, p_unkLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ class MxDSAction : public MxDSObject
|
|||
virtual MxLong GetSomeTimingField(); // vtable+3c;
|
||||
virtual MxLong GetCurrentTime(); // vtable+40;
|
||||
|
||||
void FUN_100ADE60(MxU16 p_length, void *p_data);
|
||||
void AppendData(MxU16 p_unkLength, const char *p_unkData);
|
||||
|
||||
private:
|
||||
MxU32 m_sizeOnDisk;
|
||||
|
@ -51,8 +51,8 @@ class MxDSAction : public MxDSObject
|
|||
MxVector3Data m_location;
|
||||
MxVector3Data m_direction;
|
||||
MxVector3Data m_up;
|
||||
undefined4 *m_unk7c;
|
||||
MxU16 m_unk80;
|
||||
char *m_unkData;
|
||||
MxU16 m_unkLength;
|
||||
undefined4 m_unk84;
|
||||
undefined4 m_unk88;
|
||||
MxOmni* m_omni; // 0x8c
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
#define SI_MAJOR_VERSION 2
|
||||
#define SI_MINOR_VERSION 2
|
||||
|
||||
#define FOURCC(a, b, c, d) (((a) << 0) | ((b) << 8) | ((c) << 16) | ((d) << 24))
|
||||
|
||||
// OFFSET: LEGO1 0x100cc4b0
|
||||
MxDSFile::MxDSFile(const char *filename, MxULong skipReadingChunks)
|
||||
{
|
||||
|
|
|
@ -41,4 +41,7 @@ typedef MxU8 MxBool;
|
|||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#define TWOCC(a, b) (((a) << 0) | ((b) << 8))
|
||||
#define FOURCC(a, b, c, d) (((a) << 0) | ((b) << 8) | ((c) << 16) | ((d) << 24))
|
||||
|
||||
#endif // MXTYPE_H
|
||||
|
|
Loading…
Reference in a new issue