Implement AnimState::Serialize

This commit is contained in:
jonschz 2024-06-14 16:16:59 +02:00
parent 26196c3dba
commit 5ae92bd12f
2 changed files with 65 additions and 10 deletions

View File

@ -78,11 +78,11 @@ class AnimState : public LegoState {
// AnimState::`scalar deleting destructor'
private:
undefined4 m_unk0x08; // 0x08
undefined4 m_unk0x0c; // 0x0c
void* m_unk0x10; // 0x10
undefined4 m_unk0x14; // 0x14
void* m_unk0x18; // 0x18
undefined4 m_unk0x08; // 0x08
undefined4 m_unk0x10_len; // 0x0c
undefined2* m_unk0x10; // 0x10
undefined4 m_unk0x18_len; // 0x14
undefined* m_unk0x18; // 0x18
};
// VTABLE: LEGO1 0x100d8c18

View File

@ -2826,9 +2826,9 @@ void LegoAnimationManager::FUN_10064b50(MxLong p_time)
// FUNCTION: LEGO1 0x10064ff0
AnimState::AnimState()
{
m_unk0x0c = 0;
m_unk0x10_len = 0;
m_unk0x10 = NULL;
m_unk0x14 = 0;
m_unk0x18_len = 0;
m_unk0x18 = NULL;
}
@ -2850,11 +2850,66 @@ void AnimState::FUN_10065240(MxU32, AnimInfo*, MxU32)
// TODO
}
// STUB: LEGO1 0x100652d0
// FUNCTION: LEGO1 0x100652d0
// FUNCTION: BETA10 0x10046621
MxResult AnimState::Serialize(LegoFile* p_file)
{
// TODO
return LegoState::Serialize(p_file);
// These two are equivalent up to the order of some deallocation.
// Choose as needed to get 100 %.
// Option 1:
// LegoState::Serialize(p_file);
// Option 2:
if (p_file->IsWriteMode()) {
p_file->WriteString(ClassName());
}
if (p_file->IsReadMode()) {
Read(p_file, &m_unk0x08);
// m_unk0x10_len and m_unk0x10
if (m_unk0x10) {
delete[] m_unk0x10;
}
Read(p_file, &m_unk0x10_len);
if (m_unk0x10_len != 0) {
m_unk0x10 = new undefined2[m_unk0x10_len];
}
else {
m_unk0x10 = NULL;
}
for (int i = 0; i < m_unk0x10_len; i++) {
Read(p_file, &m_unk0x10[i]);
}
// m_unk0x18_len and m_unk0x18
// Note that here we read first and then free memory in contrast to above
Read(p_file, &m_unk0x18_len);
if (m_unk0x18) {
delete[] m_unk0x18;
}
if (m_unk0x18_len != 0) {
m_unk0x18 = new undefined[m_unk0x18_len];
}
else {
m_unk0x18 = NULL;
}
for (int j = 0; j < m_unk0x18_len; j++) {
Read(p_file, &m_unk0x18[j]);
}
}
else if (p_file->IsWriteMode()) {
Write(p_file, m_unk0x08);
Write(p_file, m_unk0x10_len);
for (int i = 0; i < m_unk0x10_len; i++) {
Write(p_file, m_unk0x10[i]);
}
Write(p_file, m_unk0x18_len);
for (int j = 0; j < m_unk0x18_len; j++) {
Write(p_file, m_unk0x18[j]);
}
}
return SUCCESS;
}
// STUB: LEGO1 0x100654f0