diff --git a/CMakeLists.txt b/CMakeLists.txt index c78d6312ab..fcc86af800 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -258,7 +258,6 @@ function(add_lego_libraries NAME) LEGO1/omni/src/stream/mxstreamchunk.cpp LEGO1/omni/src/stream/mxstreamcontroller.cpp LEGO1/omni/src/stream/mxstreamer.cpp - LEGO1/omni/src/stream/mxstreamlist.cpp LEGO1/omni/src/stream/mxstreamprovider.cpp LEGO1/omni/src/system/mxautolock.cpp LEGO1/omni/src/system/mxcriticalsection.cpp diff --git a/LEGO1/omni/include/mxdiskstreamcontroller.h b/LEGO1/omni/include/mxdiskstreamcontroller.h index 9a1ad22c56..3b248b108d 100644 --- a/LEGO1/omni/include/mxdiskstreamcontroller.h +++ b/LEGO1/omni/include/mxdiskstreamcontroller.h @@ -53,15 +53,15 @@ class MxDiskStreamController : public MxStreamController { void FUN_100c8670(MxDSStreamingAction* p_streamingAction); private: - MxStreamListMxDSAction m_list0x64; // 0x64 - MxBool m_unk0x70; // 0x70 - list m_list0x74; // 0x74 - MxStreamListMxDSAction m_list0x80; // 0x80 - undefined2 m_unk0x8c; // 0x8c - MxStreamListMxDSAction m_list0x90; // 0x90 - MxCriticalSection m_critical9c; // 0x9c - MxStreamListMxDSAction m_list0xb8; // 0xb8 - MxBool m_unk0xc4; // 0xc4 + MxDSObjectList m_list0x64; // 0x64 + MxBool m_unk0x70; // 0x70 + list m_list0x74; // 0x74 + MxDSObjectList m_list0x80; // 0x80 + undefined2 m_unk0x8c; // 0x8c + MxDSObjectList m_list0x90; // 0x90 + MxCriticalSection m_critical9c; // 0x9c + MxDSObjectList m_list0xb8; // 0xb8 + MxBool m_unk0xc4; // 0xc4 void FUN_100c7970(); void FUN_100c7ce0(MxDSBuffer* p_buffer); diff --git a/LEGO1/omni/include/mxdiskstreamprovider.h b/LEGO1/omni/include/mxdiskstreamprovider.h index aa5a9ada5d..f379ea0071 100644 --- a/LEGO1/omni/include/mxdiskstreamprovider.h +++ b/LEGO1/omni/include/mxdiskstreamprovider.h @@ -5,7 +5,6 @@ #include "decomp.h" #include "mxcriticalsection.h" #include "mxdsaction.h" -#include "mxstreamlist.h" #include "mxstreamprovider.h" #include "mxthread.h" @@ -63,7 +62,7 @@ class MxDiskStreamProvider : public MxStreamProvider { MxBool m_remainingWork; // 0x34 MxBool m_unk0x35; // 0x35 MxCriticalSection m_criticalSection; // 0x38 - MxStreamListMxDSAction m_list; // 0x54 + MxDSObjectList m_list; // 0x54 }; // SYNTHETIC: LEGO1 0x100d10a0 diff --git a/LEGO1/omni/include/mxdsobject.h b/LEGO1/omni/include/mxdsobject.h index 6e3d2fc3d8..a0a5cb16a1 100644 --- a/LEGO1/omni/include/mxdsobject.h +++ b/LEGO1/omni/include/mxdsobject.h @@ -4,10 +4,25 @@ #include "decomp.h" #include "mxatom.h" #include "mxcore.h" +#include "mxutilitylist.h" class MxDSFile; +class MxDSObject; class MxPresenter; +// SIZE 0x0c +class MxDSObjectList : public MxUtilityList { +public: + // FUNCTION: BETA10 0x10150e30 + MxDSObject* FindAndErase(MxDSObject* p_action) { return FindInternal(p_action, TRUE); } + + // FUNCTION: BETA10 0x10150fc0 + MxDSObject* Find(MxDSObject* p_action) { return FindInternal(p_action, FALSE); } + +private: + MxDSObject* FindInternal(MxDSObject* p_action, MxBool p_delete); +}; + // VTABLE: LEGO1 0x100dc868 // VTABLE: BETA10 0x101c23f0 // SIZE 0x2c @@ -107,4 +122,7 @@ class MxDSObject : public MxCore { MxDSObject* DeserializeDSObjectDispatch(MxU8*&, MxS16); MxDSObject* CreateStreamObject(MxDSFile*, MxS16); +// TEMPLATE: BETA10 0x10150950 +// MxUtilityList::PopFront + #endif // MXDSOBJECT_H diff --git a/LEGO1/omni/include/mxdssubscriber.h b/LEGO1/omni/include/mxdssubscriber.h index e0334b5681..072a88bb8a 100644 --- a/LEGO1/omni/include/mxdssubscriber.h +++ b/LEGO1/omni/include/mxdssubscriber.h @@ -4,9 +4,18 @@ #include "decomp.h" #include "mxcore.h" #include "mxstreamchunklist.h" +#include "mxutilitylist.h" +class MxDSObject; +class MxDSSubscriber; class MxStreamController; +// SIZE 0x0c +class MxDSSubscriberList : public MxUtilityList { +public: + MxDSSubscriber* Find(MxDSObject* p_object); +}; + // VTABLE: LEGO1 0x100dc698 // VTABLE: BETA10 0x101c1d38 // SIZE 0x4c @@ -58,4 +67,7 @@ class MxDSSubscriber : public MxCore { // TEMPLATE: LEGO1 0x100b7d00 // MxStreamChunkList::~MxStreamChunkList +// TEMPLATE: BETA10 0x10150a70 +// MxUtilityList::PopFront + #endif // MXDSSUBSCRIBER_H diff --git a/LEGO1/omni/include/mxstreamchunk.h b/LEGO1/omni/include/mxstreamchunk.h index 72858cfe63..e68566ab66 100644 --- a/LEGO1/omni/include/mxstreamchunk.h +++ b/LEGO1/omni/include/mxstreamchunk.h @@ -4,7 +4,7 @@ #include "mxdschunk.h" class MxDSBuffer; -class MxStreamListMxDSSubscriber; +class MxDSSubscriberList; // VTABLE: LEGO1 0x100dc2a8 // VTABLE: BETA10 0x101c1d20 @@ -34,7 +34,7 @@ class MxStreamChunk : public MxDSChunk { MxResult ReadChunk(MxDSBuffer* p_buffer, MxU8* p_chunkData); MxU32 ReadChunkHeader(MxU8* p_chunkData); - MxResult SendChunk(MxStreamListMxDSSubscriber& p_subscriberList, MxBool p_append, MxS16 p_obj24val); + MxResult SendChunk(MxDSSubscriberList& p_subscriberList, MxBool p_append, MxS16 p_obj24val); void SetBuffer(MxDSBuffer* p_buffer); static MxU16* IntoFlags(MxU8* p_buffer); diff --git a/LEGO1/omni/include/mxstreamcontroller.h b/LEGO1/omni/include/mxstreamcontroller.h index e77cd39216..35996cf59d 100644 --- a/LEGO1/omni/include/mxstreamcontroller.h +++ b/LEGO1/omni/include/mxstreamcontroller.h @@ -5,13 +5,22 @@ #include "mxatom.h" #include "mxcore.h" #include "mxcriticalsection.h" +#include "mxdsobject.h" #include "mxdssubscriber.h" +#include "mxnextactiondatastart.h" #include "mxstl/stlcompat.h" -#include "mxstreamlist.h" +class MxDSAction; class MxDSStreamingAction; class MxStreamProvider; +// SIZE 0x0c +class MxNextActionDataStartList : public MxUtilityList { +public: + MxNextActionDataStart* Find(MxU32 p_id, MxS16 p_value); + MxNextActionDataStart* FindAndErase(MxU32 p_id, MxS16 p_value); +}; + // VTABLE: LEGO1 0x100dc968 // VTABLE: BETA10 0x101c26c0 // SIZE 0x64 @@ -55,20 +64,20 @@ class MxStreamController : public MxCore { MxAtomId& GetAtom() { return m_atom; } MxStreamProvider* GetProvider() { return m_provider; } - MxStreamListMxDSAction& GetUnk0x3c() { return m_unk0x3c; } - MxStreamListMxDSAction& GetUnk0x54() { return m_unk0x54; } - MxStreamListMxDSSubscriber& GetSubscriberList() { return m_subscriberList; } + MxDSObjectList& GetUnk0x3c() { return m_unk0x3c; } + MxDSObjectList& GetUnk0x54() { return m_unk0x54; } + MxDSSubscriberList& GetSubscriberList() { return m_subscriberList; } protected: - MxCriticalSection m_criticalSection; // 0x08 - MxAtomId m_atom; // 0x24 - MxStreamProvider* m_provider; // 0x28 - undefined4* m_unk0x2c; // 0x2c - MxStreamListMxDSSubscriber m_subscriberList; // 0x30 - MxStreamListMxDSAction m_unk0x3c; // 0x3c - MxStreamListMxNextActionDataStart m_nextActionList; // 0x48 - MxStreamListMxDSAction m_unk0x54; // 0x54 - MxDSAction* m_action0x60; // 0x60 + MxCriticalSection m_criticalSection; // 0x08 + MxAtomId m_atom; // 0x24 + MxStreamProvider* m_provider; // 0x28 + undefined4* m_unk0x2c; // 0x2c + MxDSSubscriberList m_subscriberList; // 0x30 + MxDSObjectList m_unk0x3c; // 0x3c + MxNextActionDataStartList m_nextActionList; // 0x48 + MxDSObjectList m_unk0x54; // 0x54 + MxDSAction* m_action0x60; // 0x60 }; // TEMPLATE: LEGO1 0x100c0d60 @@ -92,13 +101,13 @@ class MxStreamController : public MxCore { // MxStreamController::`scalar deleting destructor' // FUNCTION: LEGO1 0x100c0fc0 -// MxStreamListMxDSSubscriber::~MxStreamListMxDSSubscriber +// MxDSSubscriberList::~MxDSSubscriberList // FUNCTION: LEGO1 0x100c1010 -// MxStreamListMxDSAction::~MxStreamListMxDSAction +// MxDSObjectList::~MxDSObjectList // FUNCTION: LEGO1 0x100c1060 -// MxStreamListMxNextActionDataStart::~MxStreamListMxNextActionDataStart +// MxNextActionDataStartList::~MxNextActionDataStartList // TEMPLATE: LEGO1 0x100c10b0 // MxStreamList::~MxStreamList diff --git a/LEGO1/omni/include/mxstreamlist.h b/LEGO1/omni/include/mxstreamlist.h deleted file mode 100644 index 36a9350a3d..0000000000 --- a/LEGO1/omni/include/mxstreamlist.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef MXSTREAMLIST_H -#define MXSTREAMLIST_H - -#include "mxdsstreamingaction.h" -#include "mxdssubscriber.h" -#include "mxnextactiondatastart.h" -#include "mxstl/stlcompat.h" - -template -class MxStreamList : public list { -public: - MxBool PopFront(T& p_obj) - { - if (this->empty()) { - return FALSE; - } - - p_obj = this->front(); - this->pop_front(); - return TRUE; - } -}; - -// SIZE 0x0c -class MxStreamListMxDSAction : public MxStreamList { -public: - // FUNCTION: BETA10 0x10150e30 - MxDSAction* FindAndErase(MxDSAction* p_action) { return FindInternal(p_action, TRUE); } - - // FUNCTION: BETA10 0x10150fc0 - MxDSAction* Find(MxDSAction* p_action) { return FindInternal(p_action, FALSE); } - - // There chance this list actually holds MxDSStreamingListAction - // instead of MxDSAction. Until then, we use this helper. - MxBool PopFrontStreamingAction(MxDSStreamingAction*& p_obj) - { - if (empty()) { - return FALSE; - } - - p_obj = (MxDSStreamingAction*) front(); - pop_front(); - return TRUE; - } - -private: - MxDSAction* FindInternal(MxDSAction* p_action, MxBool p_delete); -}; - -// SIZE 0x0c -class MxStreamListMxNextActionDataStart : public MxStreamList { -public: - MxNextActionDataStart* Find(MxU32 p_id, MxS16 p_value); - MxNextActionDataStart* FindAndErase(MxU32 p_id, MxS16 p_value); -}; - -// SIZE 0x0c -class MxStreamListMxDSSubscriber : public MxStreamList { -public: - MxDSSubscriber* Find(MxDSObject* p_object); -}; - -// TEMPLATE: BETA10 0x10150950 -// MxStreamList::PopFront - -// TEMPLATE: BETA10 0x10150a70 -// MxStreamList::PopFront - -#endif // MXSTREAMLIST_H diff --git a/LEGO1/omni/include/mxutilitylist.h b/LEGO1/omni/include/mxutilitylist.h new file mode 100644 index 0000000000..c9f75f77c5 --- /dev/null +++ b/LEGO1/omni/include/mxutilitylist.h @@ -0,0 +1,23 @@ +#ifndef MXUTILITYLIST_H +#define MXUTILITYLIST_H + +#include "mxstl/mxstl.h" + +// Probably should be defined somewhere else + +template +class MxUtilityList : public list { +public: + MxBool PopFront(T& p_obj) + { + if (this->empty()) { + return FALSE; + } + + p_obj = this->front(); + this->pop_front(); + return TRUE; + } +}; + +#endif // MXUTILITYLIST_H diff --git a/LEGO1/omni/src/action/mxdsobject.cpp b/LEGO1/omni/src/action/mxdsobject.cpp index 3bb189c712..6cea1ea0cb 100644 --- a/LEGO1/omni/src/action/mxdsobject.cpp +++ b/LEGO1/omni/src/action/mxdsobject.cpp @@ -17,7 +17,8 @@ #include #include -DECOMP_SIZE_ASSERT(MxDSObject, 0x2c); +DECOMP_SIZE_ASSERT(MxDSObject, 0x2c) +DECOMP_SIZE_ASSERT(MxDSObjectList, 0x0c) // FUNCTION: LEGO1 0x100bf6a0 // FUNCTION: BETA10 0x101478c0 @@ -172,6 +173,38 @@ void MxDSObject::Deserialize(MxU8*& p_source, MxS16 p_unk0x24) m_unk0x24 = p_unk0x24; } +// FUNCTION: LEGO1 0x100bfa80 +// FUNCTION: BETA10 0x10147e02 +MxDSObject* MxDSObjectList::FindInternal(MxDSObject* p_action, MxBool p_delete) +{ + // DECOMP ALPHA 0x1008b99d ? + + MxDSObject* found = NULL; + +#ifdef COMPAT_MODE + iterator it; + for (it = begin(); it != end(); it++) { +#else + for (iterator it = begin(); it != end(); it++) { +#endif + if (p_action->GetObjectId() == -1 || p_action->GetObjectId() == (*it)->GetObjectId()) { + if (p_action->GetUnknown24() == -2 || p_action->GetUnknown24() == -3 || + p_action->GetUnknown24() == (*it)->GetUnknown24()) { + found = *it; + if (p_action->GetUnknown24() != -3) { + break; + } + } + } + } + + if (p_delete && found != NULL) { + erase(it); + } + + return found; +} + // FUNCTION: LEGO1 0x100bfb30 // FUNCTION: BETA10 0x10147f35 MxDSObject* DeserializeDSObjectDispatch(MxU8*& p_source, MxS16 p_flags) diff --git a/LEGO1/omni/src/main/mxomni.cpp b/LEGO1/omni/src/main/mxomni.cpp index 883aa008a4..b851b6fd51 100644 --- a/LEGO1/omni/src/main/mxomni.cpp +++ b/LEGO1/omni/src/main/mxomni.cpp @@ -340,7 +340,7 @@ MxLong MxOmni::HandleEndAction(MxParam& p_param) MxStreamController* controller = Streamer()->GetOpenStream(action->GetAtomId().GetInternal()); if (controller != NULL) { - action = controller->GetUnk0x54().Find(action); + action = (MxDSAction*) controller->GetUnk0x54().Find(action); if (action) { if (ActionSourceEquals(action, "LegoLoopingAnimPresenter") == FALSE) { delete controller->GetUnk0x54().FindAndErase(action); diff --git a/LEGO1/omni/src/stream/mxdiskstreamcontroller.cpp b/LEGO1/omni/src/stream/mxdiskstreamcontroller.cpp index 2e7407647e..c1341877a3 100644 --- a/LEGO1/omni/src/stream/mxdiskstreamcontroller.cpp +++ b/LEGO1/omni/src/stream/mxdiskstreamcontroller.cpp @@ -35,9 +35,9 @@ MxDiskStreamController::~MxDiskStreamController() #endif } - MxDSAction* action; - while (m_unk0x3c.PopFront(action)) { - delete action; + MxDSObject* object; + while (m_unk0x3c.PopFront(object)) { + delete object; } if (m_provider) { @@ -47,12 +47,12 @@ MxDiskStreamController::~MxDiskStreamController() FUN_100c8720(); - while (m_list0x80.PopFront(action)) { - FUN_100c7cb0((MxDSStreamingAction*) action); + while (m_list0x80.PopFront(object)) { + FUN_100c7cb0((MxDSStreamingAction*) object); } - while (m_list0x64.PopFront(action)) { - FUN_100c7cb0((MxDSStreamingAction*) action); + while (m_list0x64.PopFront(object)) { + FUN_100c7cb0((MxDSStreamingAction*) object); } while (!m_list0x74.empty()) { @@ -162,7 +162,7 @@ void MxDiskStreamController::FUN_100c7980() MxDSStreamingAction* MxDiskStreamController::VTable0x28() { AUTOLOCK(m_criticalSection); - MxDSAction* oldAction; + MxDSObject* oldAction; MxDSStreamingAction* result = NULL; MxU32 filesize = m_provider->GetFileSize(); @@ -252,10 +252,9 @@ MxDSStreamingAction* MxDiskStreamController::FUN_100c7db0() { AUTOLOCK(m_criticalSection); - for (MxStreamListMxNextActionDataStart::iterator it = m_nextActionList.begin(); it != m_nextActionList.end(); - it++) { + for (MxNextActionDataStartList::iterator it = m_nextActionList.begin(); it != m_nextActionList.end(); it++) { MxNextActionDataStart* data = *it; - for (MxStreamListMxDSAction::iterator it2 = m_list0x64.begin(); it2 != m_list0x64.end(); it2++) { + for (MxDSObjectList::iterator it2 = m_list0x64.begin(); it2 != m_list0x64.end(); it2++) { MxDSStreamingAction* streamingAction = (MxDSStreamingAction*) *it2; if (streamingAction->GetObjectId() == data->GetObjectId() && streamingAction->GetUnknown24() == data->GetUnknown24() && @@ -320,7 +319,7 @@ void MxDiskStreamController::FUN_100c8120(MxDSAction* p_action) } while (TRUE) { - MxDSAction* found = m_unk0x54.FindAndErase(p_action); + MxDSObject* found = m_unk0x54.FindAndErase(p_action); if (!found) { break; } diff --git a/LEGO1/omni/src/stream/mxdiskstreamprovider.cpp b/LEGO1/omni/src/stream/mxdiskstreamprovider.cpp index 1f7dba15db..eb6cbc546c 100644 --- a/LEGO1/omni/src/stream/mxdiskstreamprovider.cpp +++ b/LEGO1/omni/src/stream/mxdiskstreamprovider.cpp @@ -38,15 +38,15 @@ MxResult MxDiskStreamProviderThread::StartWithTarget(MxDiskStreamProvider* p_tar // FUNCTION: LEGO1 0x100d0f70 MxDiskStreamProvider::MxDiskStreamProvider() { - this->m_pFile = NULL; - this->m_remainingWork = FALSE; - this->m_unk0x35 = FALSE; + m_pFile = NULL; + m_remainingWork = FALSE; + m_unk0x35 = FALSE; } // FUNCTION: LEGO1 0x100d1240 MxDiskStreamProvider::~MxDiskStreamProvider() { - MxDSStreamingAction* action; + MxDSObject* action; m_unk0x35 = FALSE; do { @@ -54,18 +54,18 @@ MxDiskStreamProvider::~MxDiskStreamProvider() { AUTOLOCK(m_criticalSection); - m_list.PopFrontStreamingAction(action); + m_list.PopFront(action); } if (!action) { break; } - if (action->GetUnknowna0()->GetWriteOffset() < 0x20000) { + if (((MxDSStreamingAction*) action)->GetUnknowna0()->GetWriteOffset() < 0x20000) { g_unk0x10102878--; } - ((MxDiskStreamController*) m_pLookup)->FUN_100c8670(action); + ((MxDiskStreamController*) m_pLookup)->FUN_100c8670((MxDSStreamingAction*) action); } while (action); if (m_remainingWork) { @@ -116,7 +116,7 @@ MxResult MxDiskStreamProvider::SetResourceToGet(MxStreamController* p_resource) // FUNCTION: LEGO1 0x100d15e0 void MxDiskStreamProvider::VTable0x20(MxDSAction* p_action) { - MxDSStreamingAction* action; + MxDSObject* action; if (p_action->GetObjectId() == -1) { m_unk0x35 = FALSE; @@ -126,18 +126,18 @@ void MxDiskStreamProvider::VTable0x20(MxDSAction* p_action) { AUTOLOCK(m_criticalSection); - m_list.PopFrontStreamingAction(action); + m_list.PopFront(action); } if (!action) { return; } - if (action->GetUnknowna0()->GetWriteOffset() < 0x20000) { + if (((MxDSStreamingAction*) action)->GetUnknowna0()->GetWriteOffset() < 0x20000) { g_unk0x10102878--; } - ((MxDiskStreamController*) m_pLookup)->FUN_100c8670(action); + ((MxDiskStreamController*) m_pLookup)->FUN_100c8670((MxDSStreamingAction*) action); } while (action); } else { @@ -151,11 +151,11 @@ void MxDiskStreamProvider::VTable0x20(MxDSAction* p_action) return; } - if (action->GetUnknowna0()->GetWriteOffset() < 0x20000) { + if (((MxDSStreamingAction*) action)->GetUnknowna0()->GetWriteOffset() < 0x20000) { g_unk0x10102878--; } - ((MxDiskStreamController*) m_pLookup)->FUN_100c8670(action); + ((MxDiskStreamController*) m_pLookup)->FUN_100c8670((MxDSStreamingAction*) action); } while (action); } } @@ -213,14 +213,14 @@ MxResult MxDiskStreamProvider::FUN_100d1780(MxDSStreamingAction* p_action) void MxDiskStreamProvider::PerformWork() { MxDiskStreamController* controller = (MxDiskStreamController*) m_pLookup; - MxDSStreamingAction* streamingAction = NULL; + MxDSObject* streamingAction = NULL; { AUTOLOCK(m_criticalSection); if (!m_list.empty()) { - streamingAction = (MxDSStreamingAction*) m_list.front(); + streamingAction = m_list.front(); - if (streamingAction && !FUN_100d1af0(streamingAction)) { + if (streamingAction && !FUN_100d1af0((MxDSStreamingAction*) streamingAction)) { m_thread.Sleep(500); m_busySemaphore.Release(1); return; @@ -233,33 +233,33 @@ void MxDiskStreamProvider::PerformWork() { AUTOLOCK(m_criticalSection); - if (!m_list.PopFrontStreamingAction(streamingAction)) { + if (!m_list.PopFront(streamingAction)) { goto done; } } - if (streamingAction->GetUnknowna0()->GetWriteOffset() < 0x20000) { + if (((MxDSStreamingAction*) streamingAction)->GetUnknowna0()->GetWriteOffset() < 0x20000) { g_unk0x10102878--; } - buffer = streamingAction->GetUnknowna0(); + buffer = ((MxDSStreamingAction*) streamingAction)->GetUnknowna0(); - if (m_pFile->GetPosition() == streamingAction->GetBufferOffset() || - m_pFile->Seek(streamingAction->GetBufferOffset(), SEEK_SET) == 0) { + if (m_pFile->GetPosition() == ((MxDSStreamingAction*) streamingAction)->GetBufferOffset() || + m_pFile->Seek(((MxDSStreamingAction*) streamingAction)->GetBufferOffset(), SEEK_SET) == 0) { buffer->SetUnknown14(m_pFile->GetPosition()); if (m_pFile->ReadToBuffer(buffer) == SUCCESS) { buffer->SetUnknown1c(m_pFile->GetPosition()); - if (streamingAction->GetUnknown9c() > 0) { - FUN_100d1b20(streamingAction); + if (((MxDSStreamingAction*) streamingAction)->GetUnknown9c() > 0) { + FUN_100d1b20(((MxDSStreamingAction*) streamingAction)); } else { if (m_pLookup == NULL || !((MxDiskStreamController*) m_pLookup)->GetUnk0xc4()) { - controller->FUN_100c8670(streamingAction); + controller->FUN_100c8670(((MxDSStreamingAction*) streamingAction)); } else { - controller->FUN_100c7f40(streamingAction); + controller->FUN_100c7f40(((MxDSStreamingAction*) streamingAction)); } } @@ -269,7 +269,7 @@ void MxDiskStreamProvider::PerformWork() done: if (streamingAction) { - controller->FUN_100c8670(streamingAction); + controller->FUN_100c8670(((MxDSStreamingAction*) streamingAction)); } m_thread.Sleep(0); diff --git a/LEGO1/omni/src/stream/mxdssubscriber.cpp b/LEGO1/omni/src/stream/mxdssubscriber.cpp index 8900ff6945..36051667ac 100644 --- a/LEGO1/omni/src/stream/mxdssubscriber.cpp +++ b/LEGO1/omni/src/stream/mxdssubscriber.cpp @@ -2,7 +2,8 @@ #include "mxstreamcontroller.h" -DECOMP_SIZE_ASSERT(MxDSSubscriber, 0x4c); +DECOMP_SIZE_ASSERT(MxDSSubscriber, 0x4c) +DECOMP_SIZE_ASSERT(MxDSSubscriberList, 0x0c) // FUNCTION: LEGO1 0x100b7bb0 MxDSSubscriber::MxDSSubscriber() @@ -135,3 +136,18 @@ void MxDSSubscriber::FreeDataChunk(MxStreamChunk* p_chunk) } } } + +// FUNCTION: LEGO1 0x100b8450 +// FUNCTION: BETA10 0x10134c1d +MxDSSubscriber* MxDSSubscriberList::Find(MxDSObject* p_object) +{ + for (iterator it = begin(); it != end(); it++) { + if (p_object->GetObjectId() == -1 || p_object->GetObjectId() == (*it)->GetObjectId()) { + if (p_object->GetUnknown24() == -2 || p_object->GetUnknown24() == (*it)->GetUnknown48()) { + return *it; + } + } + } + + return NULL; +} diff --git a/LEGO1/omni/src/stream/mxramstreamcontroller.cpp b/LEGO1/omni/src/stream/mxramstreamcontroller.cpp index 46d11196c3..c856d69532 100644 --- a/LEGO1/omni/src/stream/mxramstreamcontroller.cpp +++ b/LEGO1/omni/src/stream/mxramstreamcontroller.cpp @@ -43,7 +43,7 @@ MxResult MxRAMStreamController::VTable0x20(MxDSAction* p_action) if (p_action->GetUnknown24() == -1) { p_action->SetUnknown24(-3); - MxDSAction* action = m_unk0x54.Find(p_action); + MxDSObject* action = m_unk0x54.Find(p_action); if (action != NULL) { unk0x24 = action->GetUnknown24() + 1; } diff --git a/LEGO1/omni/src/stream/mxstreamchunk.cpp b/LEGO1/omni/src/stream/mxstreamchunk.cpp index 4cf4fe4bb6..24c134452b 100644 --- a/LEGO1/omni/src/stream/mxstreamchunk.cpp +++ b/LEGO1/omni/src/stream/mxstreamchunk.cpp @@ -1,7 +1,7 @@ #include "mxstreamchunk.h" #include "mxdsbuffer.h" -#include "mxstreamlist.h" +#include "mxdssubscriber.h" #include "mxutilities.h" // FUNCTION: LEGO1 0x100c2fe0 @@ -58,9 +58,9 @@ MxU32 MxStreamChunk::ReadChunkHeader(MxU8* p_chunkData) // FUNCTION: LEGO1 0x100c30e0 // FUNCTION: BETA10 0x10151517 -MxResult MxStreamChunk::SendChunk(MxStreamListMxDSSubscriber& p_subscriberList, MxBool p_append, MxS16 p_obj24val) +MxResult MxStreamChunk::SendChunk(MxDSSubscriberList& p_subscriberList, MxBool p_append, MxS16 p_obj24val) { - for (MxStreamListMxDSSubscriber::iterator it = p_subscriberList.begin(); it != p_subscriberList.end(); it++) { + for (MxDSSubscriberList::iterator it = p_subscriberList.begin(); it != p_subscriberList.end(); it++) { if ((*it)->GetObjectId() == m_objectId && (*it)->GetUnknown48() == p_obj24val) { if (m_flags & DS_CHUNK_END_OF_STREAM && m_buffer) { m_buffer->ReleaseRef(this); diff --git a/LEGO1/omni/src/stream/mxstreamcontroller.cpp b/LEGO1/omni/src/stream/mxstreamcontroller.cpp index 35b1315cb9..4552d7ef14 100644 --- a/LEGO1/omni/src/stream/mxstreamcontroller.cpp +++ b/LEGO1/omni/src/stream/mxstreamcontroller.cpp @@ -14,6 +14,7 @@ DECOMP_SIZE_ASSERT(MxStreamController, 0x64) DECOMP_SIZE_ASSERT(MxNextActionDataStart, 0x14) +DECOMP_SIZE_ASSERT(MxNextActionDataStartList, 0x0c) // FUNCTION: LEGO1 0x100b9400 MxResult MxStreamController::VTable0x18(undefined4, undefined4) @@ -53,7 +54,7 @@ MxStreamController::~MxStreamController() delete subscriber; } - MxDSAction* action; + MxDSObject* action; while (m_unk0x3c.PopFront(action)) { delete action; } @@ -135,7 +136,7 @@ MxResult MxStreamController::VTable0x24(MxDSAction* p_action) { AUTOLOCK(m_criticalSection); VTable0x30(p_action); - m_action0x60 = m_unk0x54.FindAndErase(p_action); + m_action0x60 = (MxDSAction*) m_unk0x54.FindAndErase(p_action); if (m_action0x60 == NULL) { return FAILURE; } @@ -166,8 +167,8 @@ MxResult MxStreamController::FUN_100c1a00(MxDSAction* p_action, MxU32 p_offset) MxS16 newUnknown24 = -1; // These loops might be a template function in the list classes - for (MxStreamListMxDSAction::iterator it = m_unk0x54.begin(); it != m_unk0x54.end(); it++) { - MxDSAction* action = *it; + for (MxDSObjectList::iterator it = m_unk0x54.begin(); it != m_unk0x54.end(); it++) { + MxDSObject* action = *it; if (action->GetObjectId() == p_action->GetObjectId()) { newUnknown24 = Max(newUnknown24, action->GetUnknown24()); @@ -175,8 +176,8 @@ MxResult MxStreamController::FUN_100c1a00(MxDSAction* p_action, MxU32 p_offset) } if (newUnknown24 == -1) { - for (MxStreamListMxDSAction::iterator it = m_unk0x3c.begin(); it != m_unk0x3c.end(); it++) { - MxDSAction* action = *it; + for (MxDSObjectList::iterator it = m_unk0x3c.begin(); it != m_unk0x3c.end(); it++) { + MxDSObject* action = *it; if (action->GetObjectId() == p_action->GetObjectId()) { newUnknown24 = Max(newUnknown24, action->GetUnknown24()); @@ -184,8 +185,7 @@ MxResult MxStreamController::FUN_100c1a00(MxDSAction* p_action, MxU32 p_offset) } if (newUnknown24 == -1) { - for (MxStreamListMxDSSubscriber::iterator it = m_subscriberList.begin(); it != m_subscriberList.end(); - it++) { + for (MxDSSubscriberList::iterator it = m_subscriberList.begin(); it != m_subscriberList.end(); it++) { MxDSSubscriber* subscriber = *it; if (subscriber->GetObjectId() == p_action->GetObjectId()) { @@ -235,7 +235,7 @@ MxResult MxStreamController::VTable0x30(MxDSAction* p_action) { AUTOLOCK(m_criticalSection); MxResult result = FAILURE; - MxDSAction* action = m_unk0x3c.FindAndErase(p_action); + MxDSObject* action = m_unk0x3c.FindAndErase(p_action); if (action != NULL) { MxNextActionDataStart* data = m_nextActionList.FindAndErase(action->GetObjectId(), action->GetUnknown24()); delete action; @@ -266,7 +266,7 @@ MxPresenter* MxStreamController::FUN_100c1e70(MxDSAction& p_action) AUTOLOCK(m_criticalSection); MxPresenter* result = NULL; if (p_action.GetObjectId() != -1) { - MxDSAction* action = m_unk0x3c.Find(&p_action); + MxDSObject* action = m_unk0x3c.Find(&p_action); if (action != NULL) { result = action->GetUnknown28(); } @@ -344,3 +344,33 @@ MxBool MxStreamController::IsStoped(MxDSObject* p_obj) return TRUE; } + +// FUNCTION: LEGO1 0x100c21e0 +// FUNCTION: BETA10 0x1014f4e6 +MxNextActionDataStart* MxNextActionDataStartList::Find(MxU32 p_id, MxS16 p_value) +{ + for (iterator it = begin(); it != end(); it++) { + if (p_id == (*it)->GetObjectId() && p_value == (*it)->GetUnknown24()) { + return *it; + } + } + + return NULL; +} + +// FUNCTION: LEGO1 0x100c2240 +// FUNCTION: BETA10 0x1014f58c +MxNextActionDataStart* MxNextActionDataStartList::FindAndErase(MxU32 p_id, MxS16 p_value) +{ + MxNextActionDataStart* match = NULL; + + for (iterator it = begin(); it != end(); it++) { + if (p_id == (*it)->GetObjectId() && (p_value == -2 || p_value == (*it)->GetUnknown24())) { + match = *it; + erase(it); + break; + } + } + + return match; +} diff --git a/LEGO1/omni/src/stream/mxstreamer.cpp b/LEGO1/omni/src/stream/mxstreamer.cpp index c3a64cf9c6..bb5f1cb530 100644 --- a/LEGO1/omni/src/stream/mxstreamer.cpp +++ b/LEGO1/omni/src/stream/mxstreamer.cpp @@ -2,6 +2,7 @@ #include "mxdebug.h" #include "mxdiskstreamcontroller.h" +#include "mxdsaction.h" #include "mxmisc.h" #include "mxnotificationmanager.h" #include "mxramstreamcontroller.h" diff --git a/LEGO1/omni/src/stream/mxstreamlist.cpp b/LEGO1/omni/src/stream/mxstreamlist.cpp deleted file mode 100644 index 37e594634b..0000000000 --- a/LEGO1/omni/src/stream/mxstreamlist.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include "mxstreamlist.h" - -// Wrappers around STL list that are used by the MxStream* classes. -DECOMP_SIZE_ASSERT(MxStreamListMxDSAction, 0x0c); -DECOMP_SIZE_ASSERT(MxStreamListMxNextActionDataStart, 0x0c); -DECOMP_SIZE_ASSERT(MxStreamListMxDSSubscriber, 0x0c); - -// FUNCTION: LEGO1 0x100b8450 -// FUNCTION: BETA10 0x10134c1d -MxDSSubscriber* MxStreamListMxDSSubscriber::Find(MxDSObject* p_object) -{ - for (iterator it = begin(); it != end(); it++) { - if (p_object->GetObjectId() == -1 || p_object->GetObjectId() == (*it)->GetObjectId()) { - if (p_object->GetUnknown24() == -2 || p_object->GetUnknown24() == (*it)->GetUnknown48()) { - return *it; - } - } - } - - return NULL; -} - -// FUNCTION: LEGO1 0x100bfa80 -// FUNCTION: BETA10 0x10147e02 -MxDSAction* MxStreamListMxDSAction::FindInternal(MxDSAction* p_action, MxBool p_delete) -{ - // DECOMP ALPHA 0x1008b99d ? - - MxDSAction* found = NULL; - -#ifdef COMPAT_MODE - iterator it; - for (it = begin(); it != end(); it++) { -#else - for (iterator it = begin(); it != end(); it++) { -#endif - if (p_action->GetObjectId() == -1 || p_action->GetObjectId() == (*it)->GetObjectId()) { - if (p_action->GetUnknown24() == -2 || p_action->GetUnknown24() == -3 || - p_action->GetUnknown24() == (*it)->GetUnknown24()) { - found = *it; - if (p_action->GetUnknown24() != -3) { - break; - } - } - } - } - - if (p_delete && found != NULL) { - erase(it); - } - - return found; -} - -// FUNCTION: LEGO1 0x100c21e0 -// FUNCTION: BETA10 0x1014f4e6 -MxNextActionDataStart* MxStreamListMxNextActionDataStart::Find(MxU32 p_id, MxS16 p_value) -{ - for (iterator it = begin(); it != end(); it++) { - if (p_id == (*it)->GetObjectId() && p_value == (*it)->GetUnknown24()) { - return *it; - } - } - - return NULL; -} - -// FUNCTION: LEGO1 0x100c2240 -// FUNCTION: BETA10 0x1014f58c -MxNextActionDataStart* MxStreamListMxNextActionDataStart::FindAndErase(MxU32 p_id, MxS16 p_value) -{ - MxNextActionDataStart* match = NULL; - - for (iterator it = begin(); it != end(); it++) { - if (p_id == (*it)->GetObjectId() && (p_value == -2 || p_value == (*it)->GetUnknown24())) { - match = *it; - erase(it); - break; - } - } - - return match; -}