diff options
| author | oy <Tom_Adams@web.de> | 2011-02-13 13:58:59 +0100 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2011-02-13 13:58:59 +0100 |
| commit | 09cd38d3207fb619022d1cda157ecb1504600513 (patch) | |
| tree | be7ec495e97a1df81ded86391ddd9deea2052055 /src/game/client/components | |
| parent | 825eca4bab1ea0dbdd401ed96d390390ca108638 (diff) | |
| download | zcatch-09cd38d3207fb619022d1cda157ecb1504600513.tar.gz zcatch-09cd38d3207fb619022d1cda157ecb1504600513.zip | |
cleaned up skin initialisation
Diffstat (limited to 'src/game/client/components')
| -rw-r--r-- | src/game/client/components/skins.cpp | 63 | ||||
| -rw-r--r-- | src/game/client/components/skins.h | 2 |
2 files changed, 31 insertions, 34 deletions
diff --git a/src/game/client/components/skins.cpp b/src/game/client/components/skins.cpp index d89d0647..d24e36f0 100644 --- a/src/game/client/components/skins.cpp +++ b/src/game/client/components/skins.cpp @@ -65,42 +65,39 @@ void CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser) } - if(1) - { - int Freq[256] = {0}; - int OrgWeight = 0; - int NewWeight = 192; + 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++) - { - if(d[y*Pitch+x*4+3] > 128) - Freq[d[y*Pitch+x*4]]++; - } - - for(int i = 1; i < 256; i++) + // find most common frequence + for(int y = 0; y < BodySize; y++) + for(int x = 0; x < BodySize; x++) { - if(Freq[OrgWeight] < Freq[i]) - OrgWeight = i; + if(d[y*Pitch+x*4+3] > 128) + Freq[d[y*Pitch+x*4]]++; } - - // reorder - int InvOrgWeight = 255-OrgWeight; - int InvNewWeight = 255-NewWeight; - for(int y = 0; y < BodySize; y++) - for(int x = 0; x < BodySize; x++) - { - int v = d[y*Pitch+x*4]; - if(v <= OrgWeight) - v = (int)(((v/(float)OrgWeight) * NewWeight)); - else - v = (int)(((v-OrgWeight)/(float)InvOrgWeight)*InvNewWeight + NewWeight); - d[y*Pitch+x*4] = v; - d[y*Pitch+x*4+1] = v; - d[y*Pitch+x*4+2] = v; - } + + for(int i = 1; i < 256; i++) + { + if(Freq[OrgWeight] < Freq[i]) + OrgWeight = i; } + + // reorder + int InvOrgWeight = 255-OrgWeight; + int InvNewWeight = 255-NewWeight; + for(int y = 0; y < BodySize; y++) + for(int x = 0; x < BodySize; x++) + { + int v = d[y*Pitch+x*4]; + if(v <= OrgWeight) + v = (int)(((v/(float)OrgWeight) * NewWeight)); + else + v = (int)(((v-OrgWeight)/(float)InvOrgWeight)*InvNewWeight + NewWeight); + d[y*Pitch+x*4] = v; + 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); @@ -113,7 +110,7 @@ void CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser) } -void CSkins::Init() +void CSkins::OnInit() { // load skins m_aSkins.clear(); diff --git a/src/game/client/components/skins.h b/src/game/client/components/skins.h index 9e20ba37..5305fa2b 100644 --- a/src/game/client/components/skins.h +++ b/src/game/client/components/skins.h @@ -20,7 +20,7 @@ public: bool operator<(const CSkin &Other) { return str_comp(m_aName, Other.m_aName) < 0; } }; - void Init(); + void OnInit(); vec3 GetColorV3(int v); vec4 GetColorV4(int v); |