@@ -124,7 +124,7 @@ void CChat::LoadCVars ( void )
124124 CVARS_GET ( " chat_line_life" , (unsigned int &)m_ulChatLineLife );
125125 CVARS_GET ( " chat_line_fade_out" , (unsigned int &)m_ulChatLineFadeOut );
126126 CVARS_GET ( " chat_font" , (unsigned int &)Font ); SetChatFont ( (eChatFont)Font );
127- CVARS_GET ( " chat_autocomplete" , m_bAutocomplete );
127+ CVARS_GET ( " chat_autocomplete" , m_bAutocomplete );
128128
129129 // Modify default chat box to be like 'Transparent' preset
130130 SString strFlags;
@@ -605,12 +605,14 @@ bool CChat::CharacterKeyHandler ( CGUIKeyEventArgs KeyboardArgs )
605605 bool bSuccess = false ;
606606
607607 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 );
614616
615617 CModManager* pModManager = CModManager::GetSingletonPtr ();
616618 if ( pModManager && pModManager->GetCurrentMod () )
@@ -650,20 +652,8 @@ bool CChat::CharacterKeyHandler ( CGUIKeyEventArgs KeyboardArgs )
650652 continue ;
651653 else
652654 {
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-
665655 // Check size if it's ok, then output
666- SString strOutput = strTmp + strPlayerName;
656+ SString strOutput = strCurrentInput. replace ( iFound, std::string::npos, strPlayerName ) ;
667657 if ( MbUTF8ToUTF16 ( strOutput ).size () < CHAT_MAX_CHAT_LENGTH )
668658 {
669659 bSuccess = true ;
0 commit comments