Move CreateStreamObject to proper location (#1249)

This commit is contained in:
Christian Semmler
2024-12-20 14:15:52 -07:00
committed by GitHub
parent c9acd9a49f
commit 5a61cf6566
8 changed files with 61 additions and 72 deletions

View File

@@ -3,6 +3,7 @@
#include "mxdsaction.h"
#include "mxdsanim.h"
#include "mxdsevent.h"
#include "mxdsfile.h"
#include "mxdsmediaaction.h"
#include "mxdsmultiaction.h"
#include "mxdsobjectaction.h"
@@ -227,3 +228,39 @@ MxDSObject* DeserializeDSObjectDispatch(MxU8*& p_source, MxS16 p_flags)
return obj;
}
// FUNCTION: LEGO1 0x100c0280
MxDSObject* CreateStreamObject(MxDSFile* p_file, MxS16 p_ofs)
{
MxU8* buf;
_MMCKINFO tmpChunk;
if (p_file->Seek(((MxLong*) p_file->GetBuffer())[p_ofs], SEEK_SET)) {
return NULL;
}
if (p_file->Read((MxU8*) &tmpChunk.ckid, 8) == 0 && tmpChunk.ckid == FOURCC('M', 'x', 'S', 't')) {
if (p_file->Read((MxU8*) &tmpChunk.ckid, 8) == 0 && tmpChunk.ckid == FOURCC('M', 'x', 'O', 'b')) {
buf = new MxU8[tmpChunk.cksize];
if (!buf) {
return NULL;
}
if (p_file->Read(buf, tmpChunk.cksize) != 0) {
return NULL;
}
// Save a copy so we can clean up properly, because
// this function will alter the pointer value.
MxU8* copy = buf;
MxDSObject* obj = DeserializeDSObjectDispatch(buf, -1);
delete[] copy;
return obj;
}
return NULL;
}
return NULL;
}