From 27425facffc62b6164d20ff2c1270f2f0d1abe23 Mon Sep 17 00:00:00 2001 From: oy Date: Fri, 24 Sep 2010 13:21:03 +0200 Subject: [PATCH] fixed last commit --- src/game/client/components/menus_settings.cpp | 19 +++++++++---------- src/game/client/components/skins.cpp | 4 +--- src/game/client/components/skins.h | 8 +++++--- src/game/variables.h | 2 +- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 33a5695ab..c8040bfa2 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -209,28 +209,27 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView) MainView.HSplitTop(MainView.h/2, 0, &MainView); // render skinselector - static const int s_MaxSkins = 256; - static const CSkins::CSkin *s_paSkinList[s_MaxSkins]; - static int s_NumSkins = -1; + static bool s_InitSkinlist = true; + static sorted_array s_paSkinList; static float s_ScrollValue = 0; - if(s_NumSkins == -1) + if(s_InitSkinlist) { - mem_zero(s_paSkinList, sizeof(s_paSkinList)); - s_NumSkins = 0; - for(int i = 0; i < m_pClient->m_pSkins->Num() && i < s_MaxSkins; ++i) + s_paSkinList.clear(); + for(int i = 0; i < m_pClient->m_pSkins->Num(); ++i) { const CSkins::CSkin *s = m_pClient->m_pSkins->Get(i); // no special skins if(s->m_aName[0] == 'x' && s->m_aName[1] == '_') continue; - s_paSkinList[s_NumSkins++] = s; + s_paSkinList.add(s); } + s_InitSkinlist = false; } int OldSelected = -1; - UiDoListboxStart(&s_NumSkins , &MainView, 50.0f, Localize("Skins"), "", s_NumSkins, 4, OldSelected, s_ScrollValue); + UiDoListboxStart(&s_InitSkinlist, &MainView, 50.0f, Localize("Skins"), "", s_paSkinList.size(), 4, OldSelected, s_ScrollValue); - for(int i = 0; i < s_NumSkins; ++i) + for(int i = 0; i < s_paSkinList.size(); ++i) { const CSkins::CSkin *s = s_paSkinList[i]; if(s == 0) diff --git a/src/game/client/components/skins.cpp b/src/game/client/components/skins.cpp index b5cb82395..757c20086 100644 --- a/src/game/client/components/skins.cpp +++ b/src/game/client/components/skins.cpp @@ -14,9 +14,7 @@ void CSkins::SkinScan(const char *pName, int IsDir, void *pUser) { CSkins *pSelf = (CSkins *)pUser; int l = str_length(pName); - if(l < 4 || IsDir) - return; - if(str_comp(pName+l-4, ".png") != 0) + if(l < 4 || IsDir || str_comp(pName+l-4, ".png") != 0) return; char aBuf[512]; diff --git a/src/game/client/components/skins.h b/src/game/client/components/skins.h index 08e8c5e02..e1000e3a0 100644 --- a/src/game/client/components/skins.h +++ b/src/game/client/components/skins.h @@ -1,7 +1,7 @@ #ifndef GAME_CLIENT_COMPONENTS_SKINS_H #define GAME_CLIENT_COMPONENTS_SKINS_H #include -#include +#include #include class CSkins : public CComponent @@ -12,8 +12,10 @@ public: { int m_OrgTexture; int m_ColorTexture; - char m_aName[32]; + char m_aName[24]; vec3 m_BloodColor; + + bool operator<(const CSkin &Other) { return str_comp(m_aName, Other.m_aName) < 0; } }; void Init(); @@ -24,7 +26,7 @@ public: int Find(const char *pName); private: - array m_aSkins; + sorted_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 0b3cb0140..0c646a0e7 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, 32, "default", CFGFLAG_CLIENT|CFGFLAG_SAVE, "Player skin") +MACRO_CONFIG_STR(PlayerSkin, player_skin, 24, "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")