From 8b8eb509612330c800e71b87e22e11ad32219911 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 9 Dec 2012 20:26:40 +0100 Subject: [PATCH] fixed ninja skin and skin part selection on missing part --- data/skins/eyes/x_ninja.png | Bin 0 -> 2829 bytes data/skins/x_ninja.skn | 21 +++++++++++++++ src/game/client/components/menus_settings.cpp | 14 +++++----- src/game/client/components/players.cpp | 20 ++++++++++++-- src/game/client/components/skins.cpp | 25 +++++++++++------- src/game/client/components/skins.h | 14 ++++++++-- src/game/client/gameclient.cpp | 19 ++++++++----- 7 files changed, 85 insertions(+), 28 deletions(-) create mode 100644 data/skins/eyes/x_ninja.png create mode 100644 data/skins/x_ninja.skn diff --git a/data/skins/eyes/x_ninja.png b/data/skins/eyes/x_ninja.png new file mode 100644 index 0000000000000000000000000000000000000000..329952c63586f04eb3381df5ac194a2aa20e6676 GIT binary patch literal 2829 zcmai0`8(8$7yj7CkS)8h&LFbWSR)3_5R*bg_LA&NgKHbxrLvCfX)J{bi6Ps~QkH3C z&AyE<7Z(viGiLa@-+$oyJm)>{^PKm6pL2dZPi|UYzW^2m0|0OVg*3f&&e(qeVm^n?zrIh3;%<>xCqb zerxdSCf`*)(gu$>*sSc8aLTplOIKTz)t^)OAP}1>o{&_o?u3MmGHG4@F|A|baL zI}eiuD!G!2f6Btk(TCfKWS#mdko&~^kM^R%m`?3L%!50f+?+)vbb9PA{dBu{Vkk;e zfEnur(v(rmwV0c`(bIpncA8SZjCjCd1~V$>G|TEet3H$Vi`eqEQPH6Anh6?<(AXM! zyPO)8hM0Q!jSFdPG*9wtJNSD1(YZ!vqj`)#?S2Nua$p0&vzzMsPOx;sWrh1zhU6)2 z8wQYAHKPub8&{V;aLPhPa+E;Lcf>2g`=*H%aUMxW;pK~GN{HLN)6@UF&GO|$S~PpN zzC@#TEVGup7X#NEQSGvObZcC`)frxBb9U~aukXHRV~Y+*|5S~bTi}IT6~Gl2uWA>s z1lI^hB@4!noK+P?M~p!!X!uOT+Yw=q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qd@%dwv-R& ze$jftL_pE*8=HUfWFGeS%Bz^<$e3t>~UNul) zt@BTUG~e51brl-%G0W;_%w7{l&LPK!Np&2_%ACX;gZ$Lm(?54+%yF?U7$=*7v3dgq z>PvmhoFiXO#;zQ*GZR4311EcX#Q=omrwrD;MZmdt;M2pflJ^FAO=|6|%dq4s z)a3L48;tw)21G*xe#O&LYt)!MO^uSNS-1sb^9W;|ZYg~wGRg^&mFijDEo(*m?&)Fd z@9Wc1Q|sE>3)U};^H>2Fx`d{|bPWxM;^P@I($j<8-5>J~${^ljZRU9dyL@4-4Gle` zqc-J+lpH`uSJy|V+cR&-bF`aCB(j#A3w1R$b?MPo9HrktIdSse5R#RZm7;v?*qE4@ z7kJluN?vGebO~&IeSKzX>Z5hwqeqHkl<$Nxvk{dfmLRRK-vl-(|Y^J59O+))_l(BFbC9F0oBp@JT;?Wg&Ap(KGXmonRajPREH*2h$?*2VL z?+iPt6uhQmVgwJ+25z9yo{_qz#9&QL&FYCq&9ngEoC*pHpG-Kqxb*${MX0S{mT3Z# z@TC&K90PfC;@um#x3_mi{&B&D#>U1sKOEs75jR`(z^^WbFt>=Usc+aPc%l@6>m@GZ zd3?as`eeJB@DC8jwYL|WuE=lW`4AGB8FqT9SuFKbUU3NIMo#0>*?=Ek$)C;7{gMn= z20tss2nt?1_+YPR$zyQc0VV&Kna9P|HC|VBclrZ#;=vdwYx3p&P_6_4g5Gs0C>3!t z{36wod>I&7TFP8rUUrE8oWgy*-4cks-~77rSX5X-!aOc64k2by%##89p zwF6ILDZOaY#_P_z@w`63)PWg&TRu7OWyc*>f5xBpfGC^J<0Z+PMjtm_pSkins->Get(i); // no special skins - if(s->m_aName[0] == 'x' && s->m_aName[1] == '_') - continue; - s_paSkinList.add(s); + if(s->m_Type == CSkins::SKINTYPE_STANDARD) + s_paSkinList.add(s); } s_InitSkinlist = false; } @@ -398,9 +397,8 @@ void CMenus::RenderSkinPartSelection(CUIRect MainView) { const CSkins::CSkinPart *s = m_pClient->m_pSkins->GetSkinPart(p, i); // no special skins - if(s->m_aName[0] == 'x' && s->m_aName[1] == '_') - continue; - s_paList[p].add(s); + if(s->m_Type == CSkins::SKINTYPE_STANDARD) + s_paList[p].add(s); } } s_InitSkinPartList = false; @@ -427,7 +425,7 @@ void CMenus::RenderSkinPartSelection(CUIRect MainView) CTeeRenderInfo Info; for(int j = 0; j < NUM_SKINPARTS; j++) { - int SkinPart = m_pClient->m_pSkins->FindSkinPart(j, gs_apSkinVariables[j]); + int SkinPart = m_pClient->m_pSkins->FindSkinPart(j, gs_apSkinVariables[j], false); const CSkins::CSkinPart *pSkinPart = m_pClient->m_pSkins->GetSkinPart(j, SkinPart); if(*gs_apUCCVariables[j]) { @@ -952,7 +950,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView) OwnSkinInfo.m_Size = 50.0f; for(int p = 0; p < NUM_SKINPARTS; p++) { - int SkinPart = m_pClient->m_pSkins->FindSkinPart(p, gs_apSkinVariables[p]); + int SkinPart = m_pClient->m_pSkins->FindSkinPart(p, gs_apSkinVariables[p], false); const CSkins::CSkinPart *pSkinPart = m_pClient->m_pSkins->GetSkinPart(p, SkinPart); if(*gs_apUCCVariables[p]) { diff --git a/src/game/client/components/players.cpp b/src/game/client/components/players.cpp index 1429c9075..a6d65a1b3 100644 --- a/src/game/client/components/players.cpp +++ b/src/game/client/components/players.cpp @@ -528,15 +528,31 @@ void CPlayers::OnRender() if(m_pClient->m_Snap.m_aCharacters[i].m_Cur.m_Weapon == WEAPON_NINJA) { // change the skin for the player to the ninja - int Skin = m_pClient->m_pSkins->Find("x_ninja"); + int Skin = m_pClient->m_pSkins->Find("x_ninja", true); if(Skin != -1) { const CSkins::CSkin *pNinja = m_pClient->m_pSkins->Get(Skin); for(int p = 0; p < NUM_SKINPARTS; p++) { - if(IsTeamplay) + /*if(IsTeamplay) m_aRenderInfo[i].m_aTextures[p] = pNinja->m_apParts[p]->m_ColorTexture; else + { + m_aRenderInfo[i].m_aTextures[p] = pNinja->m_apParts[p]->m_OrgTexture; + m_aRenderInfo[i].m_aColors[p] = vec4(1.0f, 1.0f, 1.0f, 1.0f); + }*/ + if(IsTeamplay) + { + m_aRenderInfo[i].m_aTextures[p] = pNinja->m_apParts[p]->m_ColorTexture; + int ColorVal = m_pClient->m_pSkins->GetTeamColor(true, pNinja->m_aPartColors[p], m_pClient->m_aClients[i].m_Team, p); + m_aRenderInfo[i].m_aColors[p] = m_pClient->m_pSkins->GetColorV4(ColorVal, p==SKINPART_TATTOO); + } + else if(pNinja->m_aUseCustomColors[p]) + { + m_aRenderInfo[i].m_aTextures[p] = pNinja->m_apParts[p]->m_ColorTexture; + m_aRenderInfo[i].m_aColors[p] = m_pClient->m_pSkins->GetColorV4(pNinja->m_aPartColors[p], p==SKINPART_TATTOO); + } + else { m_aRenderInfo[i].m_aTextures[p] = pNinja->m_apParts[p]->m_OrgTexture; m_aRenderInfo[i].m_aColors[p] = vec4(1.0f, 1.0f, 1.0f, 1.0f); diff --git a/src/game/client/components/skins.cpp b/src/game/client/components/skins.cpp index 2fbed0381..e958b6a48 100644 --- a/src/game/client/components/skins.cpp +++ b/src/game/client/components/skins.cpp @@ -86,6 +86,9 @@ int CSkins::SkinPartScan(const char *pName, int IsDir, int DirType, void *pUser) mem_free(Info.m_pData); // set skin part data + Part.m_Type = SKINTYPE_STANDARD; + if(pName[0] == 'x' && pName[1] == '_') + Part.m_Type = SKINTYPE_SPECIAL; str_copy(Part.m_aName, pName, min((int)sizeof(Part.m_aName),l-3)); if(g_Config.m_Debug) { @@ -104,13 +107,14 @@ int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser) if(l < 4 || IsDir || str_comp(pName+l-4, ".skn") != 0) return 0; - CSkin Skin = pSelf->m_DummySkin; - char aBuf[512]; str_format(aBuf, sizeof(aBuf), "skins/%s", pName); IOHANDLE File = pSelf->Storage()->OpenFile(aBuf, IOFLAG_READ, IStorage::TYPE_ALL); if(!File) return 0; + + CSkin Skin = pSelf->m_DummySkin; + bool SpecialSkin = pName[0] == 'x' & pName[1] == '_'; CLineReader LineReader; LineReader.Init(File); @@ -153,7 +157,7 @@ int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser) pVariable += str_length(apParts[Part]); if(str_comp(pVariable, "filename") == 0) { - int SkinPart = pSelf->FindSkinPart(Part, pValue); + int SkinPart = pSelf->FindSkinPart(Part, pValue, SpecialSkin); if(SkinPart < 0) continue; Skin.m_apParts[Part] = pSelf->GetSkinPart(Part, SkinPart); @@ -194,6 +198,7 @@ int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser) io_close(File); // set skin data + Skin.m_Type = SpecialSkin ? SKINTYPE_SPECIAL : SKINTYPE_STANDARD; str_copy(Skin.m_aName, pName, min((int)sizeof(Skin.m_aName),l-3)); if(g_Config.m_Debug) { @@ -231,6 +236,7 @@ void CSkins::OnInit() if(!m_aaSkinParts[p].size()) { CSkinPart DummySkinPart; + DummySkinPart.m_Type = SKINTYPE_STANDARD; str_copy(DummySkinPart.m_aName, "dummy", sizeof(DummySkinPart.m_aName)); DummySkinPart.m_BloodColor = vec3(1.0f, 1.0f, 1.0f); m_aaSkinParts[p].add(DummySkinPart); @@ -238,14 +244,15 @@ void CSkins::OnInit() } // create dummy skin + m_DummySkin.m_Type = SKINTYPE_STANDARD; str_copy(m_DummySkin.m_aName, "dummy", sizeof(m_DummySkin.m_aName)); for(int p = 0; p < NUM_SKINPARTS; p++) { int Default; if(p == SKINPART_TATTOO || p == SKINPART_DECORATION) - Default = FindSkinPart(p, ""); + Default = FindSkinPart(p, "", false); else - Default = FindSkinPart(p, "standard"); + Default = FindSkinPart(p, "standard", false); if(Default < 0) Default = 0; m_DummySkin.m_apParts[p] = GetSkinPart(p, Default); @@ -277,11 +284,11 @@ const CSkins::CSkin *CSkins::Get(int Index) return &m_aSkins[max(0, Index%m_aSkins.size())]; } -int CSkins::Find(const char *pName) +int CSkins::Find(const char *pName, bool AllowSpecialSkin) { for(int i = 0; i < m_aSkins.size(); i++) { - if(str_comp(m_aSkins[i].m_aName, pName) == 0) + if(str_comp(m_aSkins[i].m_aName, pName) == 0 && (m_aSkins[i].m_Type != SKINTYPE_SPECIAL || AllowSpecialSkin)) return i; } return -1; @@ -293,11 +300,11 @@ const CSkins::CSkinPart *CSkins::GetSkinPart(int Part, int Index) return &m_aaSkinParts[Part][max(0, Index%Size)]; } -int CSkins::FindSkinPart(int Part, const char *pName) +int CSkins::FindSkinPart(int Part, const char *pName, bool AllowSpecialPart) { for(int i = 0; i < m_aaSkinParts[Part].size(); i++) { - if(str_comp(m_aaSkinParts[Part][i].m_aName, pName) == 0) + if(str_comp(m_aaSkinParts[Part][i].m_aName, pName) == 0 && (m_aaSkinParts[Part][i].m_Type != SKINTYPE_SPECIAL || AllowSpecialPart)) return i; } return -1; diff --git a/src/game/client/components/skins.h b/src/game/client/components/skins.h index 442f07315..f7a43ad0a 100644 --- a/src/game/client/components/skins.h +++ b/src/game/client/components/skins.h @@ -25,18 +25,27 @@ enum class CSkins : public CComponent { public: + enum + { + SKINTYPE_STANDARD, + SKINTYPE_SPECIAL, + }; + struct CSkinPart { + int m_Type; char m_aName[24]; IGraphics::CTextureHandle m_OrgTexture; IGraphics::CTextureHandle m_ColorTexture; vec3 m_BloodColor; + bool operator<(const CSkinPart &Other) { return str_comp_nocase(m_aName, Other.m_aName) < 0; } }; struct CSkin { + int m_Type; char m_aName[24]; const CSkinPart *m_apParts[NUM_SKINPARTS]; int m_aPartColors[NUM_SKINPARTS]; @@ -50,9 +59,10 @@ public: int Num(); int NumSkinPart(int Part); const CSkin *Get(int Index); - int Find(const char *pName); + int Find(const char *pName, bool AllowSpecialSkin); const CSkinPart *GetSkinPart(int Part, int Index); - int FindSkinPart(int Part, const char *pName); + int FindSkinPart(int Part, const char *pName, bool AllowSpecialPart); + const CSkin *GetDummySkin() const { return &m_DummySkin; } vec3 GetColorV3(int v) const; vec4 GetColorV4(int v, bool UseAlpha) const; diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index ce2b4fe9f..a7ca2d2dc 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -1326,16 +1326,21 @@ void CGameClient::CClientData::UpdateRenderInfo(CGameClient *pGameClient, bool U for(int p = 0; p < NUM_SKINPARTS; p++) { - if(m_aaSkinPartNames[p][0] == 'x' && m_aaSkinPartNames[p][1] == '_') - str_copy(m_aaSkinPartNames[p], "default", 24); - - m_SkinPartIDs[p] = pGameClient->m_pSkins->FindSkinPart(p, m_aaSkinPartNames[p]); - if(m_SkinPartIDs[p] < 0) + int ID = pGameClient->m_pSkins->FindSkinPart(p, m_aaSkinPartNames[p], false); + if(ID < 0) { - m_SkinPartIDs[p] = pGameClient->m_pSkins->Find("default"); - if(m_SkinPartIDs[p] < 0) + if(p == SKINPART_TATTOO || p == SKINPART_DECORATION) + ID = pGameClient->m_pSkins->FindSkinPart(p, "", false); + else + ID = pGameClient->m_pSkins->FindSkinPart(p, "standard", false); + + if(ID < 0) m_SkinPartIDs[p] = 0; + else + m_SkinPartIDs[p] = ID; } + else + m_SkinPartIDs[p] = ID; const CSkins::CSkinPart *pSkinPart = pGameClient->m_pSkins->GetSkinPart(p, m_SkinPartIDs[p]); if(m_aUseCustomColors[p])