mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-18 22:18:19 +00:00
Merge pull request #8035 from Robyt3/Entities-Switch-Fix
Always build switch entities layers
This commit is contained in:
commit
011299d0e3
|
@ -229,78 +229,60 @@ 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
|
||||||
{
|
mem_zero(pBuildImgData, BuildImageSize);
|
||||||
// set everything transparent
|
|
||||||
mem_zero(pBuildImgData, BuildImageSize);
|
|
||||||
|
|
||||||
for(int i = 0; i < 256; ++i)
|
for(int i = 0; i < 256; ++i)
|
||||||
|
{
|
||||||
|
bool ValidTile = i != 0;
|
||||||
|
int TileIndex = i;
|
||||||
|
if(EntitiesAreMasked)
|
||||||
{
|
{
|
||||||
bool ValidTile = i != 0;
|
if(EntitiesModType == MAP_IMAGE_MOD_TYPE_DDNET || EntitiesModType == MAP_IMAGE_MOD_TYPE_DDRACE)
|
||||||
int TileIndex = i;
|
|
||||||
if(EntitiesAreMasked)
|
|
||||||
{
|
{
|
||||||
if(EntitiesModType == MAP_IMAGE_MOD_TYPE_DDNET || EntitiesModType == MAP_IMAGE_MOD_TYPE_DDRACE)
|
if(EntitiesModType == MAP_IMAGE_MOD_TYPE_DDNET || TileIndex != TILE_BOOST)
|
||||||
{
|
{
|
||||||
if(EntitiesModType == MAP_IMAGE_MOD_TYPE_DDNET || TileIndex != TILE_BOOST)
|
if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_ALL_EXCEPT_SWITCH && !IsValidGameTile((int)TileIndex) && !IsValidFrontTile((int)TileIndex) && !IsValidSpeedupTile((int)TileIndex) &&
|
||||||
|
!IsValidTeleTile((int)TileIndex) && !IsValidTuneTile((int)TileIndex))
|
||||||
|
ValidTile = false;
|
||||||
|
else if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_SWITCH)
|
||||||
{
|
{
|
||||||
if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_ALL_EXCEPT_SWITCH && !IsValidGameTile((int)TileIndex) && !IsValidFrontTile((int)TileIndex) && !IsValidSpeedupTile((int)TileIndex) &&
|
if(!IsValidSwitchTile((int)TileIndex))
|
||||||
!IsValidTeleTile((int)TileIndex) && !IsValidTuneTile((int)TileIndex))
|
|
||||||
ValidTile = false;
|
ValidTile = false;
|
||||||
else if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_SWITCH)
|
|
||||||
{
|
|
||||||
if(!IsValidSwitchTile((int)TileIndex))
|
|
||||||
ValidTile = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if((EntitiesModType == MAP_IMAGE_MOD_TYPE_RACE) && IsCreditsTile((int)TileIndex))
|
|
||||||
{
|
|
||||||
ValidTile = false;
|
|
||||||
}
|
|
||||||
else if((EntitiesModType == MAP_IMAGE_MOD_TYPE_FNG) && IsCreditsTile((int)TileIndex))
|
|
||||||
{
|
|
||||||
ValidTile = false;
|
|
||||||
}
|
|
||||||
else if((EntitiesModType == MAP_IMAGE_MOD_TYPE_VANILLA) && IsCreditsTile((int)TileIndex))
|
|
||||||
{
|
|
||||||
ValidTile = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else if((EntitiesModType == MAP_IMAGE_MOD_TYPE_RACE) && IsCreditsTile((int)TileIndex))
|
||||||
if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_SWITCH && TileIndex == TILE_SWITCHTIMEDOPEN)
|
|
||||||
TileIndex = 8;
|
|
||||||
|
|
||||||
int X = TileIndex % 16;
|
|
||||||
int Y = TileIndex / 16;
|
|
||||||
|
|
||||||
int CopyWidth = ImgInfo.m_Width / 16;
|
|
||||||
int CopyHeight = ImgInfo.m_Height / 16;
|
|
||||||
if(ValidTile)
|
|
||||||
{
|
{
|
||||||
Graphics()->CopyTextureBufferSub(pBuildImgData, pTmpImgData, ImgInfo.m_Width, ImgInfo.m_Height, PixelSize, (size_t)X * CopyWidth, (size_t)Y * CopyHeight, CopyWidth, CopyHeight);
|
ValidTile = false;
|
||||||
|
}
|
||||||
|
else if((EntitiesModType == MAP_IMAGE_MOD_TYPE_FNG) && IsCreditsTile((int)TileIndex))
|
||||||
|
{
|
||||||
|
ValidTile = false;
|
||||||
|
}
|
||||||
|
else if((EntitiesModType == MAP_IMAGE_MOD_TYPE_VANILLA) && IsCreditsTile((int)TileIndex))
|
||||||
|
{
|
||||||
|
ValidTile = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_aaEntitiesTextures[(EntitiesModType * 2) + (int)EntitiesAreMasked][n] = Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, pBuildImgData, TextureLoadFlag, aPath);
|
if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_SWITCH && TileIndex == TILE_SWITCHTIMEDOPEN)
|
||||||
}
|
TileIndex = 8;
|
||||||
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);
|
int X = TileIndex % 16;
|
||||||
|
int Y = TileIndex / 16;
|
||||||
|
|
||||||
|
int CopyWidth = ImgInfo.m_Width / 16;
|
||||||
|
int CopyHeight = ImgInfo.m_Height / 16;
|
||||||
|
if(ValidTile)
|
||||||
|
{
|
||||||
|
Graphics()->CopyTextureBufferSub(pBuildImgData, pTmpImgData, ImgInfo.m_Width, ImgInfo.m_Height, PixelSize, (size_t)X * CopyWidth, (size_t)Y * CopyHeight, CopyWidth, CopyHeight);
|
||||||
}
|
}
|
||||||
m_aaEntitiesTextures[(EntitiesModType * 2) + (int)EntitiesAreMasked][n] = m_TransparentTexture;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_aaEntitiesTextures[(EntitiesModType * 2) + (int)EntitiesAreMasked][n] = Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, pBuildImgData, TextureLoadFlag, aPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
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]));
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
|
Loading…
Reference in a new issue