Fix skin load

This commit is contained in:
Jupeyy 2020-11-02 21:21:57 +01:00
parent cc115797b0
commit 532d845aed
2 changed files with 5 additions and 8 deletions

View file

@ -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;

View file

@ -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);
}; };