@@ -124,7 +124,7 @@ void CChat::LoadCVars ( void )
124
124
CVARS_GET ( " chat_line_life" , (unsigned int &)m_ulChatLineLife );
125
125
CVARS_GET ( " chat_line_fade_out" , (unsigned int &)m_ulChatLineFadeOut );
126
126
CVARS_GET ( " chat_font" , (unsigned int &)Font ); SetChatFont ( (eChatFont)Font );
127
- CVARS_GET ( " chat_autocomplete" , m_bAutocomplete );
127
+ CVARS_GET ( " chat_autocomplete" , m_bAutocomplete );
128
128
129
129
// Modify default chat box to be like 'Transparent' preset
130
130
SString strFlags;
@@ -605,12 +605,14 @@ bool CChat::CharacterKeyHandler ( CGUIKeyEventArgs KeyboardArgs )
605
605
bool bSuccess = false ;
606
606
607
607
SString strCurrentInput = GetInputText ();
608
-
609
- std::vector<SString> vChatParts;
610
- strCurrentInput.Split ( " " , vChatParts );
611
- SString strPlayerNamePart = vChatParts.back ();
612
- if ( strPlayerNamePart.size () == 0 )
613
- break ;
608
+ size_t iFound;
609
+ iFound = strCurrentInput.find_last_of ( " " );
610
+ if ( iFound == std::string::npos )
611
+ iFound = 0 ;
612
+ else
613
+ ++iFound;
614
+
615
+ SString strPlayerNamePart = strCurrentInput.substr ( iFound );
614
616
615
617
CModManager* pModManager = CModManager::GetSingletonPtr ();
616
618
if ( pModManager && pModManager->GetCurrentMod () )
@@ -650,20 +652,8 @@ bool CChat::CharacterKeyHandler ( CGUIKeyEventArgs KeyboardArgs )
650
652
continue ;
651
653
else
652
654
{
653
- // Remove last part
654
- vChatParts.pop_back ();
655
-
656
- // Turn back into string
657
- SString strTmp;
658
- for ( std::vector<SString>::iterator _iter = vChatParts.begin ();
659
- _iter != vChatParts.end ();
660
- _iter++ )
661
- {
662
- strTmp += *_iter + " " ;
663
- }
664
-
665
655
// Check size if it's ok, then output
666
- SString strOutput = strTmp + strPlayerName;
656
+ SString strOutput = strCurrentInput. replace ( iFound, std::string::npos, strPlayerName ) ;
667
657
if ( MbUTF8ToUTF16 ( strOutput ).size () < CHAT_MAX_CHAT_LENGTH )
668
658
{
669
659
bSuccess = true ;
0 commit comments