diff options
Diffstat (limited to 'src/game/client/components/skins.cpp')
| -rw-r--r-- | src/game/client/components/skins.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/game/client/components/skins.cpp b/src/game/client/components/skins.cpp index d8550da4..dd38e9ea 100644 --- a/src/game/client/components/skins.cpp +++ b/src/game/client/components/skins.cpp @@ -10,13 +10,13 @@ #include "skins.h" -int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser) +int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser) { CSkins *pSelf = (CSkins *)pUser; int l = str_length(pName); if(l < 4 || IsDir || str_comp(pName+l-4, ".png") != 0) return 0; - + char aBuf[512]; str_format(aBuf, sizeof(aBuf), "skins/%s", pName); CImageInfo Info; @@ -26,10 +26,10 @@ int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser) pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "game", aBuf); return 0; } - + CSkin Skin; Skin.m_OrgTexture = pSelf->Graphics()->LoadTextureRaw(Info.m_Width, Info.m_Height, Info.m_Format, Info.m_pData, Info.m_Format, 0); - + int BodySize = 96; // body size unsigned char *d = (unsigned char *)Info.m_pData; int Pitch = Info.m_Width*4; @@ -47,10 +47,10 @@ int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser) aColors[2] += d[y*Pitch+x*4+2]; } } - + Skin.m_BloodColor = normalize(vec3(aColors[0], aColors[1], aColors[2])); } - + // create colorless version int Step = Info.m_Format == CImageInfo::FORMAT_RGBA ? 4 : 3; @@ -63,11 +63,11 @@ int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser) d[i*Step+2] = v; } - + int Freq[256] = {0}; int OrgWeight = 0; int NewWeight = 192; - + // find most common frequence for(int y = 0; y < BodySize; y++) for(int x = 0; x < BodySize; x++) @@ -75,7 +75,7 @@ int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser) if(d[y*Pitch+x*4+3] > 128) Freq[d[y*Pitch+x*4]]++; } - + for(int i = 1; i < 256; i++) { if(Freq[OrgWeight] < Freq[i]) @@ -97,11 +97,11 @@ int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser) d[y*Pitch+x*4+1] = v; d[y*Pitch+x*4+2] = v; } - + Skin.m_ColorTexture = pSelf->Graphics()->LoadTextureRaw(Info.m_Width, Info.m_Height, Info.m_Format, Info.m_pData, Info.m_Format, 0); mem_free(Info.m_pData); - // set skin data + // set skin data str_copy(Skin.m_aName, pName, min((int)sizeof(Skin.m_aName),l-3)); str_format(aBuf, sizeof(aBuf), "load skin %s", Skin.m_aName); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "game", aBuf); @@ -130,7 +130,7 @@ void CSkins::OnInit() int CSkins::Num() { - return m_aSkins.size(); + return m_aSkins.size(); } const CSkins::CSkin *CSkins::Get(int Index) |