mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
Simplify handling of entities paths, remove unnecessary variables
This commit is contained in:
parent
c97c3ac7b1
commit
29d924e061
|
@ -187,43 +187,30 @@ IGraphics::CTextureHandle CMapImages::GetEntities(EMapImageEntityLayerType Entit
|
||||||
{
|
{
|
||||||
m_aEntitiesIsLoaded[(EntitiesModType * 2) + (int)EntitiesAreMasked] = true;
|
m_aEntitiesIsLoaded[(EntitiesModType * 2) + (int)EntitiesAreMasked] = true;
|
||||||
|
|
||||||
char aPath[64];
|
|
||||||
str_format(aPath, sizeof(aPath), "%s/%s.png", m_aEntitiesPath, gs_apModEntitiesNames[EntitiesModType]);
|
|
||||||
|
|
||||||
int TextureLoadFlag = 0;
|
int TextureLoadFlag = 0;
|
||||||
if(Graphics()->HasTextureArraysSupport())
|
if(Graphics()->HasTextureArraysSupport())
|
||||||
TextureLoadFlag = (Graphics()->Uses2DTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE) | IGraphics::TEXLOAD_NO_2D_TEXTURE;
|
TextureLoadFlag = (Graphics()->Uses2DTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE) | IGraphics::TEXLOAD_NO_2D_TEXTURE;
|
||||||
|
|
||||||
CImageInfo ImgInfo;
|
CImageInfo ImgInfo;
|
||||||
bool ImagePNGLoaded = false;
|
char aPath[IO_MAX_PATH_LENGTH];
|
||||||
if(Graphics()->LoadPNG(&ImgInfo, aPath, IStorage::TYPE_ALL))
|
str_format(aPath, sizeof(aPath), "%s/%s.png", m_aEntitiesPath, gs_apModEntitiesNames[EntitiesModType]);
|
||||||
ImagePNGLoaded = true;
|
Graphics()->LoadPNG(&ImgInfo, aPath, IStorage::TYPE_ALL);
|
||||||
else
|
|
||||||
{
|
|
||||||
bool TryDefault = true;
|
|
||||||
// try as single ddnet replacement
|
|
||||||
if(EntitiesModType == MAP_IMAGE_MOD_TYPE_DDNET)
|
|
||||||
{
|
|
||||||
str_format(aPath, sizeof(aPath), "%s.png", m_aEntitiesPath);
|
|
||||||
if(Graphics()->LoadPNG(&ImgInfo, aPath, IStorage::TYPE_ALL))
|
|
||||||
{
|
|
||||||
ImagePNGLoaded = true;
|
|
||||||
TryDefault = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!ImagePNGLoaded && TryDefault)
|
// try as single ddnet replacement
|
||||||
{
|
if(ImgInfo.m_pData == nullptr && EntitiesModType == MAP_IMAGE_MOD_TYPE_DDNET)
|
||||||
// try default
|
{
|
||||||
str_format(aPath, sizeof(aPath), "editor/entities_clear/%s.png", gs_apModEntitiesNames[EntitiesModType]);
|
str_format(aPath, sizeof(aPath), "%s.png", m_aEntitiesPath);
|
||||||
if(Graphics()->LoadPNG(&ImgInfo, aPath, IStorage::TYPE_ALL))
|
Graphics()->LoadPNG(&ImgInfo, aPath, IStorage::TYPE_ALL);
|
||||||
{
|
|
||||||
ImagePNGLoaded = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ImagePNGLoaded && ImgInfo.m_Width > 0 && ImgInfo.m_Height > 0)
|
// try default
|
||||||
|
if(ImgInfo.m_pData == nullptr)
|
||||||
|
{
|
||||||
|
str_format(aPath, sizeof(aPath), "editor/entities_clear/%s.png", gs_apModEntitiesNames[EntitiesModType]);
|
||||||
|
Graphics()->LoadPNG(&ImgInfo, aPath, IStorage::TYPE_ALL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ImgInfo.m_pData != nullptr)
|
||||||
{
|
{
|
||||||
const size_t PixelSize = ImgInfo.PixelSize();
|
const size_t PixelSize = ImgInfo.PixelSize();
|
||||||
const size_t BuildImageSize = (size_t)ImgInfo.m_Width * ImgInfo.m_Height * PixelSize;
|
const size_t BuildImageSize = (size_t)ImgInfo.m_Width * ImgInfo.m_Height * PixelSize;
|
||||||
|
|
Loading…
Reference in a new issue