Skip to content

Commit b10c64b

Browse files
committed
Fix profiles changing in parts
1 parent df754d8 commit b10c64b

File tree

2 files changed

+14
-27
lines changed

2 files changed

+14
-27
lines changed

src/game/client/components/skins.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,5 +329,7 @@ class CSkins : public CComponent
329329
static void ConfigSaveCallback(IConfigManager *pConfigManager, void *pUserData);
330330
void OnConfigSave(IConfigManager *pConfigManager);
331331
static void ConchainRefreshSkinList(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
332+
333+
friend class CSkinProfiles;
332334
};
333335
#endif

src/game/client/components/tclient/skinprofiles.cpp

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -45,41 +45,26 @@ void CSkinProfiles::AddProfile(int BodyColor, int FeetColor, int CountryFlag, in
4545

4646
void CSkinProfiles::ApplyProfile(int Dummy, const CProfile &Profile)
4747
{
48-
char aCommand[2048] = "";
49-
auto AddPart = [&](const char *pName, const char *pValue) {
50-
str_append(aCommand, Dummy ? "dummy" : "player");
51-
str_append(aCommand, "_");
52-
str_append(aCommand, pName);
53-
str_append(aCommand, " \"");
54-
char *pDst = aCommand + str_length(aCommand);
55-
str_escape(&pDst, pValue, aCommand + sizeof(aCommand) - 1); // 1 extra for end quote
56-
str_append(aCommand, "\";");
57-
};
58-
auto AddPartNumber = [&](const char *pName, int Value) {
59-
str_append(aCommand, Dummy ? "dummy" : "player");
60-
str_append(aCommand, "_");
61-
str_append(aCommand, pName);
62-
str_append(aCommand, " ");
63-
int Length = str_length(aCommand);
64-
str_format(aCommand + Length, sizeof(aCommand) - Length, "%d", Value);
65-
str_append(aCommand, ";");
66-
};
6748
if(g_Config.m_TcProfileSkin && strlen(Profile.m_SkinName) != 0)
68-
AddPart("skin", Profile.m_SkinName);
49+
str_copy(Dummy ? g_Config.m_ClDummySkin : g_Config.m_ClPlayerSkin, Profile.m_SkinName);
6950
if(g_Config.m_TcProfileColors && Profile.m_BodyColor != -1 && Profile.m_FeetColor != -1)
7051
{
71-
AddPartNumber("color_body", Profile.m_BodyColor);
72-
AddPartNumber("color_feet", Profile.m_FeetColor);
52+
(Dummy ? g_Config.m_ClDummyColorBody : g_Config.m_ClPlayerColorBody) = Profile.m_BodyColor;
53+
(Dummy ? g_Config.m_ClDummyColorFeet : g_Config.m_ClPlayerColorFeet) = Profile.m_FeetColor;
7354
}
7455
if(g_Config.m_TcProfileEmote && Profile.m_Emote != -1)
75-
AddPartNumber("default_eyes", Profile.m_Emote);
56+
(Dummy ? g_Config.m_ClDummyDefaultEyes : g_Config.m_ClPlayerDefaultEyes) = Profile.m_Emote;
7657
if(g_Config.m_TcProfileName && strlen(Profile.m_Name) != 0)
77-
AddPart("name", Profile.m_Name);
58+
str_copy(Dummy ? g_Config.m_ClDummyName : g_Config.m_PlayerName, Profile.m_SkinName); // TODO m_ClPlayerName
7859
if(g_Config.m_TcProfileClan && (strlen(Profile.m_Clan) != 0 || g_Config.m_TcProfileOverwriteClanWithEmpty))
79-
AddPart("clan", Profile.m_Clan);
60+
str_copy(Dummy ? g_Config.m_ClDummyClan : g_Config.m_PlayerClan, Profile.m_Clan); // TODO m_ClPlayerClan
8061
if(g_Config.m_TcProfileFlag && Profile.m_CountryFlag != -2)
81-
AddPartNumber("country", Profile.m_CountryFlag);
82-
Console()->ExecuteLine(aCommand);
62+
(Dummy ? g_Config.m_ClDummyCountry : g_Config.m_PlayerCountry) = Profile.m_CountryFlag;
63+
GameClient()->m_Skins.m_SkinList.ForceRefresh(); // Prevent segfault
64+
if(Dummy)
65+
GameClient()->SendDummyInfo(false);
66+
else
67+
GameClient()->SendInfo(false);
8368
}
8469

8570
void CSkinProfiles::ConfigSaveCallback(IConfigManager *pConfigManager, void *pUserData)

0 commit comments

Comments
 (0)