Skip to content

Commit

Permalink
Refactor stream lists
Browse files Browse the repository at this point in the history
  • Loading branch information
foxtacles committed Dec 22, 2024
1 parent cbc3d72 commit 49b03cb
Show file tree
Hide file tree
Showing 19 changed files with 224 additions and 237 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions LEGO1/omni/include/mxdiskstreamcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ class MxDiskStreamController : public MxStreamController {
void FUN_100c8670(MxDSStreamingAction* p_streamingAction);

private:
MxStreamListMxDSAction m_list0x64; // 0x64
MxBool m_unk0x70; // 0x70
list<MxDSBuffer*> 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<MxDSBuffer*> 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);
Expand Down
3 changes: 1 addition & 2 deletions LEGO1/omni/include/mxdiskstreamprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "decomp.h"
#include "mxcriticalsection.h"
#include "mxdsaction.h"
#include "mxstreamlist.h"
#include "mxstreamprovider.h"
#include "mxthread.h"

Expand Down Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions LEGO1/omni/include/mxdsobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<MxDSObject*> {
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
Expand Down Expand Up @@ -107,4 +122,7 @@ class MxDSObject : public MxCore {
MxDSObject* DeserializeDSObjectDispatch(MxU8*&, MxS16);
MxDSObject* CreateStreamObject(MxDSFile*, MxS16);

// TEMPLATE: BETA10 0x10150950
// MxUtilityList<MxDSObject *>::PopFront

#endif // MXDSOBJECT_H
12 changes: 12 additions & 0 deletions LEGO1/omni/include/mxdssubscriber.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<MxDSSubscriber*> {
public:
MxDSSubscriber* Find(MxDSObject* p_object);
};

// VTABLE: LEGO1 0x100dc698
// VTABLE: BETA10 0x101c1d38
// SIZE 0x4c
Expand Down Expand Up @@ -58,4 +67,7 @@ class MxDSSubscriber : public MxCore {
// TEMPLATE: LEGO1 0x100b7d00
// MxStreamChunkList::~MxStreamChunkList

// TEMPLATE: BETA10 0x10150a70
// MxUtilityList<MxDSSubscriber *>::PopFront

#endif // MXDSSUBSCRIBER_H
4 changes: 2 additions & 2 deletions LEGO1/omni/include/mxstreamchunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "mxdschunk.h"

class MxDSBuffer;
class MxStreamListMxDSSubscriber;
class MxDSSubscriberList;

// VTABLE: LEGO1 0x100dc2a8
// VTABLE: BETA10 0x101c1d20
Expand Down Expand Up @@ -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);
Expand Down
41 changes: 25 additions & 16 deletions LEGO1/omni/include/mxstreamcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<MxNextActionDataStart*> {
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
Expand Down Expand Up @@ -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
Expand All @@ -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<MxDSSubscriber *>::~MxStreamList<MxDSSubscriber *>
Expand Down
69 changes: 0 additions & 69 deletions LEGO1/omni/include/mxstreamlist.h

This file was deleted.

23 changes: 23 additions & 0 deletions LEGO1/omni/include/mxutilitylist.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef MXUTILITYLIST_H
#define MXUTILITYLIST_H

#include "mxstl/mxstl.h"

// Probably should be defined somewhere else

template <class T>
class MxUtilityList : public list<T> {
public:
MxBool PopFront(T& p_obj)
{
if (this->empty()) {
return FALSE;
}

p_obj = this->front();
this->pop_front();
return TRUE;
}
};

#endif // MXUTILITYLIST_H
35 changes: 34 additions & 1 deletion LEGO1/omni/src/action/mxdsobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
#include <stdlib.h>
#include <string.h>

DECOMP_SIZE_ASSERT(MxDSObject, 0x2c);
DECOMP_SIZE_ASSERT(MxDSObject, 0x2c)
DECOMP_SIZE_ASSERT(MxDSObjectList, 0x0c)

// FUNCTION: LEGO1 0x100bf6a0
// FUNCTION: BETA10 0x101478c0
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion LEGO1/omni/src/main/mxomni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 49b03cb

Please sign in to comment.