|
|
@ -241,7 +241,7 @@ CClientChatManager::CClientChatManager()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------
|
|
|
|
//-------------------------------------------------------
|
|
|
|
const ucstring *CClientChatManager::cycleLastTell()
|
|
|
|
const string *CClientChatManager::cycleLastTell()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (_TellPeople.empty()) return NULL;
|
|
|
|
if (_TellPeople.empty()) return NULL;
|
|
|
|
_TellPeople.push_front(_TellPeople.back());
|
|
|
|
_TellPeople.push_front(_TellPeople.back());
|
|
|
@ -282,14 +282,14 @@ void CClientChatManager::init( const string& /* staticDBFileName */ )
|
|
|
|
// chat
|
|
|
|
// chat
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//-----------------------------------------------
|
|
|
|
//-----------------------------------------------
|
|
|
|
void CClientChatManager::chat( const ucstring& strIn, bool isChatTeam )
|
|
|
|
void CClientChatManager::chat( const string& strIn, bool isChatTeam )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Truncate to 255 chars max (because of server restriction)
|
|
|
|
// Truncate to 255 chars max (because of server restriction)
|
|
|
|
ucstring str= strIn.substr(0,255);
|
|
|
|
ucstring str= ucstring(strIn).substr(0,255); // FIXME: UTF-8 (serial)
|
|
|
|
|
|
|
|
|
|
|
|
// send str to IOS
|
|
|
|
// send str to IOS
|
|
|
|
CBitMemStream bms;
|
|
|
|
CBitMemStream bms;
|
|
|
|
string msgType;
|
|
|
|
const char *msgType;
|
|
|
|
|
|
|
|
|
|
|
|
if (isChatTeam)
|
|
|
|
if (isChatTeam)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -303,13 +303,13 @@ void CClientChatManager::chat( const ucstring& strIn, bool isChatTeam )
|
|
|
|
|
|
|
|
|
|
|
|
if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) )
|
|
|
|
if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bms.serial( str );
|
|
|
|
bms.serial( str ); // FIXME: UTF-8 (serial)
|
|
|
|
NetMngr.push( bms );
|
|
|
|
NetMngr.push( bms );
|
|
|
|
//nlinfo("impulseCallBack : %s %s sent", msgType.c_str(), str.toString().c_str());
|
|
|
|
//nlinfo("impulseCallBack : %s %s sent", msgType.c_str(), str.toString().c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
nlwarning("<CClientChatManager::chat> unknown message name : %s", msgType.c_str());
|
|
|
|
nlwarning("<CClientChatManager::chat> unknown message name : %s", msgType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (UserEntity != NULL) UserEntity->setAFK(false);
|
|
|
|
if (UserEntity != NULL) UserEntity->setAFK(false);
|
|
|
@ -321,11 +321,11 @@ void CClientChatManager::chat( const ucstring& strIn, bool isChatTeam )
|
|
|
|
// tell
|
|
|
|
// tell
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//-----------------------------------------------
|
|
|
|
//-----------------------------------------------
|
|
|
|
void CClientChatManager::tell( const string& receiverIn, const ucstring& strIn )
|
|
|
|
void CClientChatManager::tell( const string& receiverIn, const string& strIn )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Truncate to 255 chars max (because of server restriction)
|
|
|
|
// Truncate to 255 chars max (because of server restriction)
|
|
|
|
string receiver= receiverIn.substr(0,255);
|
|
|
|
string receiver= receiverIn.substr(0,255); // FIXME: UTF-8 (serial)
|
|
|
|
ucstring str= strIn.substr(0,255);
|
|
|
|
ucstring str= ucstring(strIn).substr(0,255); // FIXME: UTF-8 (serial)
|
|
|
|
|
|
|
|
|
|
|
|
// *** send str
|
|
|
|
// *** send str
|
|
|
|
CBitMemStream bms;
|
|
|
|
CBitMemStream bms;
|
|
|
@ -333,7 +333,7 @@ void CClientChatManager::tell( const string& receiverIn, const ucstring& strIn )
|
|
|
|
if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) )
|
|
|
|
if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bms.serial( receiver );
|
|
|
|
bms.serial( receiver );
|
|
|
|
bms.serial( str );
|
|
|
|
bms.serial( str ); // FIXME: UTF-8
|
|
|
|
NetMngr.push( bms );
|
|
|
|
NetMngr.push( bms );
|
|
|
|
//nlinfo("impulseCallBack : %s %s %s sent", msgType.c_str(), receiver.c_str(), str.toString().c_str());
|
|
|
|
//nlinfo("impulseCallBack : %s %s %s sent", msgType.c_str(), receiver.c_str(), str.toString().c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -345,10 +345,10 @@ void CClientChatManager::tell( const string& receiverIn, const ucstring& strIn )
|
|
|
|
|
|
|
|
|
|
|
|
// *** manage list of last telled people
|
|
|
|
// *** manage list of last telled people
|
|
|
|
// remove the telled people from list (if present)
|
|
|
|
// remove the telled people from list (if present)
|
|
|
|
std::list<ucstring>::iterator it = _TellPeople.begin();
|
|
|
|
std::list<string>::iterator it = _TellPeople.begin();
|
|
|
|
while(it != _TellPeople.end())
|
|
|
|
while(it != _TellPeople.end())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (*it == ucstring(receiver))
|
|
|
|
if (*it == receiver)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
it = _TellPeople.erase(it);
|
|
|
|
it = _TellPeople.erase(it);
|
|
|
|
nlassert(_NumTellPeople != 0);
|
|
|
|
nlassert(_NumTellPeople != 0);
|
|
|
@ -454,14 +454,14 @@ void CClientChatManager::processTellString(NLMISC::CBitMemStream& bms, IChatDisp
|
|
|
|
// Serial. For tell message, there is no chat mode, coz we know we are in tell mode !
|
|
|
|
// Serial. For tell message, there is no chat mode, coz we know we are in tell mode !
|
|
|
|
bms.serial (chatMsg.CompressedIndex);
|
|
|
|
bms.serial (chatMsg.CompressedIndex);
|
|
|
|
bms.serial (chatMsg.SenderNameId);
|
|
|
|
bms.serial (chatMsg.SenderNameId);
|
|
|
|
bms.serial (chatMsg.Content);
|
|
|
|
bms.serial (chatMsg.Content); // FIXME: UTF-8 (serial)
|
|
|
|
|
|
|
|
|
|
|
|
if (PermanentlyBanned) return;
|
|
|
|
if (PermanentlyBanned) return;
|
|
|
|
|
|
|
|
|
|
|
|
chatMsg.ChatMode = (uint8) CChatGroup::tell;
|
|
|
|
chatMsg.ChatMode = (uint8) CChatGroup::tell;
|
|
|
|
|
|
|
|
|
|
|
|
// If !complete, wait
|
|
|
|
// If !complete, wait
|
|
|
|
ucstring senderStr;
|
|
|
|
string senderStr;
|
|
|
|
bool complete = true;
|
|
|
|
bool complete = true;
|
|
|
|
complete &= STRING_MANAGER::CStringManagerClient::instance()->getString(chatMsg.SenderNameId, senderStr);
|
|
|
|
complete &= STRING_MANAGER::CStringManagerClient::instance()->getString(chatMsg.SenderNameId, senderStr);
|
|
|
|
if (!complete)
|
|
|
|
if (!complete)
|
|
|
@ -472,8 +472,8 @@ void CClientChatManager::processTellString(NLMISC::CBitMemStream& bms, IChatDisp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// display
|
|
|
|
// display
|
|
|
|
ucstring ucstr;
|
|
|
|
string ucstr;
|
|
|
|
buildTellSentence(senderStr, chatMsg.Content, ucstr);
|
|
|
|
buildTellSentence(senderStr, chatMsg.Content.toUtf8(), ucstr);
|
|
|
|
chatDisplayer.displayTell(/*chatMsg.CompressedIndex, */ucstr, senderStr);
|
|
|
|
chatDisplayer.displayTell(/*chatMsg.CompressedIndex, */ucstr, senderStr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -488,9 +488,9 @@ void CClientChatManager::processFarTellString(NLMISC::CBitMemStream& bms, IChatD
|
|
|
|
if (PermanentlyBanned) return;
|
|
|
|
if (PermanentlyBanned) return;
|
|
|
|
|
|
|
|
|
|
|
|
// display
|
|
|
|
// display
|
|
|
|
ucstring ucstr;
|
|
|
|
string ucstr;
|
|
|
|
buildTellSentence(farTellMsg.SenderName, farTellMsg.Text, ucstr);
|
|
|
|
buildTellSentence(farTellMsg.SenderName.toUtf8(), farTellMsg.Text.toUtf8(), ucstr);
|
|
|
|
chatDisplayer.displayTell(/*chatMsg.CompressedIndex, */ucstr, farTellMsg.SenderName);
|
|
|
|
chatDisplayer.displayTell(/*chatMsg.CompressedIndex, */ucstr, farTellMsg.SenderName.toUtf8());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -505,7 +505,7 @@ void CClientChatManager::processChatString( NLMISC::CBitMemStream& bms, IChatDis
|
|
|
|
CChatMsg chatMsg;
|
|
|
|
CChatMsg chatMsg;
|
|
|
|
bms.serial( chatMsg );
|
|
|
|
bms.serial( chatMsg );
|
|
|
|
CChatGroup::TGroupType type = static_cast<CChatGroup::TGroupType>(chatMsg.ChatMode);
|
|
|
|
CChatGroup::TGroupType type = static_cast<CChatGroup::TGroupType>(chatMsg.ChatMode);
|
|
|
|
ucstring senderStr;
|
|
|
|
string senderStr;
|
|
|
|
|
|
|
|
|
|
|
|
bool complete = true;
|
|
|
|
bool complete = true;
|
|
|
|
complete &= STRING_MANAGER::CStringManagerClient::instance()->getString(chatMsg.SenderNameId, senderStr);
|
|
|
|
complete &= STRING_MANAGER::CStringManagerClient::instance()->getString(chatMsg.SenderNameId, senderStr);
|
|
|
@ -528,9 +528,9 @@ void CClientChatManager::processChatString( NLMISC::CBitMemStream& bms, IChatDis
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// display
|
|
|
|
// display
|
|
|
|
ucstring ucstr;
|
|
|
|
string ucstr;
|
|
|
|
buildChatSentence(chatMsg.CompressedIndex, senderStr, chatMsg.Content, type, ucstr);
|
|
|
|
buildChatSentence(chatMsg.CompressedIndex, senderStr, chatMsg.Content.toUtf8(), type, ucstr);
|
|
|
|
chatDisplayer.displayChat(chatMsg.CompressedIndex, ucstr, chatMsg.Content, type, chatMsg.DynChatChanID, senderStr);
|
|
|
|
chatDisplayer.displayChat(chatMsg.CompressedIndex, ucstr, chatMsg.Content.toUtf8(), type, chatMsg.DynChatChanID, senderStr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -545,8 +545,8 @@ void CClientChatManager::processTellString2(NLMISC::CBitMemStream& bms, IChatDis
|
|
|
|
bms.serial(chatMsg.PhraseId);
|
|
|
|
bms.serial(chatMsg.PhraseId);
|
|
|
|
|
|
|
|
|
|
|
|
// if !complete, wait
|
|
|
|
// if !complete, wait
|
|
|
|
ucstring senderStr;
|
|
|
|
string senderStr;
|
|
|
|
ucstring rawMessage;
|
|
|
|
string rawMessage;
|
|
|
|
bool complete = true;
|
|
|
|
bool complete = true;
|
|
|
|
complete &= STRING_MANAGER::CStringManagerClient::instance()->getString(chatMsg.SenderNameId, senderStr);
|
|
|
|
complete &= STRING_MANAGER::CStringManagerClient::instance()->getString(chatMsg.SenderNameId, senderStr);
|
|
|
|
complete &= STRING_MANAGER::CStringManagerClient::instance()->getDynString(chatMsg.PhraseId, rawMessage);
|
|
|
|
complete &= STRING_MANAGER::CStringManagerClient::instance()->getDynString(chatMsg.PhraseId, rawMessage);
|
|
|
@ -558,7 +558,7 @@ void CClientChatManager::processTellString2(NLMISC::CBitMemStream& bms, IChatDis
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// display
|
|
|
|
// display
|
|
|
|
ucstring ucstr;
|
|
|
|
string ucstr;
|
|
|
|
buildTellSentence(senderStr, rawMessage, ucstr);
|
|
|
|
buildTellSentence(senderStr, rawMessage, ucstr);
|
|
|
|
chatDisplayer.displayTell(/*chatMsg.CompressedIndex, */ucstr, senderStr);
|
|
|
|
chatDisplayer.displayTell(/*chatMsg.CompressedIndex, */ucstr, senderStr);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -571,8 +571,8 @@ void CClientChatManager::processChatString2(NLMISC::CBitMemStream& bms, IChatDis
|
|
|
|
bms.serial( chatMsg );
|
|
|
|
bms.serial( chatMsg );
|
|
|
|
if (PermanentlyBanned) return;
|
|
|
|
if (PermanentlyBanned) return;
|
|
|
|
CChatGroup::TGroupType type = static_cast<CChatGroup::TGroupType>(chatMsg.ChatMode);
|
|
|
|
CChatGroup::TGroupType type = static_cast<CChatGroup::TGroupType>(chatMsg.ChatMode);
|
|
|
|
ucstring senderStr;
|
|
|
|
string senderStr;
|
|
|
|
ucstring rawMessage;
|
|
|
|
string rawMessage;
|
|
|
|
|
|
|
|
|
|
|
|
// here, the type cannot be dyn_chat (no DynChatId in the message) => discard
|
|
|
|
// here, the type cannot be dyn_chat (no DynChatId in the message) => discard
|
|
|
|
if(type==CChatGroup::dyn_chat)
|
|
|
|
if(type==CChatGroup::dyn_chat)
|
|
|
@ -592,11 +592,11 @@ void CClientChatManager::processChatString2(NLMISC::CBitMemStream& bms, IChatDis
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rawMessage += ucstring(" ");
|
|
|
|
rawMessage += " ";
|
|
|
|
rawMessage += chatMsg.CustomTxt;
|
|
|
|
rawMessage += chatMsg.CustomTxt.toUtf8();
|
|
|
|
|
|
|
|
|
|
|
|
// display
|
|
|
|
// display
|
|
|
|
ucstring ucstr;
|
|
|
|
string ucstr;
|
|
|
|
buildChatSentence(chatMsg.CompressedIndex, senderStr, rawMessage, type, ucstr);
|
|
|
|
buildChatSentence(chatMsg.CompressedIndex, senderStr, rawMessage, type, ucstr);
|
|
|
|
chatDisplayer.displayChat(chatMsg.CompressedIndex, ucstr, rawMessage, type, CEntityId::Unknown, senderStr);
|
|
|
|
chatDisplayer.displayChat(chatMsg.CompressedIndex, ucstr, rawMessage, type, CEntityId::Unknown, senderStr);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -615,7 +615,7 @@ void CClientChatManager::processChatStringWithNoSender( NLMISC::CBitMemStream& b
|
|
|
|
chatMsg.SenderNameId = 0;
|
|
|
|
chatMsg.SenderNameId = 0;
|
|
|
|
chatMsg.ChatMode = type;
|
|
|
|
chatMsg.ChatMode = type;
|
|
|
|
chatMsg.PhraseId = phraseID;
|
|
|
|
chatMsg.PhraseId = phraseID;
|
|
|
|
ucstring ucstr;
|
|
|
|
string ucstr;
|
|
|
|
|
|
|
|
|
|
|
|
// if !complete, wait
|
|
|
|
// if !complete, wait
|
|
|
|
bool complete = STRING_MANAGER::CStringManagerClient::instance()->getDynString(chatMsg.PhraseId, ucstr);
|
|
|
|
bool complete = STRING_MANAGER::CStringManagerClient::instance()->getDynString(chatMsg.PhraseId, ucstr);
|
|
|
@ -627,7 +627,7 @@ void CClientChatManager::processChatStringWithNoSender( NLMISC::CBitMemStream& b
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// diplay
|
|
|
|
// diplay
|
|
|
|
ucstring senderName("");
|
|
|
|
string senderName;
|
|
|
|
chatDisplayer.displayChat(INVALID_DATASET_INDEX, ucstr, ucstr, type, CEntityId::Unknown, senderName);
|
|
|
|
chatDisplayer.displayChat(INVALID_DATASET_INDEX, ucstr, ucstr, type, CEntityId::Unknown, senderName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -643,7 +643,7 @@ void CClientChatManager::flushBuffer(IChatDisplayer &chatDisplayer)
|
|
|
|
for( itMsg = _ChatBuffer.begin(); itMsg != _ChatBuffer.end(); )
|
|
|
|
for( itMsg = _ChatBuffer.begin(); itMsg != _ChatBuffer.end(); )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CChatGroup::TGroupType type = static_cast<CChatGroup::TGroupType>(itMsg->ChatMode);
|
|
|
|
CChatGroup::TGroupType type = static_cast<CChatGroup::TGroupType>(itMsg->ChatMode);
|
|
|
|
ucstring sender, content;
|
|
|
|
string sender, content;
|
|
|
|
|
|
|
|
|
|
|
|
// all strings received?
|
|
|
|
// all strings received?
|
|
|
|
bool complete = true;
|
|
|
|
bool complete = true;
|
|
|
@ -652,7 +652,7 @@ void CClientChatManager::flushBuffer(IChatDisplayer &chatDisplayer)
|
|
|
|
if(itMsg->UsePhraseId)
|
|
|
|
if(itMsg->UsePhraseId)
|
|
|
|
complete &= STRING_MANAGER::CStringManagerClient::instance()->getDynString(itMsg->PhraseId, content);
|
|
|
|
complete &= STRING_MANAGER::CStringManagerClient::instance()->getDynString(itMsg->PhraseId, content);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
content= itMsg->Content;
|
|
|
|
content= itMsg->Content.toUtf8();
|
|
|
|
|
|
|
|
|
|
|
|
if (type == CChatGroup::dyn_chat)
|
|
|
|
if (type == CChatGroup::dyn_chat)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -666,7 +666,7 @@ void CClientChatManager::flushBuffer(IChatDisplayer &chatDisplayer)
|
|
|
|
// if complete, process
|
|
|
|
// if complete, process
|
|
|
|
if (complete)
|
|
|
|
if (complete)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ucstring ucstr;
|
|
|
|
string ucstr;
|
|
|
|
if (itMsg->SenderNameId == 0)
|
|
|
|
if (itMsg->SenderNameId == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ucstr = content;
|
|
|
|
ucstr = content;
|
|
|
@ -703,7 +703,7 @@ void CClientChatManager::flushBuffer(IChatDisplayer &chatDisplayer)
|
|
|
|
// getString
|
|
|
|
// getString
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//-----------------------------------------------
|
|
|
|
//-----------------------------------------------
|
|
|
|
ucstring CClientChatManager::getString( CBitMemStream& bms, ucstring& ucstr )
|
|
|
|
string CClientChatManager::getString( CBitMemStream& bms, string& ucstr )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
// deal with parameters
|
|
|
|
// deal with parameters
|
|
|
@ -714,11 +714,11 @@ ucstring CClientChatManager::getString( CBitMemStream& bms, ucstring& ucstr )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// search if a parameter exists in the string
|
|
|
|
// search if a parameter exists in the string
|
|
|
|
sprintf(chTmp,"$%d",dynParamIdx);
|
|
|
|
sprintf(chTmp,"$%d",dynParamIdx);
|
|
|
|
ucstring ucstrTmp( chTmp );
|
|
|
|
string ucstrTmp( chTmp );
|
|
|
|
ucstring::size_type idx = ucstr.find(ucstrTmp);
|
|
|
|
string::size_type idx = ucstr.find(ucstrTmp);
|
|
|
|
|
|
|
|
|
|
|
|
// if there's a parameter in the string
|
|
|
|
// if there's a parameter in the string
|
|
|
|
if( idx != ucstring::npos )
|
|
|
|
if( idx != string::npos )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char c = (char)ucstr[idx+ucstrTmp.size()];
|
|
|
|
char c = (char)ucstr[idx+ucstrTmp.size()];
|
|
|
|
switch( c )
|
|
|
|
switch( c )
|
|
|
@ -728,7 +728,7 @@ ucstring CClientChatManager::getString( CBitMemStream& bms, ucstring& ucstr )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool huff;
|
|
|
|
bool huff;
|
|
|
|
bms.serialBit(huff);
|
|
|
|
bms.serialBit(huff);
|
|
|
|
const ucstring dynStr("???");
|
|
|
|
const string dynStr("???");
|
|
|
|
if( huff )
|
|
|
|
if( huff )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
nldebug("<CClientChatManager::getString> receiving huffman dynamic parameter in static string");
|
|
|
|
nldebug("<CClientChatManager::getString> receiving huffman dynamic parameter in static string");
|
|
|
@ -756,8 +756,7 @@ ucstring CClientChatManager::getString( CBitMemStream& bms, ucstring& ucstr )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string dynStr;
|
|
|
|
string dynStr;
|
|
|
|
bms.serial( dynStr );
|
|
|
|
bms.serial( dynStr );
|
|
|
|
ucstring ucDynStr(dynStr);
|
|
|
|
ucstr.replace( idx, ucstrTmp.size()+1, dynStr );
|
|
|
|
ucstr.replace( idx, ucstrTmp.size()+1, ucDynStr );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
@ -766,7 +765,7 @@ ucstring CClientChatManager::getString( CBitMemStream& bms, ucstring& ucstr )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint32 nb;
|
|
|
|
uint32 nb;
|
|
|
|
bms.serial( nb );
|
|
|
|
bms.serial( nb );
|
|
|
|
ucstr.replace( idx, ucstrTmp.size()+1, ucstring(toString(nb)) );
|
|
|
|
ucstr.replace( idx, ucstrTmp.size()+1, toString(nb) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
/*
|
|
|
|
/*
|
|
|
@ -794,7 +793,7 @@ ucstring CClientChatManager::getString( CBitMemStream& bms, ucstring& ucstr )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sint32 nb;
|
|
|
|
sint32 nb;
|
|
|
|
bms.serial( nb );
|
|
|
|
bms.serial( nb );
|
|
|
|
ucstr.replace( idx, ucstrTmp.size()+1, ucstring(toString(nb)) );
|
|
|
|
ucstr.replace( idx, ucstrTmp.size()+1, toString(nb) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
/*
|
|
|
|
/*
|
|
|
@ -823,7 +822,7 @@ ucstring CClientChatManager::getString( CBitMemStream& bms, ucstring& ucstr )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
float nb;
|
|
|
|
float nb;
|
|
|
|
bms.serial( nb );
|
|
|
|
bms.serial( nb );
|
|
|
|
ucstr.replace( idx, ucstrTmp.size()+1, ucstring(toString(nb)) );
|
|
|
|
ucstr.replace( idx, ucstrTmp.size()+1, toString(nb) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
@ -849,7 +848,7 @@ ucstring CClientChatManager::getString( CBitMemStream& bms, ucstring& ucstr )
|
|
|
|
// getString
|
|
|
|
// getString
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//-----------------------------------------------
|
|
|
|
//-----------------------------------------------
|
|
|
|
bool CClientChatManager::getString( ucstring &result, std::vector<uint64>& args, const ucstring &ucstrbase )
|
|
|
|
bool CClientChatManager::getString( string &result, std::vector<uint64>& args, const string &ucstrbase )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
result = ucstrbase;
|
|
|
|
result = ucstrbase;
|
|
|
|
|
|
|
|
|
|
|
@ -863,17 +862,17 @@ bool CClientChatManager::getString( ucstring &result, std::vector<uint64>& args,
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// search if a parameter exists in the string
|
|
|
|
// search if a parameter exists in the string
|
|
|
|
sprintf(chTmp,"$%d",dynParamIdx);
|
|
|
|
sprintf(chTmp,"$%d",dynParamIdx);
|
|
|
|
ucstring ucstrTmp( chTmp );
|
|
|
|
string ucstrTmp( chTmp );
|
|
|
|
ucstring::size_type idx = result.find(ucstrTmp);
|
|
|
|
string::size_type idx = result.find(ucstrTmp);
|
|
|
|
|
|
|
|
|
|
|
|
// if there's a parameter in the string
|
|
|
|
// if there's a parameter in the string
|
|
|
|
if( idx != ucstring::npos )
|
|
|
|
if( idx != string::npos )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ucstring rep;
|
|
|
|
string rep;
|
|
|
|
rep = "???";
|
|
|
|
rep = "???";
|
|
|
|
if (dynParamIdx >= args.size())
|
|
|
|
if (dynParamIdx >= args.size())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
nlwarning ("Missing args for string '%s', only %d args, need arg %d", ucstrbase.toString().c_str(), args.size(), dynParamIdx);
|
|
|
|
nlwarning ("Missing args for string '%s', only %d args, need arg %d", ucstrbase.c_str(), args.size(), dynParamIdx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -948,15 +947,15 @@ bool CClientChatManager::getString( ucstring &result, std::vector<uint64>& args,
|
|
|
|
} // getString //
|
|
|
|
} // getString //
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
void CClientChatManager::buildTellSentence(const ucstring &sender, const ucstring &msg, ucstring &result)
|
|
|
|
void CClientChatManager::buildTellSentence(const string &sender, const string &msg, string &result)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// If no sender name was provided, show only the msg
|
|
|
|
// If no sender name was provided, show only the msg
|
|
|
|
if ( sender.empty() )
|
|
|
|
if ( sender.empty() )
|
|
|
|
result = msg;
|
|
|
|
result = msg;
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ucstring name = CEntityCL::removeTitleAndShardFromName(sender.toUtf8());
|
|
|
|
string name = CEntityCL::removeTitleAndShardFromName(sender);
|
|
|
|
ucstring csr;
|
|
|
|
string csr;
|
|
|
|
|
|
|
|
|
|
|
|
// special case where there is only a title, very rare case for some NPC
|
|
|
|
// special case where there is only a title, very rare case for some NPC
|
|
|
|
if (name.empty())
|
|
|
|
if (name.empty())
|
|
|
@ -965,29 +964,29 @@ void CClientChatManager::buildTellSentence(const ucstring &sender, const ucstrin
|
|
|
|
CCharacterCL *entity = dynamic_cast<CCharacterCL*>(EntitiesMngr.getEntityByName(sender, true, true));
|
|
|
|
CCharacterCL *entity = dynamic_cast<CCharacterCL*>(EntitiesMngr.getEntityByName(sender, true, true));
|
|
|
|
bool bWoman = entity && entity->getGender() == GSGENDER::female;
|
|
|
|
bool bWoman = entity && entity->getGender() == GSGENDER::female;
|
|
|
|
|
|
|
|
|
|
|
|
name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sender.toUtf8()), bWoman);
|
|
|
|
name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sender), bWoman);
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Sometimes translation contains another title
|
|
|
|
// Sometimes translation contains another title
|
|
|
|
ucstring::size_type pos = name.find('$');
|
|
|
|
string::size_type pos = name.find('$');
|
|
|
|
if (pos != ucstring::npos)
|
|
|
|
if (pos != string::npos)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(name.toUtf8()), bWoman);
|
|
|
|
name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(name), bWoman);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Does the char have a CSR title?
|
|
|
|
// Does the char have a CSR title?
|
|
|
|
csr = CHARACTER_TITLE::isCsrTitle(CEntityCL::getTitleFromName(sender.toUtf8())) ? ucstring("(CSR) ") : ucstring("");
|
|
|
|
csr = CHARACTER_TITLE::isCsrTitle(CEntityCL::getTitleFromName(sender)) ? "(CSR) " : "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
result = csr + name + ucstring(" ") + CI18N::get("tellsYou") + ucstring(": ") + msg;
|
|
|
|
result = csr + name + " " + CI18N::get("tellsYou") + ": " + msg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderIndex */, const ucstring &sender, const ucstring &msg, CChatGroup::TGroupType type, ucstring &result)
|
|
|
|
void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderIndex */, const string &sender, const string &msg, CChatGroup::TGroupType type, string &result)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// if its a tell, then use buildTellSentence
|
|
|
|
// if its a tell, then use buildTellSentence
|
|
|
|
if(type==CChatGroup::tell)
|
|
|
|
if(type==CChatGroup::tell)
|
|
|
@ -1005,35 +1004,35 @@ void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderInde
|
|
|
|
|
|
|
|
|
|
|
|
// get the category if any. Note, in some case (chat from other player), there is not categories
|
|
|
|
// get the category if any. Note, in some case (chat from other player), there is not categories
|
|
|
|
// and we do not want getStringCategory to return 'SYS' category.
|
|
|
|
// and we do not want getStringCategory to return 'SYS' category.
|
|
|
|
ucstring finalMsg;
|
|
|
|
string finalMsg;
|
|
|
|
string catStr = getStringCategory(msg, finalMsg, false);
|
|
|
|
string catStr = getStringCategory(msg, finalMsg, false);
|
|
|
|
ucstring cat;
|
|
|
|
string cat;
|
|
|
|
if (!catStr.empty())
|
|
|
|
if (!catStr.empty())
|
|
|
|
cat = string("&")+catStr+"&";
|
|
|
|
cat = "&" + catStr + "&";
|
|
|
|
|
|
|
|
|
|
|
|
if ( ! cat.empty())
|
|
|
|
if (!cat.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
result = msg;
|
|
|
|
result = msg;
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Format the sentence with the provided sender name
|
|
|
|
// Format the sentence with the provided sender name
|
|
|
|
ucstring senderName = CEntityCL::removeTitleAndShardFromName(sender.toUtf8());
|
|
|
|
string senderName = CEntityCL::removeTitleAndShardFromName(sender);
|
|
|
|
|
|
|
|
|
|
|
|
ucstring csr;
|
|
|
|
string csr;
|
|
|
|
// Does the char have a CSR title?
|
|
|
|
// Does the char have a CSR title?
|
|
|
|
csr = CHARACTER_TITLE::isCsrTitle(CEntityCL::getTitleFromName(sender.toUtf8())) ? ucstring("(CSR) ") : ucstring("");
|
|
|
|
csr = CHARACTER_TITLE::isCsrTitle(CEntityCL::getTitleFromName(sender)) ? "(CSR) " : "";
|
|
|
|
|
|
|
|
|
|
|
|
if (UserEntity && senderName.toUtf8() == UserEntity->getDisplayName())
|
|
|
|
if (UserEntity && senderName == UserEntity->getDisplayName())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// The player talks
|
|
|
|
// The player talks
|
|
|
|
switch(type)
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case CChatGroup::shout:
|
|
|
|
case CChatGroup::shout:
|
|
|
|
result = cat + csr + CI18N::get("youShout") + ucstring(": ") + finalMsg;
|
|
|
|
result = cat + csr + CI18N::get("youShout") + ": " + finalMsg;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
result = cat + csr + CI18N::get("youSay") + ucstring(": ") + finalMsg;
|
|
|
|
result = cat + csr + CI18N::get("youSay") + ": " + finalMsg;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1046,13 +1045,13 @@ void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderInde
|
|
|
|
// We need the gender to display the correct title
|
|
|
|
// We need the gender to display the correct title
|
|
|
|
bool bWoman = entity && entity->getGender() == GSGENDER::female;
|
|
|
|
bool bWoman = entity && entity->getGender() == GSGENDER::female;
|
|
|
|
|
|
|
|
|
|
|
|
senderName = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sender.toUtf8()), bWoman);
|
|
|
|
senderName = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sender), bWoman);
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Sometimes translation contains another title
|
|
|
|
// Sometimes translation contains another title
|
|
|
|
ucstring::size_type pos = senderName.find('$');
|
|
|
|
string::size_type pos = senderName.find('$');
|
|
|
|
if (pos != ucstring::npos)
|
|
|
|
if (pos != string::npos)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
senderName = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(senderName.toUtf8()), bWoman);
|
|
|
|
senderName = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(senderName), bWoman);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1060,10 +1059,10 @@ void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderInde
|
|
|
|
switch(type)
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case CChatGroup::shout:
|
|
|
|
case CChatGroup::shout:
|
|
|
|
result = cat + csr + senderName + ucstring(" ") + CI18N::get("heShout") + ucstring(": ") + finalMsg;
|
|
|
|
result = cat + csr + senderName + " " + CI18N::get("heShout") + ": " + finalMsg;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
result = cat + csr + senderName + ucstring(" ") + CI18N::get("heSays") + ucstring(": ") + finalMsg;
|
|
|
|
result = cat + csr + senderName + " " + CI18N::get("heSays") + ": " + finalMsg;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1173,7 +1172,7 @@ void CClientChatManager::updateDynamicChatChannels(IChatDisplayer &chatDisplayer
|
|
|
|
|
|
|
|
|
|
|
|
class CHandlerTell : public IActionHandler
|
|
|
|
class CHandlerTell : public IActionHandler
|
|
|
|
{
|
|
|
|
{
|
|
|
|
void execute (CCtrlBase *pCaller, const std::string &sParams)
|
|
|
|
void execute (CCtrlBase *pCaller, const string &sParams)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string receiver = getParam (sParams, "player");
|
|
|
|
string receiver = getParam (sParams, "player");
|
|
|
|
string message;
|
|
|
|
string message;
|
|
|
@ -1218,7 +1217,7 @@ REGISTER_ACTION_HANDLER( CHandlerTell, "tell");
|
|
|
|
|
|
|
|
|
|
|
|
class CHandlerEnterTell : public IActionHandler
|
|
|
|
class CHandlerEnterTell : public IActionHandler
|
|
|
|
{
|
|
|
|
{
|
|
|
|
void execute (CCtrlBase * /* pCaller */, const std::string &sParams)
|
|
|
|
void execute (CCtrlBase * /* pCaller */, const string &sParams)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CInterfaceManager *im = CInterfaceManager::getInstance();
|
|
|
|
CInterfaceManager *im = CInterfaceManager::getInstance();
|
|
|
|
string receiver = getParam (sParams, "player");
|
|
|
|
string receiver = getParam (sParams, "player");
|
|
|
@ -1294,7 +1293,7 @@ void CClientChatManager::updateChatModeAndButton(uint mode, uint32 dynamicChanne
|
|
|
|
case CChatGroup::guild: if (guildActive) pUserBut->setHardText("uiFilterGuild"); break;
|
|
|
|
case CChatGroup::guild: if (guildActive) pUserBut->setHardText("uiFilterGuild"); break;
|
|
|
|
case CChatGroup::dyn_chat:
|
|
|
|
case CChatGroup::dyn_chat:
|
|
|
|
uint32 textId = ChatMngr.getDynamicChannelNameFromDbIndex(dynamicChannelDbIndex);
|
|
|
|
uint32 textId = ChatMngr.getDynamicChannelNameFromDbIndex(dynamicChannelDbIndex);
|
|
|
|
ucstring title;
|
|
|
|
string title;
|
|
|
|
STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title);
|
|
|
|
STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title);
|
|
|
|
if (title.empty())
|
|
|
|
if (title.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1304,7 +1303,7 @@ void CClientChatManager::updateChatModeAndButton(uint mode, uint32 dynamicChanne
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pUserBut->setHardText(title.toUtf8());
|
|
|
|
pUserBut->setHardText(title);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1336,7 +1335,7 @@ void CClientChatManager::updateChatModeAndButton(uint mode, uint32 dynamicChanne
|
|
|
|
|
|
|
|
|
|
|
|
class CHandlerTalk : public IActionHandler
|
|
|
|
class CHandlerTalk : public IActionHandler
|
|
|
|
{
|
|
|
|
{
|
|
|
|
void execute (CCtrlBase * /* pCaller */, const std::string &sParams)
|
|
|
|
void execute (CCtrlBase * /* pCaller */, const string &sParams)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Param
|
|
|
|
// Param
|
|
|
|
uint mode;
|
|
|
|
uint mode;
|
|
|
@ -1375,7 +1374,7 @@ class CHandlerTalk : public IActionHandler
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CInterfaceManager *im = CInterfaceManager::getInstance();
|
|
|
|
CInterfaceManager *im = CInterfaceManager::getInstance();
|
|
|
|
im->displaySystemInfo (ucstring::makeFromUtf8(cmd) + ": " + CI18N::get ("uiCommandNotExists"));
|
|
|
|
im->displaySystemInfo (cmd + ": " + CI18N::get ("uiCommandNotExists"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -1408,7 +1407,7 @@ REGISTER_ACTION_HANDLER( CHandlerTalk, "talk");
|
|
|
|
|
|
|
|
|
|
|
|
class CHandlerEnterTalk : public IActionHandler
|
|
|
|
class CHandlerEnterTalk : public IActionHandler
|
|
|
|
{
|
|
|
|
{
|
|
|
|
void execute (CCtrlBase * /* pCaller */, const std::string &sParams)
|
|
|
|
void execute (CCtrlBase * /* pCaller */, const string &sParams)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Param
|
|
|
|
// Param
|
|
|
|
uint mode;
|
|
|
|
uint mode;
|
|
|
@ -1435,10 +1434,10 @@ REGISTER_ACTION_HANDLER( CHandlerEnterTalk, "enter_talk");
|
|
|
|
|
|
|
|
|
|
|
|
class CHandlerTalkMessage : public IActionHandler
|
|
|
|
class CHandlerTalkMessage : public IActionHandler
|
|
|
|
{
|
|
|
|
{
|
|
|
|
void execute (CCtrlBase * /* pCaller */, const std::string &sParams)
|
|
|
|
void execute (CCtrlBase * /* pCaller */, const string &sParams)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Param
|
|
|
|
// Param
|
|
|
|
ucstring text = CI18N::get ("uiTalkMemMsg"+sParams);
|
|
|
|
string text = CI18N::get ("uiTalkMemMsg"+sParams);
|
|
|
|
|
|
|
|
|
|
|
|
// Find the base group
|
|
|
|
// Find the base group
|
|
|
|
if (!text.empty())
|
|
|
|
if (!text.empty())
|
|
|
@ -1454,7 +1453,7 @@ REGISTER_ACTION_HANDLER( CHandlerTalkMessage, "talk_message");
|
|
|
|
|
|
|
|
|
|
|
|
class CHandlerSwapChatMode : public IActionHandler
|
|
|
|
class CHandlerSwapChatMode : public IActionHandler
|
|
|
|
{
|
|
|
|
{
|
|
|
|
void execute (CCtrlBase * /* pCaller */, const std::string &sParams)
|
|
|
|
void execute (CCtrlBase * /* pCaller */, const string &sParams)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CInterfaceManager *pIM= CInterfaceManager::getInstance();
|
|
|
|
CInterfaceManager *pIM= CInterfaceManager::getInstance();
|
|
|
|
bool updateCapture= getParam(sParams, "update_capture")=="1";
|
|
|
|
bool updateCapture= getParam(sParams, "update_capture")=="1";
|
|
|
|