mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +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;
|
||||
if(LoadPNG(&Img, pFilename, StorageType))
|
||||
{
|
||||
IGraphics::CTextureHandle ID = LoadTextureRaw(Img.m_Width, Img.m_Height, Img.m_Format, Img.m_pData, Flags, pFilename);
|
||||
free(Img.m_pData);
|
||||
if(ID.Id() != m_InvalidTexture.Id() && g_Config.m_Debug)
|
||||
dbg_msg("graphics/texture", "loaded %s", pFilename);
|
||||
return ID;
|
||||
CTextureHandle ID = LoadTextureRaw(Img.m_Width, Img.m_Height, Img.m_Format, Img.m_pData, Flags, pFilename);
|
||||
FreePNG(&Img);
|
||||
if(ID.IsValid())
|
||||
{
|
||||
if(g_Config.m_Debug)
|
||||
dbg_msg("graphics/texture", "loaded %s", pFilename);
|
||||
return ID;
|
||||
}
|
||||
}
|
||||
|
||||
return m_InvalidTexture;
|
||||
|
|
Loading…
Reference in a new issue