From 503941c11ac6a5078a52885d264efd59f6d6c6dc Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Mon, 25 Dec 2023 12:00:31 -0500 Subject: [PATCH] Mostly match MxDiskStreamProvider::FUN_100d1780 --- LEGO1/mxdiskstreamcontroller.cpp | 1 + LEGO1/mxdiskstreamprovider.cpp | 51 ++++++++++++++++---------------- LEGO1/mxdiskstreamprovider.h | 1 - LEGO1/mxdsstreamingaction.h | 2 +- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/LEGO1/mxdiskstreamcontroller.cpp b/LEGO1/mxdiskstreamcontroller.cpp index a1e7d7ff..1520ba3b 100644 --- a/LEGO1/mxdiskstreamcontroller.cpp +++ b/LEGO1/mxdiskstreamcontroller.cpp @@ -341,6 +341,7 @@ void MxDiskStreamController::FUN_100c8540() MxAutoLocker lock(&this->m_criticalSection); for (list::iterator it = m_list0x74.begin(); it != m_list0x74.end();) { MxDSBuffer* buf = *it; + // TODO: Match if (buf->GetRefCount() == 0) { m_list0x74.erase(it++); FUN_100c7ce0(buf); diff --git a/LEGO1/mxdiskstreamprovider.cpp b/LEGO1/mxdiskstreamprovider.cpp index d1f88fb2..2aa25e02 100644 --- a/LEGO1/mxdiskstreamprovider.cpp +++ b/LEGO1/mxdiskstreamprovider.cpp @@ -96,34 +96,35 @@ MxResult MxDiskStreamProvider::WaitForWorkToComplete() // FUNCTION: LEGO1 0x100d1780 MxResult MxDiskStreamProvider::FUN_100d1780(MxDSStreamingAction* p_action) { - if (m_remainingWork != 0) { - if (p_action->GetUnknown94() > 0 && !p_action->GetUnknowna0()) { - MxDSBuffer* buffer = new MxDSBuffer(); - if (buffer) { - if (buffer->AllocateBuffer(GetFileSize(), MxDSBufferType_Allocate) == SUCCESS) { - p_action->SetUnknowna0(buffer); - } - else { - delete buffer; - return FAILURE; - } - } + if (m_remainingWork == 0) + return FAILURE; + + if (p_action->GetUnknown9c() > 0 && !p_action->GetUnknowna0()) { + MxDSBuffer* buffer = new MxDSBuffer(); + + if (!buffer) + return FAILURE; + + if (buffer->AllocateBuffer(GetFileSize(), MxDSBufferType_Allocate) != SUCCESS) { + delete buffer; + return FAILURE; } - if (p_action->GetUnknowna0()->GetWriteOffset() < 0x20000) { - g_unk0x10102878++; - } - - { - MxAutoLocker lock(&m_criticalSection); - m_list.push_back(p_action); - } - - m_unk0x35 = 1; - m_busySemaphore.Release(1); - return SUCCESS; + p_action->SetUnknowna0(buffer); } - return FAILURE; + + if (p_action->GetUnknowna0()->GetWriteOffset() < 0x20000) { + g_unk0x10102878++; + } + + { + MxAutoLocker lock(&m_criticalSection); + m_list.push_back(p_action); + } + + m_unk0x35 = 1; + m_busySemaphore.Release(1); + return SUCCESS; } // FUNCTION: LEGO1 0x100d18f0 diff --git a/LEGO1/mxdiskstreamprovider.h b/LEGO1/mxdiskstreamprovider.h index 4f54a3ed..8bf1b16e 100644 --- a/LEGO1/mxdiskstreamprovider.h +++ b/LEGO1/mxdiskstreamprovider.h @@ -27,7 +27,6 @@ class MxDiskStreamProviderThread : public MxThread { class MxDiskStreamProvider : public MxStreamProvider { public: MxDiskStreamProvider(); - virtual ~MxDiskStreamProvider() override; // FUNCTION: LEGO1 0x100d1160 diff --git a/LEGO1/mxdsstreamingaction.h b/LEGO1/mxdsstreamingaction.h index 703b7a14..dd4e6683 100644 --- a/LEGO1/mxdsstreamingaction.h +++ b/LEGO1/mxdsstreamingaction.h @@ -32,7 +32,7 @@ class MxDSStreamingAction : public MxDSAction { void FUN_100cd2d0(); inline MxU32 GetUnknown94() { return m_unk0x94; } - inline MxU32 GetUnknown9c() { return m_unk0x9c; } + inline MxS32 GetUnknown9c() { return m_unk0x9c; } inline MxDSBuffer* GetUnknowna0() { return m_unk0xa0; } inline MxDSBuffer* GetUnknowna4() { return m_unk0xa4; } inline MxDSAction* GetInternalAction() { return m_internalAction; }