diff --git a/src/game/client/components/skins.cpp b/src/game/client/components/skins.cpp
index 73cf954da..b5cb82395 100644
--- a/src/game/client/components/skins.cpp
+++ b/src/game/client/components/skins.cpp
@@ -10,16 +10,11 @@
#include "skins.h"
-CSkins::CSkins()
-{
- m_NumSkins = 0;
-}
-
void CSkins::SkinScan(const char *pName, int IsDir, void *pUser)
{
CSkins *pSelf = (CSkins *)pUser;
int l = str_length(pName);
- if(l < 4 || IsDir || pSelf->m_NumSkins == MAX_SKINS)
+ if(l < 4 || IsDir)
return;
if(str_comp(pName+l-4, ".png") != 0)
return;
@@ -34,7 +29,8 @@ void CSkins::SkinScan(const char *pName, int IsDir, void *pUser)
return;
}
- pSelf->m_aSkins[pSelf->m_NumSkins].m_OrgTexture = pSelf->Graphics()->LoadTextureRaw(Info.m_Width, Info.m_Height, Info.m_Format, Info.m_pData, Info.m_Format, 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;
@@ -54,7 +50,7 @@ void CSkins::SkinScan(const char *pName, int IsDir, void *pUser)
}
}
- pSelf->m_aSkins[pSelf->m_NumSkins].m_BloodColor = normalize(vec3(aColors[0], aColors[1], aColors[2]));
+ Skin.m_BloodColor = normalize(vec3(aColors[0], aColors[1], aColors[2]));
}
// create colorless version
@@ -107,37 +103,37 @@ void CSkins::SkinScan(const char *pName, int IsDir, void *pUser)
}
}
- pSelf->m_aSkins[pSelf->m_NumSkins].m_ColorTexture = pSelf->Graphics()->LoadTextureRaw(Info.m_Width, Info.m_Height, Info.m_Format, Info.m_pData, Info.m_Format, 0);
+ 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
- str_copy(pSelf->m_aSkins[pSelf->m_NumSkins].m_aName, pName, min((int)sizeof(pSelf->m_aSkins[pSelf->m_NumSkins].m_aName),l-3));
- str_format(aBuf, sizeof(aBuf), "load skin %s", pSelf->m_aSkins[pSelf->m_NumSkins].m_aName);
+ 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);
- pSelf->m_NumSkins++;
+ pSelf->m_aSkins.add(Skin);
}
void CSkins::Init()
{
// load skins
- m_NumSkins = 0;
+ m_aSkins.clear();
Storage()->ListDirectory(IStorage::TYPE_ALL, "skins", SkinScan, this);
}
int CSkins::Num()
{
- return m_NumSkins;
+ return m_aSkins.size();
}
const CSkins::CSkin *CSkins::Get(int Index)
{
- return &m_aSkins[Index%m_NumSkins];
+ return &m_aSkins[Index%m_aSkins.size()];
}
int CSkins::Find(const char *pName)
{
- for(int i = 0; i < m_NumSkins; i++)
+ for(int i = 0; i < m_aSkins.size(); i++)
{
if(str_comp(m_aSkins[i].m_aName, pName) == 0)
return i;
diff --git a/src/game/client/components/skins.h b/src/game/client/components/skins.h
index f733140f7..08e8c5e02 100644
--- a/src/game/client/components/skins.h
+++ b/src/game/client/components/skins.h
@@ -1,6 +1,7 @@
#ifndef GAME_CLIENT_COMPONENTS_SKINS_H
#define GAME_CLIENT_COMPONENTS_SKINS_H
#include
+#include
#include
class CSkins : public CComponent
@@ -11,12 +12,9 @@ public:
{
int m_OrgTexture;
int m_ColorTexture;
- char m_aName[31];
- char m_aTerm[1];
+ char m_aName[32];
vec3 m_BloodColor;
- } ;
-
- CSkins();
+ };
void Init();
@@ -26,13 +24,7 @@ public:
int Find(const char *pName);
private:
- enum
- {
- MAX_SKINS=256,
- };
-
- CSkin m_aSkins[MAX_SKINS];
- int m_NumSkins;
+ array m_aSkins;
static void SkinScan(const char *pName, int IsDir, void *pUser);
};
diff --git a/src/game/variables.h b/src/game/variables.h
index 6a247671b..0b3cb0140 100644
--- a/src/game/variables.h
+++ b/src/game/variables.h
@@ -34,7 +34,7 @@ MACRO_CONFIG_STR(ClLanguagefile, cl_languagefile, 255, "", CFGFLAG_CLIENT|CFGFLA
MACRO_CONFIG_INT(PlayerUseCustomColor, player_use_custom_color, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Toggles usage of custom colors")
MACRO_CONFIG_INT(PlayerColorBody, player_color_body, 65408, 0, 0xFFFFFF, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Player body color")
MACRO_CONFIG_INT(PlayerColorFeet, player_color_feet, 65408, 0, 0xFFFFFF, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Player feet color")
-MACRO_CONFIG_STR(PlayerSkin, player_skin, 64, "default", CFGFLAG_CLIENT|CFGFLAG_SAVE, "Player skin")
+MACRO_CONFIG_STR(PlayerSkin, player_skin, 32, "default", CFGFLAG_CLIENT|CFGFLAG_SAVE, "Player skin")
MACRO_CONFIG_INT(UiPage, ui_page, 5, 0, 9, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Interface page")
MACRO_CONFIG_INT(UiToolboxPage, ui_toolbox_page, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Toolbox page")