From 0067c24ead519f0b739b0edad0e2ab0346e24ae2 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 1 Mar 2024 16:32:10 -0500 Subject: [PATCH] Implement/match ViewLODListManager::Create (#611) * Implement/match ViewLODListManager::Create * Add stdio.h header * Add remaining annotations --- LEGO1/lego/legoomni/include/legoomni.h | 2 +- LEGO1/realtime/lodlist.h | 18 ++++++-- LEGO1/viewmanager/viewlodlist.cpp | 31 +++++++++++--- LEGO1/viewmanager/viewlodlist.h | 58 +++++++++++++++++++------- 4 files changed, 85 insertions(+), 24 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoomni.h b/LEGO1/lego/legoomni/include/legoomni.h index 19324e42..e0b314f9 100644 --- a/LEGO1/lego/legoomni/include/legoomni.h +++ b/LEGO1/lego/legoomni/include/legoomni.h @@ -201,7 +201,7 @@ public: void DeleteWorld(LegoWorld* p_world); void FUN_1005b4f0(MxBool p_disable, MxU16 p_flags); void CreateBackgroundAudio(); - void RemoveWorld(const MxAtomId&, MxLong); + void RemoveWorld(const MxAtomId& p_atom, MxLong p_objectId); MxResult RegisterScripts(); MxS32 GetScriptIndex(const char* p_key); diff --git a/LEGO1/realtime/lodlist.h b/LEGO1/realtime/lodlist.h index 8e40d92a..544434b8 100644 --- a/LEGO1/realtime/lodlist.h +++ b/LEGO1/realtime/lodlist.h @@ -19,6 +19,8 @@ class LODObject; // geometric representation than the one preceeding it. // +// VTABLE: LEGO1 0x100dbdc8 +// SIZE 0x10 class LODListBase { protected: LODListBase(size_t capacity); @@ -36,6 +38,9 @@ public: // maximum number of LODObject* LODListBase can hold size_t Capacity() const; + // SYNTHETIC: LEGO1 0x100a77b0 + // LODListBase::`scalar deleting destructor' + #ifdef _DEBUG virtual void Dump(void (*pTracer)(const char*, ...)) const; #endif @@ -46,9 +51,9 @@ private: LODListBase& operator=(const LODListBase&); private: - const LODObject** m_ppLODObject; - size_t m_capacity; - size_t m_size; + const LODObject** m_ppLODObject; // 0x04 + size_t m_capacity; // 0x08 + size_t m_size; // 0x0c }; ////////////////////////////////////////////////////////////////////////////// @@ -56,6 +61,7 @@ private: // LODList // +// SIZE 0x10 template class LODList : public LODListBase { public: @@ -174,6 +180,12 @@ inline const T* LODList::PopBack() return static_cast(LODListBase::PopBack()); } +// VTABLE: LEGO1 0x100dbdc0 +// class LODList + +// SYNTHETIC: LEGO1 0x100a7740 +// LODList::`scalar deleting destructor' + // re-enable: identifier was truncated to '255' characters in the debug information #pragma warning(default : 4786) diff --git a/LEGO1/viewmanager/viewlodlist.cpp b/LEGO1/viewmanager/viewlodlist.cpp index 1cd0783e..6d6dfdb2 100644 --- a/LEGO1/viewmanager/viewlodlist.cpp +++ b/LEGO1/viewmanager/viewlodlist.cpp @@ -2,7 +2,15 @@ #include "decomp.h" -DECOMP_SIZE_ASSERT(ViewLODListManager, 0x14); +#include + +DECOMP_SIZE_ASSERT(ViewLODListManager, 0x14) +DECOMP_SIZE_ASSERT(LODListBase, 0x10) +DECOMP_SIZE_ASSERT(LODList, 0x10) +DECOMP_SIZE_ASSERT(ViewLODList, 0x18) + +// GLOBAL: LEGO1 0x10101064 +int g_unk0x10101064 = 0; // FUNCTION: LEGO1 0x100a6fd0 ViewLODListManager::ViewLODListManager() @@ -15,7 +23,7 @@ ViewLODListManager::~ViewLODListManager() // TODO } -// STUB: LEGO1 0x100a72c0 +// FUNCTION: LEGO1 0x100a72c0 ViewLODList* ViewLODListManager::Create(const ROIName& rROIName, int lodCount) { // returned ViewLODList has a refCount of 1, i.e. caller must call Release() @@ -27,12 +35,25 @@ ViewLODList* ViewLODListManager::Create(const ROIName& rROIName, int lodCount) assert(!Lookup(rROIName)); - pLODList = new ViewLODList(lodCount); + pLODList = new ViewLODList(lodCount, this); refCount = pLODList->AddRef(); assert(refCount == 1); - pROIName = new char[strlen(rROIName) + 1]; - strcpy(pROIName, rROIName); + ViewLODList* list = Lookup(rROIName); + if (list != NULL) { + list->Release(); + + char num[12]; + sprintf(num, "%d", g_unk0x10101064); + pROIName = new char[strlen(rROIName) + strlen(num) + 1]; + strcpy(pROIName, rROIName); + strcat(pROIName, num); + g_unk0x10101064++; + } + else { + pROIName = new char[strlen(rROIName) + 1]; + strcpy(pROIName, rROIName); + } m_map[pROIName] = pLODList; diff --git a/LEGO1/viewmanager/viewlodlist.h b/LEGO1/viewmanager/viewlodlist.h index d8516955..930dbb96 100644 --- a/LEGO1/viewmanager/viewlodlist.h +++ b/LEGO1/viewmanager/viewlodlist.h @@ -22,13 +22,18 @@ class ViewLODListManager; // ViewLODLists are managed (created and destroyed) by ViewLODListManager. // +// VTABLE: LEGO1 0x100dbdc4 +// SIZE 0x18 class ViewLODList : public LODList { friend ViewLODListManager; protected: - ViewLODList(size_t capacity); + ViewLODList(size_t capacity, ViewLODListManager* owner); ~ViewLODList() override; + // SYNTHETIC: LEGO1 0x100a80f0 + // ViewLODList::`scalar deleting destructor' + public: inline int AddRef(); inline int Release(); @@ -38,8 +43,8 @@ public: #endif private: - int m_refCount; - ViewLODListManager* m_owner; + int m_refCount; // 0x10 + ViewLODListManager* m_owner; // 0x14 }; ////////////////////////////////////////////////////////////////////////////// @@ -48,7 +53,7 @@ private: // ??? for now, until we have symbol management typedef const char* ROIName; struct ROINameComparator { - bool operator()(const ROIName& rName1, const ROIName& rName2) const + unsigned char operator()(const ROIName& rName1, const ROIName& rName2) const { return strcmp((const char*) rName1, (const char*) rName2) > 0; } @@ -96,28 +101,51 @@ private: ViewLODListMap m_map; }; +// clang-format off // FUNCTION: LEGO1 0x1001dde0 // _Lockit::~_Lockit -// clang-format off -// TEMPLATE: LEGO1 0x100a7890 -// _Tree,map >::_Kfn,ROINameComparator,allocator >::~_Tree,map >::~map > -// clang-format on - // TEMPLATE: LEGO1 0x100a70e0 // Map::~Map +// TEMPLATE: LEGO1 0x100a77e0 +// LODListBase::~LODListBase + +// TEMPLATE: LEGO1 0x100a7800 +// _Tree,map >::_Kfn,ROINameComparator,allocator >::iterator::_Dec + +// TEMPLATE: LEGO1 0x100a7850 +// _Tree,map >::_Kfn,ROINameComparator,allocator >::iterator::_Inc + +// TEMPLATE: LEGO1 0x100a7890 +// _Tree,map >::_Kfn,ROINameComparator,allocator >::~_Tree,map,map >::_Kfn,ROINameComparator,allocator >::erase + +// TEMPLATE: LEGO1 0x100a7db0 +// _Tree,map >::_Kfn,ROINameComparator,allocator >::_Erase + +// TEMPLATE: LEGO1 0x100a7df0 +// _Tree,map >::_Kfn,ROINameComparator,allocator >::_Insert + +// TEMPLATE: LEGO1 0x100a80a0 +// map >::~map > + +// TEMPLATE: LEGO1 0x100a8160 +// LODList::~LODList + +// GLOBAL: LEGO1 0x10101068 +// _Tree,map >::_Kfn,ROINameComparator,allocator >::_Nil +// clang-format on + ////////////////////////////////////////////////////////////////////////////// // // ViewLODList implementation -inline ViewLODList::ViewLODList(size_t capacity) : LODList(capacity), m_refCount(0) +inline ViewLODList::ViewLODList(size_t capacity, ViewLODListManager* owner) : LODList(capacity), m_refCount(0) { + m_owner = owner; } inline ViewLODList::~ViewLODList()