@@ -45,41 +45,26 @@ void CSkinProfiles::AddProfile(int BodyColor, int FeetColor, int CountryFlag, in
4545
4646void 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
8570void CSkinProfiles::ConfigSaveCallback (IConfigManager *pConfigManager, void *pUserData)
0 commit comments