Merge pull request #637 from necropotame/pr-i636-memoryleak

Fixed memory leak after gametype change
This commit is contained in:
Dennis Felsing 2017-03-02 09:47:34 +01:00 committed by GitHub
commit acb1ada28c

View file

@ -91,7 +91,7 @@ int CMapImages::GetEntities()
{ {
CServerInfo Info; CServerInfo Info;
Client()->GetServerInfo(&Info); Client()->GetServerInfo(&Info);
if(m_EntitiesTextures == -1 || str_comp(m_aEntitiesGameType, Info.m_aGameType)) if(m_EntitiesTextures == -1 || str_comp(m_aEntitiesGameType, Info.m_aGameType))
{ {
// DDNet default to prevent delay in seeing entities // DDNet default to prevent delay in seeing entities
@ -109,6 +109,9 @@ int CMapImages::GetEntities()
char path[64]; char path[64];
str_format(path, sizeof(path), "editor/entities_clear/%s.png", file); str_format(path, sizeof(path), "editor/entities_clear/%s.png", file);
if(m_EntitiesTextures >= 0)
Graphics()->UnloadTexture(m_EntitiesTextures);
m_EntitiesTextures = Graphics()->LoadTexture(path, IStorage::TYPE_ALL, CImageInfo::FORMAT_AUTO, 0); m_EntitiesTextures = Graphics()->LoadTexture(path, IStorage::TYPE_ALL, CImageInfo::FORMAT_AUTO, 0);
str_copy(m_aEntitiesGameType, Info.m_aGameType, sizeof(m_aEntitiesGameType)); str_copy(m_aEntitiesGameType, Info.m_aGameType, sizeof(m_aEntitiesGameType));