mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-12 19:18:20 +00:00
Fix check for invalid texture after LoadTextureRaw
The handle returned by `LoadTextureRaw` is either valid or invalid (i.e. `-1`) but never the invalid texture itself. Additionally, ensure that the `LoadTexture` function returns the invalid texture also when `LoadTextureRaw` fails.
This commit is contained in:
parent
07e336e0f4
commit
fdaa343219
|
@ -482,11 +482,14 @@ IGraphics::CTextureHandle CGraphics_Threaded::LoadTexture(const char *pFilename,
|
||||||
CImageInfo Img;
|
CImageInfo Img;
|
||||||
if(LoadPNG(&Img, pFilename, StorageType))
|
if(LoadPNG(&Img, pFilename, StorageType))
|
||||||
{
|
{
|
||||||
IGraphics::CTextureHandle ID = LoadTextureRaw(Img.m_Width, Img.m_Height, Img.m_Format, Img.m_pData, Flags, pFilename);
|
CTextureHandle ID = LoadTextureRaw(Img.m_Width, Img.m_Height, Img.m_Format, Img.m_pData, Flags, pFilename);
|
||||||
free(Img.m_pData);
|
FreePNG(&Img);
|
||||||
if(ID.Id() != m_InvalidTexture.Id() && g_Config.m_Debug)
|
if(ID.IsValid())
|
||||||
dbg_msg("graphics/texture", "loaded %s", pFilename);
|
{
|
||||||
return ID;
|
if(g_Config.m_Debug)
|
||||||
|
dbg_msg("graphics/texture", "loaded %s", pFilename);
|
||||||
|
return ID;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_InvalidTexture;
|
return m_InvalidTexture;
|
||||||
|
|
Loading…
Reference in a new issue