From dfc3a8d33ec1850cea05fed83e692ca3e7223dbc Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 23 Feb 2024 12:23:21 -0500 Subject: [PATCH] Match --- LEGO1/lego/sources/misc/legocontainer.cpp | 39 ++++++++++------------- LEGO1/lego/sources/misc/legocontainer.h | 2 +- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/LEGO1/lego/sources/misc/legocontainer.cpp b/LEGO1/lego/sources/misc/legocontainer.cpp index f89b88ad..aebfc96d 100644 --- a/LEGO1/lego/sources/misc/legocontainer.cpp +++ b/LEGO1/lego/sources/misc/legocontainer.cpp @@ -18,7 +18,6 @@ LegoTextureInfo* LegoTextureContainer::Insert(LegoTextureInfo* p_textureInfo) { DDSURFACEDESC desc, newDesc; DWORD width, height; - LegoTextureInfo* textureInfo; memset(&desc, 0, sizeof(desc)); desc.dwSize = sizeof(desc); @@ -28,36 +27,31 @@ LegoTextureInfo* LegoTextureContainer::Insert(LegoTextureInfo* p_textureInfo) p_textureInfo->m_surface->Unlock(desc.lpSurface); } - LegoTextureList::iterator it; - for (it = m_list.begin(); it != m_list.end(); it++) { - if ((*it).second == FALSE) { - textureInfo = (*it).first; + for (LegoTextureList::iterator it = m_list.begin(); it != m_list.end(); it++) { + if ((*it).second == FALSE && (*it).first->m_texture->AddRef() != 0 && (*it).first->m_texture->Release() == 1) { + if (!strcmp((*it).first->m_name, p_textureInfo->m_name)) { + memset(&newDesc, 0, sizeof(newDesc)); + newDesc.dwSize = sizeof(newDesc); - if (textureInfo->m_texture->AddRef() != 0 && textureInfo->m_texture->Release() == 1) { - if (!strcmp(textureInfo->m_name, p_textureInfo->m_name)) { - memset(&newDesc, 0, sizeof(newDesc)); - newDesc.dwSize = sizeof(newDesc); + if ((*it).first->m_surface->Lock(NULL, &newDesc, DDLOCK_SURFACEMEMORYPTR, NULL) == DD_OK) { + BOOL und = FALSE; + if (newDesc.dwWidth == width && newDesc.dwHeight == height) { + und = TRUE; + } - if (textureInfo->m_surface->Lock(NULL, &newDesc, DDLOCK_SURFACEMEMORYPTR, NULL) == DD_OK) { - BOOL und = FALSE; - if (newDesc.dwWidth == width && newDesc.dwHeight == height) { - und = TRUE; - } + (*it).first->m_surface->Unlock(newDesc.lpSurface); - textureInfo->m_surface->Unlock(newDesc.lpSurface); - - if (und) { - (*it).second = TRUE; - textureInfo->m_texture->AddRef(); - return textureInfo; - } + if (und) { + (*it).second = TRUE; + (*it).first->m_texture->AddRef(); + return (*it).first; } } } } } - textureInfo = new LegoTextureInfo(); + LegoTextureInfo* textureInfo = new LegoTextureInfo(); textureInfo->m_palette = p_textureInfo->m_palette; p_textureInfo->m_palette->Release(); @@ -107,7 +101,6 @@ LegoTextureInfo* LegoTextureContainer::Insert(LegoTextureInfo* p_textureInfo) textureInfo->m_name = new char[strlen(p_textureInfo->m_name) + 1]; strcpy(textureInfo->m_name, p_textureInfo->m_name); - return textureInfo; } } diff --git a/LEGO1/lego/sources/misc/legocontainer.h b/LEGO1/lego/sources/misc/legocontainer.h index 074903aa..89bdaea9 100644 --- a/LEGO1/lego/sources/misc/legocontainer.h +++ b/LEGO1/lego/sources/misc/legocontainer.h @@ -119,7 +119,7 @@ class LegoTextureContainer : public LegoContainer { // _Tree,map >::_Kfn,LegoContainerInfoComparator,allocator >::_Erase // TEMPLATE: LEGO1 0x1005a250 -// list,allocator > >::~list,allocator > > +// list,allocator > >::~list,allocator > > // TEMPLATE: LEGO1 0x1005a2c0 // map >::~map >