Merge pull request #8035 from Robyt3/Entities-Switch-Fix

Always build switch entities layers
This commit is contained in:
Jupeyy 2024-03-01 15:08:53 +00:00 committed by GitHub
commit 011299d0e3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 37 additions and 56 deletions

View file

@ -229,14 +229,8 @@ IGraphics::CTextureHandle CMapImages::GetEntities(EMapImageEntityLayerType Entit
// build game layer // build game layer
for(int n = 0; n < MAP_IMAGE_ENTITY_LAYER_TYPE_COUNT; ++n) for(int n = 0; n < MAP_IMAGE_ENTITY_LAYER_TYPE_COUNT; ++n)
{ {
bool BuildThisLayer = true;
if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_SWITCH && Layers()->SwitchLayer() == nullptr)
BuildThisLayer = false;
dbg_assert(!m_aaEntitiesTextures[(EntitiesModType * 2) + (int)EntitiesAreMasked][n].IsValid(), "entities texture already loaded when it should not be"); dbg_assert(!m_aaEntitiesTextures[(EntitiesModType * 2) + (int)EntitiesAreMasked][n].IsValid(), "entities texture already loaded when it should not be");
if(BuildThisLayer)
{
// set everything transparent // set everything transparent
mem_zero(pBuildImgData, BuildImageSize); mem_zero(pBuildImgData, BuildImageSize);
@ -290,18 +284,6 @@ IGraphics::CTextureHandle CMapImages::GetEntities(EMapImageEntityLayerType Entit
m_aaEntitiesTextures[(EntitiesModType * 2) + (int)EntitiesAreMasked][n] = Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, pBuildImgData, TextureLoadFlag, aPath); m_aaEntitiesTextures[(EntitiesModType * 2) + (int)EntitiesAreMasked][n] = Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, pBuildImgData, TextureLoadFlag, aPath);
} }
else
{
if(!m_TransparentTexture.IsValid())
{
// set everything transparent
mem_zero(pBuildImgData, BuildImageSize);
m_TransparentTexture = Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, pBuildImgData, TextureLoadFlag, aPath);
}
m_aaEntitiesTextures[(EntitiesModType * 2) + (int)EntitiesAreMasked][n] = m_TransparentTexture;
}
}
free(pBuildImgData); free(pBuildImgData);
@ -355,7 +337,7 @@ void CMapImages::ChangeEntitiesPath(const char *pPath)
{ {
for(int n = 0; n < MAP_IMAGE_ENTITY_LAYER_TYPE_COUNT; ++n) for(int n = 0; n < MAP_IMAGE_ENTITY_LAYER_TYPE_COUNT; ++n)
{ {
if(m_aaEntitiesTextures[i][n].IsValid() && m_aaEntitiesTextures[i][n].Id() != m_TransparentTexture.Id()) if(m_aaEntitiesTextures[i][n].IsValid())
{ {
Graphics()->UnloadTexture(&(m_aaEntitiesTextures[i][n])); Graphics()->UnloadTexture(&(m_aaEntitiesTextures[i][n]));
} }

View file

@ -76,7 +76,6 @@ private:
IGraphics::CTextureHandle m_OverlayBottomTexture; IGraphics::CTextureHandle m_OverlayBottomTexture;
IGraphics::CTextureHandle m_OverlayTopTexture; IGraphics::CTextureHandle m_OverlayTopTexture;
IGraphics::CTextureHandle m_OverlayCenterTexture; IGraphics::CTextureHandle m_OverlayCenterTexture;
IGraphics::CTextureHandle m_TransparentTexture;
int m_TextureScale; int m_TextureScale;
void InitOverlayTextures(); void InitOverlayTextures();