From 90b710eedc31a8bde02e36ddfe85c9226114cdcc Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 9 Mar 2024 10:39:15 -0500 Subject: [PATCH] Implement LegoTexturePresenter::Store --- .../legoomni/include/legonamedtexturelist.h | 31 +++++++++++++++++ LEGO1/lego/legoomni/include/legotextureinfo.h | 9 ++++- .../legoomni/include/legotexturepresenter.h | 2 +- .../legoomni/src/common/legotextureinfo.cpp | 15 +++++++++ .../src/entity/legoworldpresenter.cpp | 2 +- .../src/video/legotexturepresenter.cpp | 33 +++++++++++++++++-- LEGO1/lego/sources/misc/legocontainer.h | 6 ++++ LEGO1/lego/sources/roi/legolod.cpp | 13 ++------ LEGO1/lego/sources/roi/legolod.h | 2 +- LEGO1/lego/sources/roi/legoroi.h | 2 +- 10 files changed, 96 insertions(+), 19 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legonamedtexturelist.h b/LEGO1/lego/legoomni/include/legonamedtexturelist.h index c847213c..05ed0ac3 100644 --- a/LEGO1/lego/legoomni/include/legonamedtexturelist.h +++ b/LEGO1/lego/legoomni/include/legonamedtexturelist.h @@ -23,6 +23,37 @@ class LegoNamedTextureList : public MxPtrList { // LegoNamedTextureList::`scalar deleting destructor' }; +// VTABLE: LEGO1 0x100d8170 +// class MxListCursor + +// VTABLE: LEGO1 0x100d8188 +// class MxPtrListCursor + +// VTABLE: LEGO1 0x100d81a0 +// SIZE 0x10 +class LegoNamedTextureListCursor : public MxPtrListCursor { +public: + LegoNamedTextureListCursor(LegoNamedTextureList* p_list) : MxPtrListCursor(p_list) {} +}; + +// SYNTHETIC: LEGO1 0x1004f500 +// LegoNamedTextureListCursor::`scalar deleting destructor' + +// FUNCTION: LEGO1 0x1004f570 +// MxPtrListCursor::~MxPtrListCursor + +// SYNTHETIC: LEGO1 0x1004f5c0 +// MxListCursor::`scalar deleting destructor' + +// SYNTHETIC: LEGO1 0x1004f630 +// MxPtrListCursor::`scalar deleting destructor' + +// FUNCTION: LEGO1 0x1004f6a0 +// MxListCursor::~MxListCursor + +// FUNCTION: LEGO1 0x1004f6f0 +// LegoNamedTextureListCursor::~LegoNamedTextureListCursor + // TEMPLATE: LEGO1 0x1004eec0 // MxCollection::Compare diff --git a/LEGO1/lego/legoomni/include/legotextureinfo.h b/LEGO1/lego/legoomni/include/legotextureinfo.h index 72afb905..ca8d7055 100644 --- a/LEGO1/lego/legoomni/include/legotextureinfo.h +++ b/LEGO1/lego/legoomni/include/legotextureinfo.h @@ -1,19 +1,26 @@ #ifndef LEGOTEXTUREINFO_H #define LEGOTEXTUREINFO_H +#include "misc/legotypes.h" +#include "tgl/tgl.h" + #include #include class LegoTexture; // SIZE 0x10 -struct LegoTextureInfo { +class LegoTextureInfo { public: LegoTextureInfo(); ~LegoTextureInfo(); static LegoTextureInfo* Create(const char* p_name, LegoTexture* p_texture); + static BOOL SetGroupTexture(Tgl::Mesh* pMesh, LegoTextureInfo* p_textureInfo); + LegoResult FUN_10066010(LegoU8* m_bits); + + // private: char* m_name; // 0x00 LPDIRECTDRAWSURFACE m_surface; // 0x04 LPDIRECTDRAWPALETTE m_palette; // 0x08 diff --git a/LEGO1/lego/legoomni/include/legotexturepresenter.h b/LEGO1/lego/legoomni/include/legotexturepresenter.h index fbb83757..be42cc59 100644 --- a/LEGO1/lego/legoomni/include/legotexturepresenter.h +++ b/LEGO1/lego/legoomni/include/legotexturepresenter.h @@ -32,7 +32,7 @@ class LegoTexturePresenter : public MxMediaPresenter { // LegoTexturePresenter::`scalar deleting destructor' MxResult Read(MxDSChunk& p_chunk); - void FUN_1004f290(); + MxResult Store(); private: LegoNamedTextureList* m_textures; // 0x50 diff --git a/LEGO1/lego/legoomni/src/common/legotextureinfo.cpp b/LEGO1/lego/legoomni/src/common/legotextureinfo.cpp index 539c1f48..06bffa39 100644 --- a/LEGO1/lego/legoomni/src/common/legotextureinfo.cpp +++ b/LEGO1/lego/legoomni/src/common/legotextureinfo.cpp @@ -151,3 +151,18 @@ LegoTextureInfo* LegoTextureInfo::Create(const char* p_name, LegoTexture* p_text return NULL; } + +// STUB: LEGO1 0x10065f60 +BOOL LegoTextureInfo::SetGroupTexture(Tgl::Mesh* pMesh, LegoTextureInfo* p_textureInfo) +{ + TglImpl::MeshImpl::MeshData* data = ((TglImpl::MeshImpl*) pMesh)->ImplementationData(); + data->groupMesh->SetGroupTexture(data->groupIndex, p_textureInfo->m_texture); + return TRUE; +} + +// STUB: LEGO1 0x10066010 +LegoResult LegoTextureInfo::FUN_10066010(LegoU8* m_bits) +{ + // TODO + return SUCCESS; +} diff --git a/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp b/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp index de7fbfa6..84b7bb2a 100644 --- a/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp @@ -227,7 +227,7 @@ MxResult LegoWorldPresenter::LoadWorld(char* p_worldName, LegoWorld* p_world) LegoTexturePresenter texturePresenter; if (texturePresenter.Read(chunk) == SUCCESS) { - texturePresenter.FUN_1004f290(); + texturePresenter.Store(); } delete[] buff; diff --git a/LEGO1/lego/legoomni/src/video/legotexturepresenter.cpp b/LEGO1/lego/legoomni/src/video/legotexturepresenter.cpp index f73d90d4..1033bf62 100644 --- a/LEGO1/lego/legoomni/src/video/legotexturepresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legotexturepresenter.cpp @@ -2,6 +2,8 @@ #include "legoomni.h" #include "legovideomanager.h" +#include "misc/legocontainer.h" +#include "misc/legoimage.h" #include "misc/legostorage.h" #include "mxcompositepresenter.h" @@ -80,10 +82,35 @@ MxResult LegoTexturePresenter::Read(MxDSChunk& p_chunk) return result; } -// STUB: LEGO1 0x1004f290 -void LegoTexturePresenter::FUN_1004f290() +// FUNCTION: LEGO1 0x1004f290 +MxResult LegoTexturePresenter::Store() { - // TODO + LegoNamedTextureListCursor cursor(m_textures); + LegoNamedTexture* namedTexture; + VideoManager(); + + while (cursor.Next(namedTexture)) { + LegoTexture* texture = namedTexture->GetTexture(); + LegoTextureInfo* textureInfo = TextureContainer()->Get(namedTexture->GetName()->GetData()); + + if (textureInfo == NULL) { + textureInfo = LegoTextureInfo::Create(namedTexture->GetName()->GetData(), texture); + + if (textureInfo != NULL) { + TextureContainer()->Add(namedTexture->GetName()->GetData(), textureInfo); + } + } + else { + textureInfo->FUN_10066010(texture->GetImage()->GetBits()); + } + } + + if (m_textures != NULL) { + delete m_textures; + } + + m_textures = NULL; + return SUCCESS; } // STUB: LEGO1 0x1004fc60 diff --git a/LEGO1/lego/sources/misc/legocontainer.h b/LEGO1/lego/sources/misc/legocontainer.h index ac387e0d..a4fb53b0 100644 --- a/LEGO1/lego/sources/misc/legocontainer.h +++ b/LEGO1/lego/sources/misc/legocontainer.h @@ -122,6 +122,12 @@ class LegoTextureContainer : public LegoContainer { // TEMPLATE: LEGO1 0x10001cc0 // _Tree,map >::_Kfn,LegoContainerInfoComparator,allocator >::_Lbound +// TEMPLATE: LEGO1 0x1004f740 +// _Tree,map >::_Kfn,LegoContainerInfoComparator,allocator >::find + +// TEMPLATE: LEGO1 0x1004f800 +// map >::insert + // TEMPLATE: LEGO1 0x1004f960 // _Tree,map >::_Kfn,LegoContainerInfoComparator,allocator >::iterator::_Dec diff --git a/LEGO1/lego/sources/roi/legolod.cpp b/LEGO1/lego/sources/roi/legolod.cpp index 4db477b8..9536b51a 100644 --- a/LEGO1/lego/sources/roi/legolod.cpp +++ b/LEGO1/lego/sources/roi/legolod.cpp @@ -21,15 +21,6 @@ const char* g_unk0x101013dc = "inh"; inline IDirect3DRM2* GetD3DRM(Tgl::Renderer* pRenderer); inline BOOL GetMeshData(IDirect3DRMMesh*& mesh, D3DRMGROUPINDEX& index, Tgl::Mesh* pMesh); -// TODO: Find out which unit this belongs to -// STUB: LEGO1 0x10065f60 -BOOL SetGroupTexture(Tgl::Mesh* pMesh, LegoTextureInfo* p_textureInfo) -{ - TglImpl::MeshImpl::MeshData* data = ((TglImpl::MeshImpl*) pMesh)->ImplementationData(); - data->groupMesh->SetGroupTexture(data->groupIndex, p_textureInfo->m_texture); - return TRUE; -} - // FUNCTION: LEGO1 0x100aa380 LegoLOD::LegoLOD(Tgl::Renderer* p_renderer) : ViewLOD(p_renderer) { @@ -231,7 +222,7 @@ LegoResult LegoLOD::Read(Tgl::Renderer* p_renderer, LegoTextureContainer* p_text } m_meshes[meshIndex].m_tglMesh->SetColor(1.0F, 1.0F, 1.0F, 0.0F); - SetGroupTexture(m_meshes[meshIndex].m_tglMesh, textureInfo); + LegoTextureInfo::SetGroupTexture(m_meshes[meshIndex].m_tglMesh, textureInfo); m_meshes[meshIndex].m_unk0x04 = TRUE; } else { @@ -328,7 +319,7 @@ LegoResult LegoLOD::FUN_100aad00(LegoTextureInfo* p_textureInfo) { for (LegoU32 i = m_unk0x1c; i < m_numMeshes; i++) { if (m_meshes[i].m_unk0x04) { - SetGroupTexture(m_meshes[i].m_tglMesh, p_textureInfo); + LegoTextureInfo::SetGroupTexture(m_meshes[i].m_tglMesh, p_textureInfo); m_meshes[i].m_tglMesh->SetColor(1.0F, 1.0F, 1.0F, 0.0F); m_meshes[i].m_unk0x04 = TRUE; } diff --git a/LEGO1/lego/sources/roi/legolod.h b/LEGO1/lego/sources/roi/legolod.h index 18df610f..9b1143ef 100644 --- a/LEGO1/lego/sources/roi/legolod.h +++ b/LEGO1/lego/sources/roi/legolod.h @@ -5,7 +5,7 @@ #include "viewmanager/viewlod.h" class LegoTextureContainer; -struct LegoTextureInfo; +class LegoTextureInfo; class LegoStorage; // VTABLE: LEGO1 0x100dbf10 diff --git a/LEGO1/lego/sources/roi/legoroi.h b/LEGO1/lego/sources/roi/legoroi.h index 44aeee2a..b5f6c7af 100644 --- a/LEGO1/lego/sources/roi/legoroi.h +++ b/LEGO1/lego/sources/roi/legoroi.h @@ -8,7 +8,7 @@ typedef unsigned char (*ROIHandler)(const char*, char*, unsigned int); class LegoEntity; class LegoTextureContainer; -struct LegoTextureInfo; +class LegoTextureInfo; class LegoStorage; class LegoAnim; class LegoAnimNodeData;