diff --git a/LEGO1/realtime/lodlist.h b/LEGO1/realtime/lodlist.h index 544434b8..66854887 100644 --- a/LEGO1/realtime/lodlist.h +++ b/LEGO1/realtime/lodlist.h @@ -20,6 +20,7 @@ class LODObject; // // VTABLE: LEGO1 0x100dbdc8 +// VTABLE: BETA10 0x101c3500 // SIZE 0x10 class LODListBase { protected: @@ -39,6 +40,7 @@ class LODListBase { size_t Capacity() const; // SYNTHETIC: LEGO1 0x100a77b0 + // SYNTHETIC: BETA10 0x1017b410 // LODListBase::`scalar deleting destructor' #ifdef _DEBUG @@ -76,6 +78,7 @@ class LODList : public LODListBase { // // LODListBase implementation +// FUNCTION: BETA10 0x1017b390 inline LODListBase::LODListBase(size_t capacity) : m_capacity(capacity), m_size(0), m_ppLODObject(new const LODObject*[capacity]) { @@ -88,6 +91,8 @@ inline LODListBase::LODListBase(size_t capacity) #endif } +// FUNCTION: LEGO1 0x100a77e0 +// FUNCTION: BETA10 0x1017b450 inline LODListBase::~LODListBase() { // all LODObject* should have been popped by client @@ -96,16 +101,19 @@ inline LODListBase::~LODListBase() delete[] m_ppLODObject; } +// FUNCTION: BETA10 0x1005c480 inline size_t LODListBase::Size() const { return m_size; } +// FUNCTION: BETA10 0x10178b40 inline size_t LODListBase::Capacity() const { return m_capacity; } +// FUNCTION: BETA10 0x1007b6a0 inline const LODObject* LODListBase::operator[](int i) const { assert((0 <= i) && (i < (int) m_size)); @@ -113,6 +121,7 @@ inline const LODObject* LODListBase::operator[](int i) const return m_ppLODObject[i]; } +// FUNCTION: BETA10 0x1007bb40 inline const LODObject* LODListBase::PushBack(const LODObject* pLOD) { assert(m_size < m_capacity); @@ -121,6 +130,7 @@ inline const LODObject* LODListBase::PushBack(const LODObject* pLOD) return pLOD; } +// FUNCTION: BETA10 0x10178b60 inline const LODObject* LODListBase::PopBack() { const LODObject* pLOD; @@ -137,6 +147,7 @@ inline const LODObject* LODListBase::PopBack() } #ifdef _DEBUG +// FUNCTION: BETA10 0x1017b4c0 inline void LODListBase::Dump(void (*pTracer)(const char*, ...)) const { int i; @@ -181,11 +192,26 @@ inline const T* LODList::PopBack() } // VTABLE: LEGO1 0x100dbdc0 +// VTABLE: BETA10 0x101c34f8 // class LODList // SYNTHETIC: LEGO1 0x100a7740 +// SYNTHETIC: BETA10 0x1017b350 // LODList::`scalar deleting destructor' +// TEMPLATE: BETA10 0x10178b20 +// LODList::PopBack + +// TEMPLATE: BETA10 0x1017b2d0 +// LODList::LODList + +// TEMPLATE: LEGO1 0x100a8160 +// TEMPLATE: BETA10 0x1017b5d0 +// LODList::~LODList + +// TEMPLATE: BETA10 0x1007bae0 +// LODList::operator[] + // 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 920444e9..ca57bc01 100644 --- a/LEGO1/viewmanager/viewlodlist.cpp +++ b/LEGO1/viewmanager/viewlodlist.cpp @@ -11,14 +11,31 @@ DECOMP_SIZE_ASSERT(LODList, 0x10) DECOMP_SIZE_ASSERT(ViewLODList, 0x18) // GLOBAL: LEGO1 0x10101064 -int g_unk0x10101064 = 0; +// GLOBAL: BETA10 0x10205d08 +int ViewLODListManager::g_ROINameUID = 0; + +#ifdef _DEBUG +// FUNCTION: BETA10 0x10178310 +inline void ViewLODList::Dump(void (*pTracer)(const char*, ...)) const +{ + pTracer(" ViewLODList<0x%x>: Capacity=%d, Size=%d, RefCount=%d\n", this, Capacity(), Size(), m_refCount); + + for (int i = 0; i < (int) Size(); i++) { + ViewLOD* lod = const_cast(this->operator[](i)); + pTracer(" [%d]: ViewLOD<0x%x>: Vertices=%d\n", i, lod, lod->NVerts()); + } +} +#endif // FUNCTION: LEGO1 0x100a6fd0 +// FUNCTION: BETA10 0x101783a3 ViewLODListManager::ViewLODListManager() { } // FUNCTION: LEGO1 0x100a7130 +// FUNCTION: BETA10 0x1017841c +// FUNCTION: ALPHA 0x100e3402 ViewLODListManager::~ViewLODListManager() { ViewLODListMap::iterator iterator; @@ -28,9 +45,6 @@ ViewLODListManager::~ViewLODListManager() const ROIName& rROIName = (*iterator).first; ViewLODList* pLODList = (*iterator).second; - // LODList's refCount should be 0 - assert(pLODList->m_refCount == 0); - // ???who pops and deletes LODObjects while (pLODList->Size() > 0) { delete const_cast(pLODList->PopBack()); @@ -48,6 +62,8 @@ ViewLODListManager::~ViewLODListManager() } // FUNCTION: LEGO1 0x100a72c0 +// FUNCTION: BETA10 0x101785ef +// FUNCTION: ALPHA 0x100e35d2 ViewLODList* ViewLODListManager::Create(const ROIName& rROIName, int lodCount) { // returned ViewLODList has a refCount of 1, i.e. caller must call Release() @@ -57,7 +73,7 @@ ViewLODList* ViewLODListManager::Create(const ROIName& rROIName, int lodCount) int refCount; char* pROIName; - assert(!Lookup(rROIName)); + // assert(!Lookup(rROIName)); // alpha only pLODList = new ViewLODList(lodCount, this); refCount = pLODList->AddRef(); @@ -68,11 +84,11 @@ ViewLODList* ViewLODListManager::Create(const ROIName& rROIName, int lodCount) list->Release(); char num[12]; - sprintf(num, "%d", g_unk0x10101064); + sprintf(num, "%d", g_ROINameUID); pROIName = new char[strlen(rROIName) + strlen(num) + 1]; strcpy(pROIName, rROIName); strcat(pROIName, num); - g_unk0x10101064++; + g_ROINameUID++; } else { pROIName = new char[strlen(rROIName) + 1]; @@ -82,12 +98,13 @@ ViewLODList* ViewLODListManager::Create(const ROIName& rROIName, int lodCount) m_map[pROIName] = pLODList; // NOTE: Lookup() adds a refCount - assert((Lookup(rROIName) == pLODList) && (pLODList->Release() == 1)); + assert((Lookup(pROIName) == pLODList) && (pLODList->Release() == 1)); return pLODList; } // FUNCTION: LEGO1 0x100a75b0 +// FUNCTION: BETA10 0x101787d8 ViewLODList* ViewLODListManager::Lookup(const ROIName& p_roiName) const { // returned ViewLODList's refCount is increased, i.e. caller must call Release() @@ -106,7 +123,30 @@ ViewLODList* ViewLODListManager::Lookup(const ROIName& p_roiName) const return pLODList; } -// STUB: LEGO1 0x100a7680 -void ViewLODListManager::Destroy(ViewLODList* lodList) +// FUNCTION: LEGO1 0x100a7680 +// FUNCTION: BETA10 0x1017886b +unsigned char ViewLODListManager::Destroy(ViewLODList* lodList) { + ViewLODListMap::iterator iterator; + char deleted = FALSE; + + for (iterator = m_map.begin(); !(iterator == m_map.end()); ++iterator) { + const ROIName& rROIName = (*iterator).first; + ViewLODList* pLODList = (*iterator).second; + + if (lodList == pLODList) { + while (pLODList->Size() > 0) { + delete const_cast(pLODList->PopBack()); + } + + delete pLODList; + delete[] const_cast(rROIName); + m_map.erase(iterator); + + deleted = TRUE; + break; + } + } + + return deleted; } diff --git a/LEGO1/viewmanager/viewlodlist.h b/LEGO1/viewmanager/viewlodlist.h index 930dbb96..187d6feb 100644 --- a/LEGO1/viewmanager/viewlodlist.h +++ b/LEGO1/viewmanager/viewlodlist.h @@ -23,6 +23,7 @@ class ViewLODListManager; // // VTABLE: LEGO1 0x100dbdc4 +// VTABLE: BETA10 0x101c34f0 // SIZE 0x18 class ViewLODList : public LODList { friend ViewLODListManager; @@ -32,6 +33,7 @@ class ViewLODList : public LODList { ~ViewLODList() override; // SYNTHETIC: LEGO1 0x100a80f0 + // SYNTHETIC: BETA10 0x1017b590 // ViewLODList::`scalar deleting destructor' public: @@ -53,6 +55,7 @@ class ViewLODList : public LODList { // ??? for now, until we have symbol management typedef const char* ROIName; struct ROINameComparator { + // FUNCTION: BETA10 0x101794c0 unsigned char operator()(const ROIName& rName1, const ROIName& rName2) const { return strcmp((const char*) rName1, (const char*) rName2) > 0; @@ -68,6 +71,7 @@ struct ROINameComparator { // the ViewLODList belongs. // VTABLE: LEGO1 0x100dbdbc +// VTABLE: BETA10 0x101c34ec // SIZE 0x14 class ViewLODListManager { @@ -88,29 +92,31 @@ class ViewLODListManager { // returned LODList's refCount is increased, i.e. caller must call Release() // when it no longer holds on to the list ViewLODList* Lookup(const ROIName&) const; - void Destroy(ViewLODList* lodList); + unsigned char Destroy(ViewLODList* lodList); #ifdef _DEBUG void Dump(void (*pTracer)(const char*, ...)) const; #endif // SYNTHETIC: LEGO1 0x100a70c0 + // SYNTHETIC: BETA10 0x10178a80 // ViewLODListManager::`scalar deleting destructor' private: + static int g_ROINameUID; + ViewLODListMap m_map; }; // clang-format off // FUNCTION: LEGO1 0x1001dde0 +// FUNCTION: BETA10 0x100223c0 // _Lockit::~_Lockit // TEMPLATE: LEGO1 0x100a70e0 +// TEMPLATE: BETA10 0x10178ac0 // Map::~Map -// TEMPLATE: LEGO1 0x100a77e0 -// LODListBase::~LODListBase - // TEMPLATE: LEGO1 0x100a7800 // _Tree,map >::_Kfn,ROINameComparator,allocator >::iterator::_Dec @@ -121,28 +127,76 @@ class ViewLODListManager { // _Tree,map >::_Kfn,ROINameComparator,allocator >::~_Tree,map,map >::_Kfn,ROINameComparator,allocator >::erase // TEMPLATE: LEGO1 0x100a7db0 +// TEMPLATE: BETA10 0x1017aca0 // _Tree,map >::_Kfn,ROINameComparator,allocator >::_Erase // TEMPLATE: LEGO1 0x100a7df0 +// TEMPLATE: BETA10 0x101796b0 // _Tree,map >::_Kfn,ROINameComparator,allocator >::_Insert // TEMPLATE: LEGO1 0x100a80a0 +// TEMPLATE: BETA10 0x1017b1e0 // map >::~map > -// TEMPLATE: LEGO1 0x100a8160 -// LODList::~LODList - // GLOBAL: LEGO1 0x10101068 +// GLOBAL: BETA10 0x10205eb4 // _Tree,map >::_Kfn,ROINameComparator,allocator >::_Nil + +// TEMPLATE: BETA10 0x101791f0 +// map >::operator[] + +// TEMPLATE: BETA10 0x10178c80 +// _Tree,map >::_Kfn,ROINameComparator,allocator >::iterator::operator== + +// TEMPLATE: BETA10 0x10178ef0 +// map >::begin + +// TEMPLATE: BETA10 0x10179070 +// map >::end + +// TEMPLATE: BETA10 0x10179250 +// pair::pair + +// TEMPLATE: BETA10 0x10179280 +// map >::insert + +// TEMPLATE: BETA10 0x101792c0 +// _Tree,map >::_Kfn,ROINameComparator,allocator >::insert + +// TEMPLATE: BETA10 0x10178c00 +// _Tree,map >::_Kfn,ROINameComparator,allocator >::iterator::operator* + +// TEMPLATE: BETA10 0x1017ab10 +// map >::erase +// Two iterators + +// TEMPLATE: BETA10 0x1017a040 +// map >::erase +// One iterator + +// TEMPLATE: BETA10 0x10178f80 +// _Tree,map >::_Kfn,ROINameComparator,allocator >::_Lmost + +// TEMPLATE: BETA10 0x10179e70 +// _Tree,map >::_Kfn,ROINameComparator,allocator >::_Rmost + +// TEMPLATE: BETA10 0x10179670 +// _Tree,map >::_Kfn,ROINameComparator,allocator >::_Color + +// TEMPLATE: BETA10 0x1017aa30 +// ?swap@@YAXAAW4_Redbl@?$_Tree@PBDU?$pair@QBDPAVViewLODList@@@@U_Kfn@?$map@PBDPAVViewLODList@@UROINameComparator@@V?$allocator@PAVViewLODList@@@@@@UROINameComparator@@V?$allocator@PAVViewLODList@@@@@@0@Z + // clang-format on ////////////////////////////////////////////////////////////////////////////// // // ViewLODList implementation +// FUNCTION: BETA10 0x1017b240 inline ViewLODList::ViewLODList(size_t capacity, ViewLODListManager* owner) : LODList(capacity), m_refCount(0) { m_owner = owner; @@ -153,25 +207,22 @@ inline ViewLODList::~ViewLODList() assert(m_refCount == 0); } +// FUNCTION: BETA10 0x1007b5b0 inline int ViewLODList::AddRef() { return ++m_refCount; } +// FUNCTION: BETA10 0x1007ad70 inline int ViewLODList::Release() { assert(m_refCount > 0); if (!--m_refCount) { m_owner->Destroy(this); + return 0; } + return m_refCount; } -#ifdef _DEBUG -inline void ViewLODList::Dump(void (*pTracer)(const char*, ...)) const -{ - // FIXME: dump something -} -#endif - #endif // VIEWLODLIST_H