2023-09-25 22:30:56 -04:00
|
|
|
#include "mxramstreamcontroller.h"
|
2023-10-24 19:38:27 -04:00
|
|
|
|
2023-10-29 10:01:14 -04:00
|
|
|
#include "mxautolocker.h"
|
2023-12-13 18:11:07 -05:00
|
|
|
#include "mxdsstreamingaction.h"
|
2023-10-08 16:41:34 -04:00
|
|
|
#include "mxramstreamprovider.h"
|
2023-09-25 22:30:56 -04:00
|
|
|
|
|
|
|
DECOMP_SIZE_ASSERT(MxRAMStreamController, 0x98);
|
2023-10-08 16:41:34 -04:00
|
|
|
|
2023-12-13 18:11:07 -05:00
|
|
|
undefined* __cdecl ReadData(MxU32* p_fileSizeBuffer, MxU32 p_fileSize);
|
2023-10-29 10:01:14 -04:00
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100c6110
|
2023-10-24 19:38:27 -04:00
|
|
|
MxResult MxRAMStreamController::Open(const char* p_filename)
|
2023-10-08 16:41:34 -04:00
|
|
|
{
|
2023-10-29 10:01:14 -04:00
|
|
|
MxAutoLocker locker(&m_criticalSection);
|
|
|
|
if (MxStreamController::Open(p_filename) != SUCCESS) {
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_provider = new MxRAMStreamProvider();
|
|
|
|
if (((MxRAMStreamProvider*) m_provider) != NULL) {
|
|
|
|
if (m_provider->SetResourceToGet(this) != SUCCESS) {
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
2023-12-13 18:11:07 -05:00
|
|
|
ReadData(
|
2023-10-29 10:01:14 -04:00
|
|
|
((MxRAMStreamProvider*) m_provider)->GetBufferOfFileSize(),
|
|
|
|
((MxRAMStreamProvider*) m_provider)->GetFileSize()
|
|
|
|
);
|
2023-10-30 09:54:00 -04:00
|
|
|
m_buffer.SetBufferPointer(
|
2023-10-29 10:01:14 -04:00
|
|
|
((MxRAMStreamProvider*) m_provider)->GetBufferOfFileSize(),
|
|
|
|
((MxRAMStreamProvider*) m_provider)->GetFileSize()
|
|
|
|
);
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
return FAILURE;
|
2023-10-08 16:41:34 -04:00
|
|
|
}
|
|
|
|
|
2023-12-13 18:11:07 -05:00
|
|
|
// FUNCTION: LEGO1 0x100c6210
|
2023-12-13 05:48:14 -05:00
|
|
|
MxResult MxRAMStreamController::VTable0x20(MxDSAction* p_action)
|
2023-10-08 16:41:34 -04:00
|
|
|
{
|
2023-12-13 18:11:07 -05:00
|
|
|
MxAutoLocker locker(&m_criticalSection);
|
|
|
|
MxS16 unk0x24 = 0;
|
|
|
|
MxResult result = FAILURE;
|
|
|
|
if (p_action->GetUnknown24() == -1) {
|
|
|
|
p_action->SetUnknown24(-3);
|
|
|
|
MxDSAction* action = m_unk0x54.Find(p_action, FALSE);
|
|
|
|
if (action != NULL) {
|
|
|
|
unk0x24 = action->GetUnknown24() + 1;
|
|
|
|
}
|
|
|
|
p_action->SetUnknown24(unk0x24);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (m_unk0x54.Find(p_action, FALSE)) {
|
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (MxStreamController::VTable0x20(p_action) == SUCCESS) {
|
|
|
|
MxDSStreamingAction* action = (MxDSStreamingAction*) m_unk0x3c.Find(p_action, FALSE);
|
|
|
|
MxDSStreamingAction streamingaction(*action);
|
|
|
|
result = DeserializeObject(streamingaction);
|
|
|
|
}
|
|
|
|
return result;
|
2023-10-08 16:41:34 -04:00
|
|
|
}
|
|
|
|
|
2023-12-11 16:17:25 -05:00
|
|
|
// FUNCTION: LEGO1 0x100c6320
|
2023-12-13 05:48:14 -05:00
|
|
|
MxResult MxRAMStreamController::VTable0x24(MxDSAction* p_action)
|
2023-10-08 16:41:34 -04:00
|
|
|
{
|
2023-12-11 16:17:25 -05:00
|
|
|
MxDSAction action;
|
|
|
|
do {
|
|
|
|
if (m_action0x60 != NULL) {
|
|
|
|
delete m_action0x60;
|
|
|
|
m_action0x60 = NULL;
|
|
|
|
}
|
|
|
|
action = *p_action;
|
2023-12-13 05:48:14 -05:00
|
|
|
MxStreamController::VTable0x24(&action);
|
2023-12-11 16:17:25 -05:00
|
|
|
} while (m_action0x60 != NULL);
|
|
|
|
return SUCCESS;
|
2023-10-08 16:41:34 -04:00
|
|
|
}
|
2023-11-21 03:44:45 -05:00
|
|
|
|
2023-12-13 18:11:07 -05:00
|
|
|
// FUNCTION: LEGO1 0x100c63c0
|
|
|
|
MxResult MxRAMStreamController::DeserializeObject(MxDSStreamingAction& p_action)
|
|
|
|
{
|
|
|
|
MxAutoLocker locker(&m_criticalSection);
|
|
|
|
MxResult result;
|
|
|
|
undefined4 value = 0;
|
|
|
|
do {
|
|
|
|
m_buffer.FUN_100c6f80(p_action.GetUnknown94());
|
|
|
|
result = m_buffer.FUN_100c67b0(this, &p_action, &value);
|
|
|
|
} while (m_unk0x3c.Find(&p_action, FALSE) != NULL);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// STUB: LEGO1 0x100d0d80
|
2023-12-13 18:11:07 -05:00
|
|
|
undefined* __cdecl ReadData(MxU32* p_fileSizeBuffer, MxU32 p_fileSize)
|
2023-11-21 03:44:45 -05:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|