mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-20 15:08:19 +00:00
Fix skin load
This commit is contained in:
parent
cc115797b0
commit
532d845aed
|
@ -55,7 +55,7 @@ int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser)
|
||||||
return pSelf->LoadSkin(aNameWithoutPng, aBuf, DirType);
|
return pSelf->LoadSkin(aNameWithoutPng, aBuf, DirType);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CSkins::LoadSkin(const char *pName, const char *pPath, int DirType, int *pGetSkinID)
|
int CSkins::LoadSkin(const char *pName, const char *pPath, int DirType)
|
||||||
{
|
{
|
||||||
char aBuf[512];
|
char aBuf[512];
|
||||||
CImageInfo Info;
|
CImageInfo Info;
|
||||||
|
@ -172,10 +172,8 @@ int CSkins::LoadSkin(const char *pName, const char *pPath, int DirType, int *pGe
|
||||||
str_format(aBuf, sizeof(aBuf), "load skin %s", Skin.m_aName);
|
str_format(aBuf, sizeof(aBuf), "load skin %s", Skin.m_aName);
|
||||||
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "game", aBuf);
|
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "game", aBuf);
|
||||||
}
|
}
|
||||||
m_aSkins.add(Skin);
|
|
||||||
|
|
||||||
if(pGetSkinID)
|
m_aSkins.add(Skin);
|
||||||
*pGetSkinID = m_aSkins.size() - 1;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -293,20 +291,19 @@ int CSkins::FindImpl(const char *pName)
|
||||||
auto d = ::find_binary(m_aDownloadSkins.all(), pName);
|
auto d = ::find_binary(m_aDownloadSkins.all(), pName);
|
||||||
if(!d.empty())
|
if(!d.empty())
|
||||||
{
|
{
|
||||||
int SkinID = -1;
|
|
||||||
if(d.front().m_pTask && d.front().m_pTask->State() == HTTP_DONE)
|
if(d.front().m_pTask && d.front().m_pTask->State() == HTTP_DONE)
|
||||||
{
|
{
|
||||||
char aPath[MAX_PATH_LENGTH];
|
char aPath[MAX_PATH_LENGTH];
|
||||||
str_format(aPath, sizeof(aPath), "downloadedskins/%s.png", d.front().m_aName);
|
str_format(aPath, sizeof(aPath), "downloadedskins/%s.png", d.front().m_aName);
|
||||||
Storage()->RenameFile(d.front().m_aPath, aPath, IStorage::TYPE_SAVE);
|
Storage()->RenameFile(d.front().m_aPath, aPath, IStorage::TYPE_SAVE);
|
||||||
LoadSkin(d.front().m_aName, aPath, IStorage::TYPE_SAVE, &SkinID);
|
LoadSkin(d.front().m_aName, aPath, IStorage::TYPE_SAVE);
|
||||||
d.front().m_pTask = nullptr;
|
d.front().m_pTask = nullptr;
|
||||||
}
|
}
|
||||||
if(d.front().m_pTask && (d.front().m_pTask->State() == HTTP_ERROR || d.front().m_pTask->State() == HTTP_ABORTED))
|
if(d.front().m_pTask && (d.front().m_pTask->State() == HTTP_ERROR || d.front().m_pTask->State() == HTTP_ABORTED))
|
||||||
{
|
{
|
||||||
d.front().m_pTask = nullptr;
|
d.front().m_pTask = nullptr;
|
||||||
}
|
}
|
||||||
return SkinID;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
CDownloadSkin Skin;
|
CDownloadSkin Skin;
|
||||||
|
|
|
@ -35,7 +35,7 @@ private:
|
||||||
sorted_array<CDownloadSkin> m_aDownloadSkins;
|
sorted_array<CDownloadSkin> m_aDownloadSkins;
|
||||||
char m_EventSkinPrefix[24];
|
char m_EventSkinPrefix[24];
|
||||||
|
|
||||||
int LoadSkin(const char *pName, const char *pPath, int DirType, int *pGetSkinID = NULL);
|
int LoadSkin(const char *pName, const char *pPath, int DirType);
|
||||||
int FindImpl(const char *pName);
|
int FindImpl(const char *pName);
|
||||||
static int SkinScan(const char *pName, int IsDir, int DirType, void *pUser);
|
static int SkinScan(const char *pName, int IsDir, int DirType, void *pUser);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue