From 6fa4a0dbec5c2b071d5d30fb5568b0afc59cc9fd Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 9 Mar 2024 13:03:21 -0500 Subject: [PATCH] Implement/match LegoPartPresenter::Store (#643) --- LEGO1/lego/legoomni/include/legolodlist.h | 31 +++++++++++++++++ LEGO1/lego/legoomni/include/legonamedpart.h | 1 - .../lego/legoomni/include/legonamedpartlist.h | 31 +++++++++++++++++ .../lego/legoomni/include/legopartpresenter.h | 2 +- .../src/entity/legoworldpresenter.cpp | 4 +-- .../legoomni/src/video/legopartpresenter.cpp | 33 +++++++++++++++++-- 6 files changed, 95 insertions(+), 7 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legolodlist.h b/LEGO1/lego/legoomni/include/legolodlist.h index b9e52096..af538ccc 100644 --- a/LEGO1/lego/legoomni/include/legolodlist.h +++ b/LEGO1/lego/legoomni/include/legolodlist.h @@ -25,6 +25,37 @@ class LegoLODList : public MxPtrList { // LegoLODList::`scalar deleting destructor' }; +// VTABLE: LEGO1 0x100d9df0 +// class MxListCursor + +// VTABLE: LEGO1 0x100d9e08 +// class MxPtrListCursor + +// VTABLE: LEGO1 0x100d9e20 +// SIZE 0x10 +class LegoLODListCursor : public MxPtrListCursor { +public: + LegoLODListCursor(LegoLODList* p_list) : MxPtrListCursor(p_list) {} +}; + +// SYNTHETIC: LEGO1 0x1007d9b0 +// LegoLODListCursor::`scalar deleting destructor' + +// FUNCTION: LEGO1 0x1007da20 +// MxPtrListCursor::~MxPtrListCursor + +// SYNTHETIC: LEGO1 0x1007da70 +// MxListCursor::`scalar deleting destructor' + +// SYNTHETIC: LEGO1 0x1007dae0 +// MxPtrListCursor::`scalar deleting destructor' + +// FUNCTION: LEGO1 0x1007db50 +// MxListCursor::~MxListCursor + +// FUNCTION: LEGO1 0x1007dba0 +// LegoLODListCursor::~LegoLODListCursor + // TEMPLATE: LEGO1 0x1007d480 // MxCollection::Compare diff --git a/LEGO1/lego/legoomni/include/legonamedpart.h b/LEGO1/lego/legoomni/include/legonamedpart.h index 876090e2..dcdee2f9 100644 --- a/LEGO1/lego/legoomni/include/legonamedpart.h +++ b/LEGO1/lego/legoomni/include/legonamedpart.h @@ -15,7 +15,6 @@ class LegoNamedPart { ~LegoNamedPart() { delete m_list; } const MxString* GetName() const { return &m_name; } - LegoLODList* GetList() { return m_list; } private: diff --git a/LEGO1/lego/legoomni/include/legonamedpartlist.h b/LEGO1/lego/legoomni/include/legonamedpartlist.h index ddab4f67..5026c53a 100644 --- a/LEGO1/lego/legoomni/include/legonamedpartlist.h +++ b/LEGO1/lego/legoomni/include/legonamedpartlist.h @@ -23,6 +23,37 @@ class LegoNamedPartList : public MxPtrList { // LegoNamedPartList::`scalar deleting destructor' }; +// VTABLE: LEGO1 0x100d9e68 +// class MxListCursor + +// VTABLE: LEGO1 0x100d9e38 +// class MxPtrListCursor + +// VTABLE: LEGO1 0x100d9e50 +// SIZE 0x10 +class LegoNamedPartListCursor : public MxPtrListCursor { +public: + LegoNamedPartListCursor(LegoNamedPartList* p_list) : MxPtrListCursor(p_list) {} +}; + +// SYNTHETIC: LEGO1 0x1007e170 +// LegoNamedPartListCursor::`scalar deleting destructor' + +// FUNCTION: LEGO1 0x1007e1e0 +// MxPtrListCursor::~MxPtrListCursor + +// SYNTHETIC: LEGO1 0x1007e230 +// MxListCursor::`scalar deleting destructor' + +// SYNTHETIC: LEGO1 0x1007e2a0 +// MxPtrListCursor::`scalar deleting destructor' + +// FUNCTION: LEGO1 0x1007e310 +// MxListCursor::~MxListCursor + +// FUNCTION: LEGO1 0x1007e360 +// LegoNamedPartListCursor::~LegoNamedPartListCursor + // TEMPLATE: LEGO1 0x1007d760 // MxCollection::Compare diff --git a/LEGO1/lego/legoomni/include/legopartpresenter.h b/LEGO1/lego/legoomni/include/legopartpresenter.h index ac1fcc5e..875c39a7 100644 --- a/LEGO1/lego/legoomni/include/legopartpresenter.h +++ b/LEGO1/lego/legoomni/include/legopartpresenter.h @@ -38,7 +38,7 @@ class LegoPartPresenter : public MxMediaPresenter { inline void Reset() { m_parts = NULL; } MxResult Read(MxDSChunk& p_chunk); - void FUN_1007df20(); + void Store(); private: void Destroy(MxBool p_fromDestructor); diff --git a/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp b/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp index 84b7bb2a..e3555d7a 100644 --- a/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp @@ -246,7 +246,7 @@ MxResult LegoWorldPresenter::LoadWorld(char* p_worldName, LegoWorld* p_world) LegoPartPresenter partPresenter; if (partPresenter.Read(chunk) == SUCCESS) { - partPresenter.FUN_1007df20(); + partPresenter.Store(); } delete[] buff; @@ -335,7 +335,7 @@ MxResult LegoWorldPresenter::FUN_10067360(ModelDbPart& p_part, FILE* p_wdbFile) result = partPresenter.Read(chunk); if (result == SUCCESS) { - partPresenter.FUN_1007df20(); + partPresenter.Store(); } delete[] buff; diff --git a/LEGO1/lego/legoomni/src/video/legopartpresenter.cpp b/LEGO1/lego/legoomni/src/video/legopartpresenter.cpp index a41c4164..76f7306a 100644 --- a/LEGO1/lego/legoomni/src/video/legopartpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legopartpresenter.cpp @@ -5,6 +5,7 @@ #include "misc/legocontainer.h" #include "misc/legostorage.h" #include "misc/legotexture.h" +#include "viewmanager/viewlodlist.h" DECOMP_SIZE_ASSERT(LegoLODList, 0x18) DECOMP_SIZE_ASSERT(LegoNamedPart, 0x14) @@ -216,8 +217,34 @@ void LegoPartPresenter::ReadyTickle() // TODO } -// STUB: LEGO1 0x1007df20 -void LegoPartPresenter::FUN_1007df20() +// FUNCTION: LEGO1 0x1007df20 +void LegoPartPresenter::Store() { - // TODO + LegoNamedPartListCursor partCursor(m_parts); + LegoNamedPart* part; + + while (partCursor.Next(part)) { + ViewLODList* lodList = GetViewLODListManager()->Lookup(part->GetName()->GetData()); + + if (lodList == NULL) { + lodList = GetViewLODListManager()->Create(part->GetName()->GetData(), part->GetList()->GetCount()); + + LegoLODListCursor lodCursor(part->GetList()); + LegoLOD* lod; + + while (lodCursor.First(lod)) { + lodCursor.Detach(); + lodList->PushBack(lod); + } + } + else { + lodList->Release(); + } + } + + if (m_parts != NULL) { + delete m_parts; + } + + m_parts = NULL; }