Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor MxStreamList based lists #1260

Merged
merged 8 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +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
LEGO1/omni/src/system/mxscheduler.cpp
Expand Down
10 changes: 5 additions & 5 deletions LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,24 +404,24 @@ LegoROI* LegoAnimPresenter::FUN_100699e0(const LegoChar* p_und)
// FUNCTION: LEGO1 0x10069b10
void LegoAnimPresenter::FUN_10069b10()
{
LegoAnimStructMap map;
LegoAnimStructMap anims;

if (m_unk0x8c != NULL) {
memset(m_unk0x8c, 0, m_unk0x94 * sizeof(*m_unk0x8c));
}

FUN_1006a3c0(map, m_anim->GetRoot(), NULL);
FUN_1006a3c0(anims, m_anim->GetRoot(), NULL);

if (m_roiMap != NULL) {
delete[] m_roiMap;
m_roiMapSize = 0;
}

m_roiMapSize = 0;
m_roiMap = new LegoROI*[map.size() + 1];
memset(m_roiMap, 0, (map.size() + 1) * sizeof(*m_roiMap));
m_roiMap = new LegoROI*[anims.size() + 1];
memset(m_roiMap, 0, (anims.size() + 1) * sizeof(*m_roiMap));

for (LegoAnimStructMap::iterator it = map.begin(); it != map.end();) {
for (LegoAnimStructMap::iterator it = anims.begin(); it != anims.end();) {
MxU32 index = (*it).second.m_index;
m_roiMap[index] = (*it).second.m_roi;

Expand Down
8 changes: 4 additions & 4 deletions LEGO1/lego/legoomni/src/video/legohideanimpresenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,18 @@ void LegoHideAnimPresenter::FUN_1006db60(LegoTreeNode* p_node, LegoTime p_time)
// FUNCTION: BETA10 0x100532fd
void LegoHideAnimPresenter::FUN_1006dc10()
{
LegoHideAnimStructMap map;
LegoHideAnimStructMap anims;

FUN_1006e3f0(map, m_anim->GetRoot());
FUN_1006e3f0(anims, m_anim->GetRoot());

if (m_boundaryMap != NULL) {
delete[] m_boundaryMap;
}

m_boundaryMap = new LegoPathBoundary*[map.size() + 1];
m_boundaryMap = new LegoPathBoundary*[anims.size() + 1];
m_boundaryMap[0] = NULL;

for (LegoHideAnimStructMap::iterator it = map.begin(); !(it == map.end()); it++) {
for (LegoHideAnimStructMap::iterator it = anims.begin(); !(it == anims.end()); it++) {
m_boundaryMap[(*it).second.m_index] = (*it).second.m_boundary;
delete[] const_cast<char*>((*it).first);
}
Expand Down
8 changes: 4 additions & 4 deletions LEGO1/lego/legoomni/src/worlds/registrationbook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,12 +576,12 @@ MxLong RegistrationBook::HandlePathStruct(LegoPathStructNotificationParam& p_par
// FUNCTION: LEGO1 0x10078350
MxBool RegistrationBook::CreateSurface()
{
MxCompositePresenterList* list = m_checkmark[0]->GetList();
MxCompositePresenterList* presenters = m_checkmark[0]->GetList();
MxStillPresenter *presenter, *uninitialized;

if (list) {
if (list->begin() != list->end()) {
presenter = (MxStillPresenter*) list->front();
if (presenters) {
if (presenters->begin() != presenters->end()) {
presenter = (MxStillPresenter*) presenters->front();
}
else {
presenter = uninitialized; // intentionally uninitialized variable
Expand Down
22 changes: 11 additions & 11 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 All @@ -74,10 +74,10 @@ class MxDiskStreamController : public MxStreamController {
};

// TEMPLATE: LEGO1 0x100c14d0
// list<MxDSAction *,allocator<MxDSAction *> >::erase
// list<MxDSObject *,allocator<MxDSObject *> >::erase

// TEMPLATE: LEGO1 0x100c7330
// list<MxDSAction *,allocator<MxDSAction *> >::_Buynode
// list<MxDSObject *,allocator<MxDSObject *> >::_Buynode

// TEMPLATE: LEGO1 0x100c7420
// list<MxDSBuffer *,allocator<MxDSBuffer *> >::~list<MxDSBuffer *,allocator<MxDSBuffer *> >
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
73 changes: 45 additions & 28 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 All @@ -34,12 +43,20 @@ class MxStreamController : public MxCore {
return !strcmp(p_name, MxStreamController::ClassName()) || MxCore::IsA(p_name);
}

virtual MxResult Open(const char* p_filename); // vtable+0x14
virtual MxResult VTable0x18(undefined4, undefined4); // vtable+0x18
virtual MxResult VTable0x1c(undefined4, undefined4); // vtable+0x1c
virtual MxResult VTable0x20(MxDSAction* p_action); // vtable+0x20
virtual MxResult VTable0x24(MxDSAction* p_action); // vtable+0x24
virtual MxDSStreamingAction* VTable0x28(); // vtable+0x28
virtual MxResult Open(const char* p_filename); // vtable+0x14

// FUNCTION: LEGO1 0x100b9400
virtual MxResult VTable0x18(undefined4, undefined4) { return FAILURE; } // vtable+0x18

// FUNCTION: LEGO1 0x100b9410
virtual MxResult VTable0x1c(undefined4, undefined4) { return FAILURE; } // vtable+0x1c

virtual MxResult VTable0x20(MxDSAction* p_action); // vtable+0x20
virtual MxResult VTable0x24(MxDSAction* p_action); // vtable+0x24

// FUNCTION: LEGO1 0x100b9420
virtual MxDSStreamingAction* VTable0x28() { return NULL; } // vtable+0x28

virtual MxResult VTable0x2c(MxDSAction* p_action, MxU32 p_bufferval); // vtable+0x2c
virtual MxResult VTable0x30(MxDSAction* p_action); // vtable+0x30

Expand All @@ -55,24 +72,24 @@ 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
// list<MxDSAction *,allocator<MxDSAction *> >::~list<MxDSAction *,allocator<MxDSAction *> >
// list<MxDSObject *,allocator<MxDSObject *> >::~list<MxDSObject *,allocator<MxDSObject *> >

// TEMPLATE: LEGO1 0x100c0dd0
// list<MxDSSubscriber *,allocator<MxDSSubscriber *> >::~list<MxDSSubscriber *,allocator<MxDSSubscriber *> >
Expand All @@ -92,33 +109,33 @@ 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 *>
// MxUtilityList<MxDSSubscriber *>::~MxUtilityList<MxDSSubscriber *>

// TEMPLATE: LEGO1 0x100c1100
// MxStreamList<MxDSAction *>::~MxStreamList<MxDSAction *>
// MxUtilityList<MxDSObject *>::~MxUtilityList<MxDSObject *>

// TEMPLATE: LEGO1 0x100c1150
// MxStreamList<MxNextActionDataStart *>::~MxStreamList<MxNextActionDataStart *>
// MxUtilityList<MxNextActionDataStart *>::~MxUtilityList<MxNextActionDataStart *>

// TEMPLATE: LEGO1 0x100c11a0
// List<MxDSSubscriber *>::~List<MxDSSubscriber *>

// TEMPLATE: LEGO1 0x100c11f0
// List<MxDSAction *>::~List<MxDSAction *>
// List<MxDSObject *>::~List<MxDSObject *>

// TEMPLATE: LEGO1 0x100c1240
// List<MxNextActionDataStart *>::~List<MxNextActionDataStart *>

// TEMPLATE: LEGO1 0x100c1bc0
// list<MxDSAction *,allocator<MxDSAction *> >::insert
// list<MxDSObject *,allocator<MxDSObject *> >::insert

#endif // MXSTREAMCONTROLLER_H
Loading
Loading