Implement/match ViewLODListManager::Create (#611)

* Implement/match ViewLODListManager::Create

* Add stdio.h header

* Add remaining annotations
This commit is contained in:
Christian Semmler 2024-03-01 16:32:10 -05:00 committed by GitHub
parent fb6eed9bff
commit 0067c24ead
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 85 additions and 24 deletions

View file

@ -201,7 +201,7 @@ class LegoOmni : public MxOmni {
void DeleteWorld(LegoWorld* p_world); void DeleteWorld(LegoWorld* p_world);
void FUN_1005b4f0(MxBool p_disable, MxU16 p_flags); void FUN_1005b4f0(MxBool p_disable, MxU16 p_flags);
void CreateBackgroundAudio(); void CreateBackgroundAudio();
void RemoveWorld(const MxAtomId&, MxLong); void RemoveWorld(const MxAtomId& p_atom, MxLong p_objectId);
MxResult RegisterScripts(); MxResult RegisterScripts();
MxS32 GetScriptIndex(const char* p_key); MxS32 GetScriptIndex(const char* p_key);

View file

@ -19,6 +19,8 @@ class LODObject;
// geometric representation than the one preceeding it. // geometric representation than the one preceeding it.
// //
// VTABLE: LEGO1 0x100dbdc8
// SIZE 0x10
class LODListBase { class LODListBase {
protected: protected:
LODListBase(size_t capacity); LODListBase(size_t capacity);
@ -36,6 +38,9 @@ class LODListBase {
// maximum number of LODObject* LODListBase can hold // maximum number of LODObject* LODListBase can hold
size_t Capacity() const; size_t Capacity() const;
// SYNTHETIC: LEGO1 0x100a77b0
// LODListBase::`scalar deleting destructor'
#ifdef _DEBUG #ifdef _DEBUG
virtual void Dump(void (*pTracer)(const char*, ...)) const; virtual void Dump(void (*pTracer)(const char*, ...)) const;
#endif #endif
@ -46,9 +51,9 @@ class LODListBase {
LODListBase& operator=(const LODListBase&); LODListBase& operator=(const LODListBase&);
private: private:
const LODObject** m_ppLODObject; const LODObject** m_ppLODObject; // 0x04
size_t m_capacity; size_t m_capacity; // 0x08
size_t m_size; size_t m_size; // 0x0c
}; };
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
@ -56,6 +61,7 @@ class LODListBase {
// LODList // LODList
// //
// SIZE 0x10
template <class T> template <class T>
class LODList : public LODListBase { class LODList : public LODListBase {
public: public:
@ -174,6 +180,12 @@ inline const T* LODList<T>::PopBack()
return static_cast<const T*>(LODListBase::PopBack()); return static_cast<const T*>(LODListBase::PopBack());
} }
// VTABLE: LEGO1 0x100dbdc0
// class LODList<ViewLOD>
// SYNTHETIC: LEGO1 0x100a7740
// LODList<ViewLOD>::`scalar deleting destructor'
// re-enable: identifier was truncated to '255' characters in the debug information // re-enable: identifier was truncated to '255' characters in the debug information
#pragma warning(default : 4786) #pragma warning(default : 4786)

View file

@ -2,7 +2,15 @@
#include "decomp.h" #include "decomp.h"
DECOMP_SIZE_ASSERT(ViewLODListManager, 0x14); #include <stdio.h>
DECOMP_SIZE_ASSERT(ViewLODListManager, 0x14)
DECOMP_SIZE_ASSERT(LODListBase, 0x10)
DECOMP_SIZE_ASSERT(LODList<ViewLOD>, 0x10)
DECOMP_SIZE_ASSERT(ViewLODList, 0x18)
// GLOBAL: LEGO1 0x10101064
int g_unk0x10101064 = 0;
// FUNCTION: LEGO1 0x100a6fd0 // FUNCTION: LEGO1 0x100a6fd0
ViewLODListManager::ViewLODListManager() ViewLODListManager::ViewLODListManager()
@ -15,7 +23,7 @@ ViewLODListManager::~ViewLODListManager()
// TODO // TODO
} }
// STUB: LEGO1 0x100a72c0 // FUNCTION: LEGO1 0x100a72c0
ViewLODList* ViewLODListManager::Create(const ROIName& rROIName, int lodCount) ViewLODList* ViewLODListManager::Create(const ROIName& rROIName, int lodCount)
{ {
// returned ViewLODList has a refCount of 1, i.e. caller must call Release() // 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)); assert(!Lookup(rROIName));
pLODList = new ViewLODList(lodCount); pLODList = new ViewLODList(lodCount, this);
refCount = pLODList->AddRef(); refCount = pLODList->AddRef();
assert(refCount == 1); assert(refCount == 1);
pROIName = new char[strlen(rROIName) + 1]; ViewLODList* list = Lookup(rROIName);
strcpy(pROIName, 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; m_map[pROIName] = pLODList;

View file

@ -22,13 +22,18 @@ class ViewLODListManager;
// ViewLODLists are managed (created and destroyed) by ViewLODListManager. // ViewLODLists are managed (created and destroyed) by ViewLODListManager.
// //
// VTABLE: LEGO1 0x100dbdc4
// SIZE 0x18
class ViewLODList : public LODList<ViewLOD> { class ViewLODList : public LODList<ViewLOD> {
friend ViewLODListManager; friend ViewLODListManager;
protected: protected:
ViewLODList(size_t capacity); ViewLODList(size_t capacity, ViewLODListManager* owner);
~ViewLODList() override; ~ViewLODList() override;
// SYNTHETIC: LEGO1 0x100a80f0
// ViewLODList::`scalar deleting destructor'
public: public:
inline int AddRef(); inline int AddRef();
inline int Release(); inline int Release();
@ -38,8 +43,8 @@ class ViewLODList : public LODList<ViewLOD> {
#endif #endif
private: private:
int m_refCount; int m_refCount; // 0x10
ViewLODListManager* m_owner; ViewLODListManager* m_owner; // 0x14
}; };
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
@ -48,7 +53,7 @@ class ViewLODList : public LODList<ViewLOD> {
// ??? for now, until we have symbol management // ??? for now, until we have symbol management
typedef const char* ROIName; typedef const char* ROIName;
struct ROINameComparator { 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; return strcmp((const char*) rName1, (const char*) rName2) > 0;
} }
@ -96,28 +101,51 @@ class ViewLODListManager {
ViewLODListMap m_map; ViewLODListMap m_map;
}; };
// clang-format off
// FUNCTION: LEGO1 0x1001dde0 // FUNCTION: LEGO1 0x1001dde0
// _Lockit::~_Lockit // _Lockit::~_Lockit
// clang-format off
// TEMPLATE: LEGO1 0x100a7890
// _Tree<char const *,pair<char const * const,ViewLODList *>,map<char const *,ViewLODList *,ROINameComparator,allocator<ViewLODList *> >::_Kfn,ROINameComparator,allocator<ViewLODList *> >::~_Tree<char const *,pair<char const * const,ViewLODList *>,map<char c
// clang-format on
// clang-format off
// TEMPLATE: LEGO1 0x100a80a0
// map<char const *,ViewLODList *,ROINameComparator,allocator<ViewLODList *> >::~map<char const *,ViewLODList *,ROINameComparator,allocator<ViewLODList *> >
// clang-format on
// TEMPLATE: LEGO1 0x100a70e0 // TEMPLATE: LEGO1 0x100a70e0
// Map<char const *,ViewLODList *,ROINameComparator>::~Map<char const *,ViewLODList *,ROINameComparator> // Map<char const *,ViewLODList *,ROINameComparator>::~Map<char const *,ViewLODList *,ROINameComparator>
// TEMPLATE: LEGO1 0x100a77e0
// LODListBase::~LODListBase
// TEMPLATE: LEGO1 0x100a7800
// _Tree<char const *,pair<char const * const,ViewLODList *>,map<char const *,ViewLODList *,ROINameComparator,allocator<ViewLODList *> >::_Kfn,ROINameComparator,allocator<ViewLODList *> >::iterator::_Dec
// TEMPLATE: LEGO1 0x100a7850
// _Tree<char const *,pair<char const * const,ViewLODList *>,map<char const *,ViewLODList *,ROINameComparator,allocator<ViewLODList *> >::_Kfn,ROINameComparator,allocator<ViewLODList *> >::iterator::_Inc
// TEMPLATE: LEGO1 0x100a7890
// _Tree<char const *,pair<char const * const,ViewLODList *>,map<char const *,ViewLODList *,ROINameComparator,allocator<ViewLODList *> >::_Kfn,ROINameComparator,allocator<ViewLODList *> >::~_Tree<char const *,pair<char const * const,ViewLODList *>,map<char c
// TEMPLATE: LEGO1 0x100a7960
// _Tree<char const *,pair<char const * const,ViewLODList *>,map<char const *,ViewLODList *,ROINameComparator,allocator<ViewLODList *> >::_Kfn,ROINameComparator,allocator<ViewLODList *> >::erase
// TEMPLATE: LEGO1 0x100a7db0
// _Tree<char const *,pair<char const * const,ViewLODList *>,map<char const *,ViewLODList *,ROINameComparator,allocator<ViewLODList *> >::_Kfn,ROINameComparator,allocator<ViewLODList *> >::_Erase
// TEMPLATE: LEGO1 0x100a7df0
// _Tree<char const *,pair<char const * const,ViewLODList *>,map<char const *,ViewLODList *,ROINameComparator,allocator<ViewLODList *> >::_Kfn,ROINameComparator,allocator<ViewLODList *> >::_Insert
// TEMPLATE: LEGO1 0x100a80a0
// map<char const *,ViewLODList *,ROINameComparator,allocator<ViewLODList *> >::~map<char const *,ViewLODList *,ROINameComparator,allocator<ViewLODList *> >
// TEMPLATE: LEGO1 0x100a8160
// LODList<ViewLOD>::~LODList<ViewLOD>
// GLOBAL: LEGO1 0x10101068
// _Tree<char const *,pair<char const * const,ViewLODList *>,map<char const *,ViewLODList *,ROINameComparator,allocator<ViewLODList *> >::_Kfn,ROINameComparator,allocator<ViewLODList *> >::_Nil
// clang-format on
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// //
// ViewLODList implementation // ViewLODList implementation
inline ViewLODList::ViewLODList(size_t capacity) : LODList<ViewLOD>(capacity), m_refCount(0) inline ViewLODList::ViewLODList(size_t capacity, ViewLODListManager* owner) : LODList<ViewLOD>(capacity), m_refCount(0)
{ {
m_owner = owner;
} }
inline ViewLODList::~ViewLODList() inline ViewLODList::~ViewLODList()