From 6b1c75ab5ae4760f9a1fce4b19508487aab13ca8 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 23 Feb 2024 10:06:16 -0500 Subject: [PATCH] Refactor LegoContainer (#587) * Refactor LegoContainer * Fix name * Fix build * Refactor some includes * Update STL compat * Fix * Fix annotations --- CMakeLists.txt | 10 +- .../lego/legoomni/include/legoanimpresenter.h | 2 +- LEGO1/lego/legoomni/include/legocontainer.h | 161 ------------------ LEGO1/lego/legoomni/include/legogamestate.h | 2 +- LEGO1/lego/legoomni/include/legoomni.h | 2 +- .../legoomni/include/legophonemepresenter.h | 11 +- LEGO1/lego/legoomni/include/legostate.h | 2 +- LEGO1/lego/legoomni/include/legotextureinfo.h | 23 +++ .../legoomni/include/legounksavedatawriter.h | 2 +- ...{legocontainer.cpp => legotextureinfo.cpp} | 51 +----- LEGO1/lego/legoomni/src/infocenter/score.cpp | 4 +- LEGO1/lego/legoomni/src/main/legoomni.cpp | 4 +- .../src/video/legopalettepresenter.cpp | 2 +- LEGO1/lego/sources/anim/legoanim.h | 4 +- LEGO1/lego/sources/misc/legocontainer.cpp | 43 +++++ LEGO1/lego/sources/misc/legocontainer.h | 149 ++++++++++++++++ LEGO1/lego/sources/roi/legoroi.h | 2 +- LEGO1/mxstl/stlcompat.h | 2 + 18 files changed, 249 insertions(+), 227 deletions(-) delete mode 100644 LEGO1/lego/legoomni/include/legocontainer.h create mode 100644 LEGO1/lego/legoomni/include/legotextureinfo.h rename LEGO1/lego/legoomni/src/common/{legocontainer.cpp => legotextureinfo.cpp} (73%) create mode 100644 LEGO1/lego/sources/misc/legocontainer.cpp create mode 100644 LEGO1/lego/sources/misc/legocontainer.h diff --git a/CMakeLists.txt b/CMakeLists.txt index fad4e322..91e85359 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -144,7 +144,7 @@ add_library(roi STATIC ) register_lego1_target(roi) set_property(TARGET roi PROPERTY ARCHIVE_OUTPUT_NAME "roi$<$:d>") -target_include_directories(roi PRIVATE "${CMAKE_SOURCE_DIR}/LEGO1" "${CMAKE_SOURCE_DIR}/util") +target_include_directories(roi PRIVATE "${CMAKE_SOURCE_DIR}/LEGO1" "${CMAKE_SOURCE_DIR}/LEGO1/lego/sources" "${CMAKE_SOURCE_DIR}/util") target_link_libraries(roi PRIVATE) add_library(anim STATIC @@ -152,10 +152,11 @@ add_library(anim STATIC ) register_lego1_target(anim) set_property(TARGET anim PROPERTY ARCHIVE_OUTPUT_NAME "anim$<$:d>") -target_include_directories(anim PRIVATE "${CMAKE_SOURCE_DIR}/LEGO1/omni/include" "${CMAKE_SOURCE_DIR}/LEGO1" "${CMAKE_SOURCE_DIR}/util") +target_include_directories(anim PRIVATE "${CMAKE_SOURCE_DIR}/LEGO1/omni/include" "${CMAKE_SOURCE_DIR}/LEGO1" "${CMAKE_SOURCE_DIR}/LEGO1/lego/sources" "${CMAKE_SOURCE_DIR}/util") target_link_libraries(anim PRIVATE) add_library(misc STATIC + LEGO1/lego/sources/misc/legocontainer.cpp LEGO1/lego/sources/misc/legoimage.cpp LEGO1/lego/sources/misc/legostorage.cpp LEGO1/lego/sources/misc/legotexture.cpp @@ -163,7 +164,7 @@ add_library(misc STATIC ) register_lego1_target(misc) set_property(TARGET misc PROPERTY ARCHIVE_OUTPUT_NAME "misc$<$:d>") -target_include_directories(misc PRIVATE "${CMAKE_SOURCE_DIR}/LEGO1/omni/include" "${CMAKE_SOURCE_DIR}/LEGO1" "${CMAKE_SOURCE_DIR}/LEGO1/realtime" "${CMAKE_SOURCE_DIR}/util") +target_include_directories(misc PRIVATE "${CMAKE_SOURCE_DIR}/LEGO1/omni/include" "${CMAKE_SOURCE_DIR}/LEGO1" "${CMAKE_SOURCE_DIR}/util") target_link_libraries(misc PRIVATE) add_library(3dmanager STATIC @@ -293,12 +294,12 @@ add_library(lego1 SHARED LEGO1/lego/legoomni/src/common/animstate.cpp LEGO1/lego/legoomni/src/common/legoactioncontrolpresenter.cpp LEGO1/lego/legoomni/src/common/legobackgroundcolor.cpp - LEGO1/lego/legoomni/src/common/legocontainer.cpp LEGO1/lego/legoomni/src/common/legofullscreenmovie.cpp LEGO1/lego/legoomni/src/common/legogamestate.cpp LEGO1/lego/legoomni/src/common/legoobjectfactory.cpp LEGO1/lego/legoomni/src/common/legoplantmanager.cpp LEGO1/lego/legoomni/src/common/legostate.cpp + LEGO1/lego/legoomni/src/common/legotextureinfo.cpp LEGO1/lego/legoomni/src/common/legounksavedatawriter.cpp LEGO1/lego/legoomni/src/common/legoutil.cpp LEGO1/lego/legoomni/src/common/legovariables.cpp @@ -407,7 +408,6 @@ target_include_directories(lego1 PUBLIC "${CMAKE_SOURCE_DIR}/LEGO1") target_include_directories(lego1 PUBLIC "${CMAKE_SOURCE_DIR}/LEGO1/omni/include") target_include_directories(lego1 PUBLIC "${CMAKE_SOURCE_DIR}/LEGO1/lego/sources") target_include_directories(lego1 PUBLIC "${CMAKE_SOURCE_DIR}/LEGO1/lego/legoomni/include") -target_include_directories(lego1 PUBLIC "${CMAKE_SOURCE_DIR}/LEGO1/realtime") # Link libraries target_link_libraries(lego1 PRIVATE tglrl viewmanager realtime mxdirectx roi anim FLIC::FLIC Vec::Vec dinput dxguid misc 3dmanager omni) diff --git a/LEGO1/lego/legoomni/include/legoanimpresenter.h b/LEGO1/lego/legoomni/include/legoanimpresenter.h index 1f8a0058..7ae607fd 100644 --- a/LEGO1/lego/legoomni/include/legoanimpresenter.h +++ b/LEGO1/lego/legoomni/include/legoanimpresenter.h @@ -1,7 +1,7 @@ #ifndef LEGOANIMPRESENTER_H #define LEGOANIMPRESENTER_H -#include "lego/sources/anim/legoanim.h" +#include "anim/legoanim.h" #include "mxgeometry/mxgeometry3d.h" #include "mxvideopresenter.h" diff --git a/LEGO1/lego/legoomni/include/legocontainer.h b/LEGO1/lego/legoomni/include/legocontainer.h deleted file mode 100644 index a5c73786..00000000 --- a/LEGO1/lego/legoomni/include/legocontainer.h +++ /dev/null @@ -1,161 +0,0 @@ -#ifndef LEGOTEXTURECONTAINER_H -#define LEGOTEXTURECONTAINER_H - -#include "compat.h" -#include "decomp.h" -#include "mxstl/stlcompat.h" -#include "mxtypes.h" - -#include -#include - -#pragma warning(disable : 4237) - -class LegoTexture; - -// SIZE 0x10 -struct TextureData { -public: - TextureData(); - ~TextureData(); - - static TextureData* Create(const char* p_name, LegoTexture* p_texture); - - char* m_name; // 0x00 - LPDIRECTDRAWSURFACE m_surface; // 0x04 - LPDIRECTDRAWPALETTE m_palette; // 0x08 - LPDIRECT3DRMTEXTURE2 m_texture; // 0x0c -}; - -struct LegoContainerInfoComparator { - bool operator()(const char* const& p_key0, const char* const& p_key1) const { return strcmp(p_key0, p_key1) > 0; } -}; - -// SIZE 0x10 -template -class LegoContainerInfo : public map {}; - -// SIZE 0x18 -template -class LegoContainer { -public: - virtual ~LegoContainer() - { -#ifdef COMPAT_MODE - typename LegoContainerInfo::iterator it; -#else - LegoContainerInfo::iterator it; -#endif - for (it = m_map.begin(); it != m_map.end(); it++) { - // DECOMP: Use of const_cast here matches ~ViewLODListManager from 96 source. - const char* const& key = (*it).first; - delete[] const_cast(key); - - if (m_ownership) { - delete (*it).second; - } - } - } - - inline T* Get(const char* p_name) - { -#ifdef COMPAT_MODE - typename LegoContainerInfo::iterator it = m_map.find(p_name); -#else - LegoContainerInfo::iterator it = m_map.find(p_name); -#endif - if (it != m_map.end()) { - return (*it).second; - } - - return NULL; - } - - inline void SetOwnership(MxBool p_ownership) { m_ownership = p_ownership; } - -protected: - MxBool m_ownership; // 0x04 - LegoContainerInfo m_map; // 0x08 -}; - -// VTABLE: LEGO1 0x100d86d4 -// class LegoContainer - -typedef list TextureList; - -// VTABLE: LEGO1 0x100d86fc -// SIZE 0x24 -class LegoTextureContainer : public LegoContainer { -public: - LegoTextureContainer() { m_ownership = TRUE; } - ~LegoTextureContainer() override; - - void FUN_10099cc0(TextureData* p_data); - -protected: - TextureList m_list; // 0x18 -}; - -// TEMPLATE: LEGO1 0x10059c50 -// allocator::_Charalloc - -// clang-format off -// TEMPLATE: LEGO1 0x10001cc0 -// _Tree,map >::_Kfn,LegoContainerInfoComparator,allocator >::_Lbound - -// TEMPLATE: LEGO1 0x1004f9b0 -// _Tree,map >::_Kfn,LegoContainerInfoComparator,allocator >::_Insert - -// TEMPLATE: LEGO1 0x10059c70 -// _Tree,map >::_Kfn,LegoContainerInfoComparator,allocator >::_Color - -// TEMPLATE: LEGO1 0x10059c80 -// _Tree,map >::_Kfn,LegoContainerInfoComparator,allocator >::_Left - -// TEMPLATE: LEGO1 0x10059c90 -// _Tree,map >::_Kfn,LegoContainerInfoComparator,allocator >::_Parent - -// TEMPLATE: LEGO1 0x10059ca0 -// _Tree,map >::_Kfn,LegoContainerInfoComparator,allocator >::_Right - -// TEMPLATE: LEGO1 0x10059cb0 -// _Tree,map >::_Kfn,LegoContainerInfoComparator,allocator >::~_Tree,map >::_Kfn,LegoContainerInfoComparator,allocator > - -// TEMPLATE: LEGO1 0x10059d80 -// _Tree,map >::_Kfn,LegoContainerInfoComparator,allocator >::iterator::_Inc - -// TEMPLATE: LEGO1 0x10059dc0 -// _Tree,map >::_Kfn,LegoContainerInfoComparator,allocator >::erase - -// TEMPLATE: LEGO1 0x1005a210 -// _Tree,map >::_Kfn,LegoContainerInfoComparator,allocator >::_Erase - -// TEMPLATE: LEGO1 0x1005a250 -// list >::~list > - -// TEMPLATE: LEGO1 0x1005a2c0 -// map >::~map > - -// TEMPLATE: LEGO1 0x1005a310 -// LegoContainer::`scalar deleting destructor' - -// TEMPLATE: LEGO1 0x1005a400 -// LegoContainerInfo::~LegoContainerInfo - -// TEMPLATE: LEGO1 0x1005a450 -// Map::~Map - -// SYNTHETIC: LEGO1 0x1005a580 -// LegoTextureContainer::`scalar deleting destructor' - -// TEMPLATE: LEGO1 0x1005a5a0 -// List::~List - -// TEMPLATE: LEGO1 0x1005b660 -// LegoContainer::~LegoContainer - -// GLOBAL: LEGO1 0x100f0100 -// _Tree,map >::_Kfn,LegoContainerInfoComparator,allocator >::_Nil -// clang-format on - -#endif // LEGOTEXTURECONTAINER_H diff --git a/LEGO1/lego/legoomni/include/legogamestate.h b/LEGO1/lego/legoomni/include/legogamestate.h index f893f154..011fbf8a 100644 --- a/LEGO1/lego/legoomni/include/legogamestate.h +++ b/LEGO1/lego/legoomni/include/legogamestate.h @@ -2,9 +2,9 @@ #define LEGOGAMESTATE_H #include "decomp.h" -#include "lego/sources/misc/legostorage.h" #include "legobackgroundcolor.h" #include "legofullscreenmovie.h" +#include "misc/legostorage.h" #include "mxtypes.h" #include "mxvariabletable.h" diff --git a/LEGO1/lego/legoomni/include/legoomni.h b/LEGO1/lego/legoomni/include/legoomni.h index e19189f7..a8b27b4d 100644 --- a/LEGO1/lego/legoomni/include/legoomni.h +++ b/LEGO1/lego/legoomni/include/legoomni.h @@ -275,7 +275,7 @@ ViewManager* GetViewManager(); LegoPlantManager* PlantManager(); LegoWorld* CurrentWorld(); LegoUnkSaveDataWriter* UnkSaveDataWriter(); -LegoTextureContainer* GetTextureContainer(); +LegoTextureContainer* TextureContainer(); void FUN_10015820(MxBool p_disable, MxU16 p_flags); void SetROIUnknown0x0c(const char* p_name, undefined p_unk0x0c); LegoWorld* FindWorld(const MxAtomId& p_atom, MxS32 p_entityid); diff --git a/LEGO1/lego/legoomni/include/legophonemepresenter.h b/LEGO1/lego/legoomni/include/legophonemepresenter.h index db86a1e5..59263f7f 100644 --- a/LEGO1/lego/legoomni/include/legophonemepresenter.h +++ b/LEGO1/lego/legoomni/include/legophonemepresenter.h @@ -30,11 +30,12 @@ public: private: void Init(); - int m_unk0x68; - int m_unk0x6c; - undefined m_unk0x70; - MxString m_string; // 0x74 - undefined m_unk0x84; + + undefined4 m_unk0x68; // 0x68 + undefined4 m_unk0x6c; // 0x6c + undefined m_unk0x70; // 0x70 + MxString m_unk0x74; // 0x74 + undefined m_unk0x84; // 0x84 }; #endif // LEGOPHONEMEPRESENTER_H diff --git a/LEGO1/lego/legoomni/include/legostate.h b/LEGO1/lego/legoomni/include/legostate.h index 2ed94a3e..d4f9bad4 100644 --- a/LEGO1/lego/legoomni/include/legostate.h +++ b/LEGO1/lego/legoomni/include/legostate.h @@ -2,7 +2,7 @@ #define LEGOSTATE_H #include "decomp.h" -#include "lego/sources/misc/legostorage.h" +#include "misc/legostorage.h" #include "mxcore.h" #include "mxstring.h" diff --git a/LEGO1/lego/legoomni/include/legotextureinfo.h b/LEGO1/lego/legoomni/include/legotextureinfo.h new file mode 100644 index 00000000..72afb905 --- /dev/null +++ b/LEGO1/lego/legoomni/include/legotextureinfo.h @@ -0,0 +1,23 @@ +#ifndef LEGOTEXTUREINFO_H +#define LEGOTEXTUREINFO_H + +#include +#include + +class LegoTexture; + +// SIZE 0x10 +struct LegoTextureInfo { +public: + LegoTextureInfo(); + ~LegoTextureInfo(); + + static LegoTextureInfo* Create(const char* p_name, LegoTexture* p_texture); + + char* m_name; // 0x00 + LPDIRECTDRAWSURFACE m_surface; // 0x04 + LPDIRECTDRAWPALETTE m_palette; // 0x08 + LPDIRECT3DRMTEXTURE2 m_texture; // 0x0c +}; + +#endif // LEGOTEXTUREINFO_H diff --git a/LEGO1/lego/legoomni/include/legounksavedatawriter.h b/LEGO1/lego/legoomni/include/legounksavedatawriter.h index e0aa8cea..7fa539ca 100644 --- a/LEGO1/lego/legoomni/include/legounksavedatawriter.h +++ b/LEGO1/lego/legoomni/include/legounksavedatawriter.h @@ -2,8 +2,8 @@ #define LEGOUNKSAVEDATAWRITER_H #include "decomp.h" -#include "lego/sources/misc/legostorage.h" #include "legovariables.h" +#include "misc/legostorage.h" #include "mxstl/stlcompat.h" #include "mxtypes.h" diff --git a/LEGO1/lego/legoomni/src/common/legocontainer.cpp b/LEGO1/lego/legoomni/src/common/legotextureinfo.cpp similarity index 73% rename from LEGO1/lego/legoomni/src/common/legocontainer.cpp rename to LEGO1/lego/legoomni/src/common/legotextureinfo.cpp index 411ff7ab..84c587cf 100644 --- a/LEGO1/lego/legoomni/src/common/legocontainer.cpp +++ b/LEGO1/lego/legoomni/src/common/legotextureinfo.cpp @@ -1,18 +1,15 @@ -#include "legocontainer.h" +#include "legotextureinfo.h" -#include "lego/sources/misc/legoimage.h" -#include "lego/sources/misc/legotexture.h" #include "legoomni.h" #include "legovideomanager.h" +#include "misc/legoimage.h" +#include "misc/legotexture.h" #include "tgl/d3drm/impl.h" -DECOMP_SIZE_ASSERT(TextureData, 0x10); -DECOMP_SIZE_ASSERT(LegoContainerInfo, 0x10); -// DECOMP_SIZE_ASSERT(LegoContainer, 0x18); -DECOMP_SIZE_ASSERT(LegoTextureContainer, 0x24); +DECOMP_SIZE_ASSERT(LegoTextureInfo, 0x10); // FUNCTION: LEGO1 0x10065bf0 -TextureData::TextureData() +LegoTextureInfo::LegoTextureInfo() { m_name = NULL; m_surface = NULL; @@ -21,7 +18,7 @@ TextureData::TextureData() } // FUNCTION: LEGO1 0x10065c00 -TextureData::~TextureData() +LegoTextureInfo::~LegoTextureInfo() { if (m_name) { delete[] m_name; @@ -45,9 +42,9 @@ TextureData::~TextureData() } // FUNCTION: LEGO1 0x10065c60 -TextureData* TextureData::Create(const char* p_name, LegoTexture* p_texture) +LegoTextureInfo* LegoTextureInfo::Create(const char* p_name, LegoTexture* p_texture) { - TextureData* texture = new TextureData(); + LegoTextureInfo* texture = new LegoTextureInfo(); if (p_name == NULL || p_texture == NULL) { return NULL; @@ -154,35 +151,3 @@ done: return NULL; } - -// FUNCTION: LEGO1 0x10099870 -LegoTextureContainer::~LegoTextureContainer() -{ -} - -// FUNCTION: LEGO1 0x10099cc0 -void LegoTextureContainer::FUN_10099cc0(TextureData* p_data) -{ - if (p_data == NULL) { - return; - } - -#ifdef COMPAT_MODE - TextureList::iterator it; - for (it = m_list.begin(); it != m_list.end(); it++) { -#else - for (TextureList::iterator it = m_list.begin(); it != m_list.end(); it++) { -#endif - if (*it == p_data) { - // TODO: This is wrong, but what is at +0x0c on the iterator? - *it = NULL; - - if (p_data->m_texture->Release() == TRUE) { - delete p_data; - m_list.erase(it); - } - - return; - } - } -} diff --git a/LEGO1/lego/legoomni/src/infocenter/score.cpp b/LEGO1/lego/legoomni/src/infocenter/score.cpp index 40c8f98c..0f924725 100644 --- a/LEGO1/lego/legoomni/src/infocenter/score.cpp +++ b/LEGO1/lego/legoomni/src/infocenter/score.cpp @@ -2,11 +2,11 @@ #include "ambulancemissionstate.h" #include "jukebox.h" -#include "legocontainer.h" #include "legocontrolmanager.h" #include "legogamestate.h" #include "legoinputmanager.h" #include "legoomni.h" +#include "misc/legocontainer.h" #include "mxnotificationmanager.h" #include "mxnotificationparam.h" #include "mxtransitionmanager.h" @@ -233,7 +233,7 @@ void Score::Enable(MxBool p_enable) // FUNCTION: LEGO1 0x100019d0 void Score::Paint() { - TextureData* gd = GetTextureContainer()->Get("bigcube.gif"); + LegoTextureInfo* gd = TextureContainer()->Get("bigcube.gif"); if (gd) { RaceState* l78 = (RaceState*) GameState()->GetState("JetskiRaceState"); diff --git a/LEGO1/lego/legoomni/src/main/legoomni.cpp b/LEGO1/lego/legoomni/src/main/legoomni.cpp index 25327e11..0ea4607d 100644 --- a/LEGO1/lego/legoomni/src/main/legoomni.cpp +++ b/LEGO1/lego/legoomni/src/main/legoomni.cpp @@ -2,7 +2,6 @@ #include "legoanimationmanager.h" #include "legobuildingmanager.h" -#include "legocontainer.h" #include "legogamestate.h" #include "legoinputmanager.h" #include "legoobjectfactory.h" @@ -14,6 +13,7 @@ #include "legovideomanager.h" #include "legoworld.h" #include "legoworldlist.h" +#include "misc/legocontainer.h" #include "mxactionnotificationparam.h" #include "mxautolocker.h" #include "mxbackgroundaudiomanager.h" @@ -215,7 +215,7 @@ LegoBuildingManager* BuildingManager() } // FUNCTION: LEGO1 0x10015800 -LegoTextureContainer* GetTextureContainer() +LegoTextureContainer* TextureContainer() { return LegoOmni::GetInstance()->GetTextureContainer(); } diff --git a/LEGO1/lego/legoomni/src/video/legopalettepresenter.cpp b/LEGO1/lego/legoomni/src/video/legopalettepresenter.cpp index e6469cc6..c071a37e 100644 --- a/LEGO1/lego/legoomni/src/video/legopalettepresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legopalettepresenter.cpp @@ -1,8 +1,8 @@ #include "legopalettepresenter.h" -#include "lego/sources/misc/legostorage.h" #include "legoomni.h" #include "legovideomanager.h" +#include "misc/legostorage.h" #include "mxstreamchunk.h" DECOMP_SIZE_ASSERT(LegoPalettePresenter, 0x68) diff --git a/LEGO1/lego/sources/anim/legoanim.h b/LEGO1/lego/sources/anim/legoanim.h index d728e5d1..a16b2415 100644 --- a/LEGO1/lego/sources/anim/legoanim.h +++ b/LEGO1/lego/sources/anim/legoanim.h @@ -2,8 +2,8 @@ #define __LEGOANIM_H #include "decomp.h" -#include "lego/sources/misc/legostorage.h" -#include "lego/sources/misc/legotree.h" +#include "misc/legostorage.h" +#include "misc/legotree.h" // SIZE 0x08 class LegoAnimKey { diff --git a/LEGO1/lego/sources/misc/legocontainer.cpp b/LEGO1/lego/sources/misc/legocontainer.cpp new file mode 100644 index 00000000..75efabfb --- /dev/null +++ b/LEGO1/lego/sources/misc/legocontainer.cpp @@ -0,0 +1,43 @@ +#include "legocontainer.h" + +DECOMP_SIZE_ASSERT(LegoContainerInfo, 0x10); +// DECOMP_SIZE_ASSERT(LegoContainer, 0x18); +DECOMP_SIZE_ASSERT(LegoTextureContainer, 0x24); + +// FUNCTION: LEGO1 0x10099870 +LegoTextureContainer::~LegoTextureContainer() +{ +} + +// STUB: LEGO1 0x100998e0 +LegoTextureInfo* LegoTextureContainer::Create(undefined* p_und) +{ + return NULL; +} + +// FUNCTION: LEGO1 0x10099cc0 +void LegoTextureContainer::Destroy(LegoTextureInfo* p_data) +{ + if (p_data == NULL) { + return; + } + +#ifdef COMPAT_MODE + LegoTextureList::iterator it; + for (it = m_list.begin(); it != m_list.end(); it++) { +#else + for (LegoTextureList::iterator it = m_list.begin(); it != m_list.end(); it++) { +#endif + if (((*it).first) == p_data) { + // TODO: Element type + (*it).second = 0; + + if (p_data->m_texture->Release() == TRUE) { + delete p_data; + m_list.erase(it); + } + + return; + } + } +} diff --git a/LEGO1/lego/sources/misc/legocontainer.h b/LEGO1/lego/sources/misc/legocontainer.h new file mode 100644 index 00000000..a4c2b148 --- /dev/null +++ b/LEGO1/lego/sources/misc/legocontainer.h @@ -0,0 +1,149 @@ +#ifndef LEGOCONTAINER_H +#define LEGOCONTAINER_H + +#include "compat.h" +#include "decomp.h" +#include "legotexture.h" +#include "legotypes.h" +#include "mxstl/stlcompat.h" + +// Note: dependency on LegoOmni +#include "lego/legoomni/include/legotextureinfo.h" + +#pragma warning(disable : 4237) + +struct LegoContainerInfoComparator { + bool operator()(const char* const& p_key0, const char* const& p_key1) const { return strcmp(p_key0, p_key1) > 0; } +}; + +// SIZE 0x10 +template +class LegoContainerInfo : public map {}; + +// SIZE 0x18 +template +class LegoContainer { +public: + virtual ~LegoContainer() + { +#ifdef COMPAT_MODE + typename LegoContainerInfo::iterator it; +#else + LegoContainerInfo::iterator it; +#endif + for (it = m_map.begin(); it != m_map.end(); it++) { + // DECOMP: Use of const_cast here matches ~ViewLODListManager from 96 source. + const char* const& key = (*it).first; + delete[] const_cast(key); + + if (m_ownership) { + delete (*it).second; + } + } + } + + inline T* Get(const char* p_name) + { +#ifdef COMPAT_MODE + typename LegoContainerInfo::iterator it = m_map.find(p_name); +#else + LegoContainerInfo::iterator it = m_map.find(p_name); +#endif + if (it != m_map.end()) { + return (*it).second; + } + + return NULL; + } + + inline void SetOwnership(LegoBool p_ownership) { m_ownership = p_ownership; } + +protected: + LegoBool m_ownership; // 0x04 + LegoContainerInfo m_map; // 0x08 +}; + +// VTABLE: LEGO1 0x100d86d4 +// class LegoContainer + +// TODO: Element type +typedef pair LegoTextureListElement; +typedef list LegoTextureList; + +// VTABLE: LEGO1 0x100d86fc +// SIZE 0x24 +class LegoTextureContainer : public LegoContainer { +public: + LegoTextureContainer() { m_ownership = TRUE; } + ~LegoTextureContainer() override; + + LegoTextureInfo* Create(undefined* p_und); + void Destroy(LegoTextureInfo* p_data); + +protected: + LegoTextureList m_list; // 0x18 +}; + +// TEMPLATE: LEGO1 0x10059c50 +// allocator::_Charalloc + +// clang-format off +// TEMPLATE: LEGO1 0x10001cc0 +// _Tree,map >::_Kfn,LegoContainerInfoComparator,allocator >::_Lbound + +// TEMPLATE: LEGO1 0x1004f9b0 +// _Tree,map >::_Kfn,LegoContainerInfoComparator,allocator >::_Insert + +// TEMPLATE: LEGO1 0x10059c70 +// _Tree,map >::_Kfn,LegoContainerInfoComparator,allocator >::_Color + +// TEMPLATE: LEGO1 0x10059c80 +// _Tree,map >::_Kfn,LegoContainerInfoComparator,allocator >::_Left + +// TEMPLATE: LEGO1 0x10059c90 +// _Tree,map >::_Kfn,LegoContainerInfoComparator,allocator >::_Parent + +// TEMPLATE: LEGO1 0x10059ca0 +// _Tree,map >::_Kfn,LegoContainerInfoComparator,allocator >::_Right + +// TEMPLATE: LEGO1 0x10059cb0 +// _Tree,map >::_Kfn,LegoContainerInfoComparator,allocator >::~_Tree,map >::_Kfn,LegoContainerInfoComparator,allocator > + +// TEMPLATE: LEGO1 0x10059d80 +// _Tree,map >::_Kfn,LegoContainerInfoComparator,allocator >::iterator::_Inc + +// TEMPLATE: LEGO1 0x10059dc0 +// _Tree,map >::_Kfn,LegoContainerInfoComparator,allocator >::erase + +// TEMPLATE: LEGO1 0x1005a210 +// _Tree,map >::_Kfn,LegoContainerInfoComparator,allocator >::_Erase + +// TEMPLATE: LEGO1 0x1005a250 +// list,allocator > >::~list,allocator > > + +// TEMPLATE: LEGO1 0x1005a2c0 +// map >::~map > + +// TEMPLATE: LEGO1 0x1005a310 +// LegoContainer::`scalar deleting destructor' + +// TEMPLATE: LEGO1 0x1005a400 +// LegoContainerInfo::~LegoContainerInfo + +// TEMPLATE: LEGO1 0x1005a450 +// Map::~Map + +// SYNTHETIC: LEGO1 0x1005a580 +// LegoTextureContainer::`scalar deleting destructor' + +// TEMPLATE: LEGO1 0x1005a5a0 +// List >::~List > + +// TEMPLATE: LEGO1 0x1005b660 +// LegoContainer::~LegoContainer + +// GLOBAL: LEGO1 0x100f0100 +// _Tree,map >::_Kfn,LegoContainerInfoComparator,allocator >::_Nil +// clang-format on + +#endif // LEGOCONTAINER_H diff --git a/LEGO1/lego/sources/roi/legoroi.h b/LEGO1/lego/sources/roi/legoroi.h index 64bb2b7e..8b6c78ce 100644 --- a/LEGO1/lego/sources/roi/legoroi.h +++ b/LEGO1/lego/sources/roi/legoroi.h @@ -1,7 +1,7 @@ #ifndef LEGOROI_H #define LEGOROI_H -#include "lego/sources/misc/legotypes.h" +#include "misc/legotypes.h" #include "viewmanager/viewroi.h" typedef unsigned char (*ROIHandler)(char*, char*, unsigned int); diff --git a/LEGO1/mxstl/stlcompat.h b/LEGO1/mxstl/stlcompat.h index 29c31549..c6f525bd 100644 --- a/LEGO1/mxstl/stlcompat.h +++ b/LEGO1/mxstl/stlcompat.h @@ -12,9 +12,11 @@ #include #include #include +#include #include using std::list; using std::map; +using std::pair; using std::set; using std::vector; #endif