Merge branch 'deepl'

feature/prepare-cross-merge
Ulukyn 5 years ago committed by kaetemi
parent 0d57aad8b9
commit 3c178cb506
No known key found for this signature in database
GPG Key ID: 9873C4D40BB479BC

@ -4577,17 +4577,20 @@ NLMISC_COMMAND (connectLangChannel, "Connect to lang channel", "<user id> <lang>
CPVPManager2 *inst = CPVPManager2::getInstance();
string action;
string lang = args[1];
if (lang != "en" && lang != "fr" && lang != "de" && lang != "ru" && lang != "es" && lang != "rf"
&& lang != "rf-en" && lang != "rf-fr" && lang != "rf-de" && lang != "rf-ru" && lang != "rf-es")
if (lang != "en" && lang != "fr" && lang != "de" && lang != "ru" && lang != "es" && lang != "rf" && !c->havePriv(":DEV:"))
return false;
bool leave = !c->havePriv(":DEV:"); // Since June 2020, no any lang channels, players only can leave it
bool leave = false;
if (args.size() > 2)
leave = args[2] == "1";
TChanID channel = inst->getFactionDynChannel(lang);
string channelName = lang;
// Convert langs to usr lang channels
if (lang == "en" || lang == "fr" || lang == "de" || lang == "ru" || lang == "es")
channelName = "usr_"+lang;
TChanID channel = inst->getFactionDynChannel(channelName);
if (channel != DYN_CHAT_INVALID_CHAN)
{

@ -436,7 +436,7 @@ static void prepareCharacterPositionForStore ( COfflineEntityState & state, cons
PROP(uint32,_GuildPoints)\
PROP(uint8,_TodayGuildPoints)\
PROP_GAME_CYCLE_COMP(_NextTodayGuildPointsReset)\
PROP2(_LangChannel,string,_LangChannel,_LangChannel="rf")\
PROP2(_LangChannel,string,_LangChannel,_LangChannel=val)\
PROP(uint32,_Organization)\
PROP(uint32,_OrganizationStatus)\
PROP(uint32,_OrganizationPoints)\

@ -221,20 +221,21 @@ std::vector<TChanID> CPVPManager2::getCharacterChannels(CCharacter * user)
NLMISC::splitString(user->getLangChannel(), " ", langChannels);
for ( uint i = 0; i < langChannels.size(); i++ )
{
TMAPExtraFactionChannel::iterator it = _ExtraFactionChannel.find(langChannels[i]);
if (it != _ExtraFactionChannel.end())
if (langChannels[i] != "rf")
{
result.push_back((*it).second);
TMAPExtraFactionChannel::iterator it = _ExtraFactionChannel.find("usr_"+langChannels[i]);
if (it != _ExtraFactionChannel.end())
{
result.push_back((*it).second);
}
}
}
}
else
TMAPExtraFactionChannel::iterator it = _ExtraFactionChannel.find("rf");
if (it != _ExtraFactionChannel.end())
{
TMAPExtraFactionChannel::iterator it = _ExtraFactionChannel.find("en");
if (it != _ExtraFactionChannel.end())
{
result.push_back((*it).second);
}
result.push_back((*it).second);
}
PVP_CLAN::TPVPClan faction = user->getAllegiance().first;
@ -1184,11 +1185,18 @@ void CPVPManager2::onIOSMirrorUp()
createExtraFactionChannel("de", true);
createExtraFactionChannel("ru", true);
createExtraFactionChannel("es", true);
createExtraFactionChannel("usr_en", true);
createExtraFactionChannel("usr_fr", true);
createExtraFactionChannel("usr_de", true);
createExtraFactionChannel("usr_ru", true);
createExtraFactionChannel("usr_es", true);
createExtraFactionChannel("rf", true);
createExtraFactionChannel("rf-fr", true);
createExtraFactionChannel("rf-en", true);
createExtraFactionChannel("rf-es", true);
createExtraFactionChannel("rf-ed", true);
createExtraFactionChannel("rf-de", true);
createExtraFactionChannel("rf-ru", true);
#ifdef HAVE_MONGO

@ -46,7 +46,7 @@ CChatClient::CChatClient( const TDataSetRow& index )
cm.addGroup(_SayAudienceId, CChatGroup::say, "");
cm.addGroup(_ShoutAudienceId, CChatGroup::shout, "");
_Muted = false;
_Muted = false;
_ChatMode = CChatGroup::say;
_SayLastAudienceUpdateTime = CTime::getLocalTime();
_ShoutLastAudienceUpdateTime = _SayLastAudienceUpdateTime;
@ -64,9 +64,9 @@ CChatClient::~CChatClient()
}
void CChatClient::setChatMode( CChatGroup::TGroupType mode, TChanID dynChatChan)
{
_ChatMode = mode;
void CChatClient::setChatMode( CChatGroup::TGroupType mode, TChanID dynChatChan)
{
_ChatMode = mode;
_DynChatChan = dynChatChan;
}
@ -126,7 +126,7 @@ bool CChatClient::isMuted()
return false;
}
}
return true;
return true;
}
} // isMuted //
@ -143,10 +143,10 @@ void CChatClient::setIgnoreStatus( const NLMISC::CEntityId &id, bool ignored)
if (ignored)
{
if( itIgnore == _IgnoreList.end() )
{
{
_IgnoreList.insert( id );
}
}
else
{
@ -223,11 +223,11 @@ void CChatClient::filter( TFilter filterId )
//
//-----------------------------------------------
CChatGroup& CChatClient::getAudience()
{
{
CChatManager &cm = IOS->getChatManager();
if(_ChatMode == CChatGroup::shout)
return cm.getGroup(_ShoutAudienceId);
else
if(_ChatMode == CChatGroup::shout)
return cm.getGroup(_ShoutAudienceId);
else
return cm.getGroup(_SayAudienceId);
} // getAudience //
@ -239,7 +239,7 @@ CChatGroup& CChatClient::getAudience()
//
//-----------------------------------------------
CChatGroup& CChatClient::getSayAudience( bool update )
{
{
CChatManager &cm = IOS->getChatManager();
if( update )
{
@ -256,7 +256,7 @@ CChatGroup& CChatClient::getSayAudience( bool update )
//
//-----------------------------------------------
CChatGroup& CChatClient::getShoutAudience( bool update )
{
{
CChatManager &cm = IOS->getChatManager();
if( update )
{
@ -339,8 +339,8 @@ void CChatClient::updateAudience( CEntityId &audienceId, sint maxDist, TTime& la
// first of all, check the instance id
if (instanceId == charInstanceId)
{
CMirrorPropValueRO<sint32> charCell( TheDataset, entityIndex, DSPropertyCELL );
CMirrorPropValueRO<sint32> charCell( TheDataset, entityIndex, DSPropertyCELL );
// if the player is NOT in an appartment
if( cellS > 0 )
{
@ -349,7 +349,7 @@ void CChatClient::updateAudience( CEntityId &audienceId, sint maxDist, TTime& la
uint16 charCellX = (uint16)(charCell>>16);
uint16 charCellY = (uint16)(charCell&0xffff);
sint32 distX = (sint32)(charCellX) - (sint32)(senderCellX);
sint32 distY = (sint32)(charCellY) - (sint32)(senderCellY);
@ -409,7 +409,7 @@ void CChatClient::updateAudience( CEntityId &audienceId, sint maxDist, TTime& la
}
lastAudienceUpdateTime = currentTime;
}
} // updateAudience //
@ -512,13 +512,24 @@ void CChatClient::unsubscribeAllChatGroup()
//-----------------------------------------------
// disableTranslation
// disableSendTranslation
//-----------------------------------------------
void CChatClient::disableTranslation( const string &lang )
void CChatClient::disableSendTranslation( const string &lang )
{
if (find(_DontTranslate.begin(), _DontTranslate.end(), lang) == _DontTranslate.end())
if (find(_DontSendTranslation.begin(), _DontSendTranslation.end(), lang) == _DontSendTranslation.end())
{
_DontTranslate.push_back(lang);
_DontSendTranslation.push_back(lang);
}
}
//-----------------------------------------------
// disableReceiveTranslation
//-----------------------------------------------
void CChatClient::disableReceiveTranslation( const string &lang )
{
if (find(_DontReceiveTranslation.begin(), _DontReceiveTranslation.end(), lang) == _DontReceiveTranslation.end())
{
_DontReceiveTranslation.push_back(lang);
}
}
@ -527,16 +538,25 @@ void CChatClient::disableTranslation( const string &lang )
//-----------------------------------------------
void CChatClient::resetDisabledTranslations()
{
_DontTranslate.clear();
_DontReceiveTranslation.clear();
_DontSendTranslation.clear();
}
//-----------------------------------------------
// haveDisabledTranslation
// dontReceiveTranslation
//-----------------------------------------------
bool CChatClient::haveDisabledTranslation( const string &lang )
bool CChatClient::dontReceiveTranslation( const string &lang )
{
return find(_DontTranslate.begin(), _DontTranslate.end(), lang) != _DontTranslate.end();
return find(_DontReceiveTranslation.begin(), _DontReceiveTranslation.end(), lang) != _DontReceiveTranslation.end();
}
//-----------------------------------------------
// dontSendTranslation
//-----------------------------------------------
bool CChatClient::dontSendTranslation( const string &lang )
{
return find(_DontSendTranslation.begin(), _DontSendTranslation.end(), lang) != _DontSendTranslation.end();
}

@ -33,21 +33,21 @@
typedef uint8 TFilter;
/**
* CChatClient
* \author Stephane Coutelas
* \author Nevrax France
* \date 2002
*/
class CChatClient
class CChatClient
{
public :
/**
* Constructor
*/
CChatClient( const TDataSetRow& id );
CChatClient( const TDataSetRow& id );
/************************************************************************/
/* Destructor */
/************************************************************************/
@ -62,7 +62,7 @@ public :
*/
const TDataSetRow &getDataSetIndex() const { return _DataSetIndex; }
/**
/**
* Mute or unmute this client, nobody will received chat from him
* the player can be muted for a fixed period of time
* If the player is unmuted, the delay is not taken into account
@ -73,7 +73,7 @@ public :
/**
* Get the mute state of this client
*
*
* \return true if this client is muted
*/
bool isMuted();
@ -101,7 +101,7 @@ public :
* \param filterId the filter
*/
void filter( TFilter filterId );
/**
* Return true if the filter is on
* \param filterId the filter
@ -109,7 +109,7 @@ public :
bool isFilterOn( TFilter filterId ) const;
/**
* Set the chat mode
* Set the chat mode
* \param mode the chat mode
* \param dynChatChan If mode is dyn chat, then gives the channel
*/
@ -132,32 +132,32 @@ public :
*/
// void setChatGroup( TGroupId gId) { _ChatGroup = gId; }
void setTeamChatGroup( TGroupId gId)
{
void setTeamChatGroup( TGroupId gId)
{
_TeamChat = gId;
}
void setGuildChatGroup( TGroupId gId)
{
void setGuildChatGroup( TGroupId gId)
{
_GuildChat = gId;
}
void setRegionChatGroup( TGroupId gId)
{
void setRegionChatGroup( TGroupId gId)
{
_RegionChat = gId;
}
TGroupId getTeamChatGroup()
{
TGroupId getTeamChatGroup()
{
return _TeamChat;
}
TGroupId getGuildChatGroup()
{
TGroupId getGuildChatGroup()
{
return _GuildChat;
}
TGroupId getRegionChatGroup()
{
TGroupId getRegionChatGroup()
{
return _RegionChat;
}
/**
* Get the chat group
* \return the group's id
@ -206,12 +206,14 @@ public :
// unsubscribe to all chat group
void unsubscribeAllChatGroup();
void disableTranslation( const std::string &lang );
void disableSendTranslation( const std::string &lang );
void disableReceiveTranslation( const std::string &lang );
void resetDisabledTranslations();
bool haveDisabledTranslation( const std::string &lang );
bool dontReceiveTranslation( const std::string &lang );
bool dontSendTranslation( const std::string &lang );
private :
/// CLient datasetrow
TDataSetRow _DataSetIndex;
/// client character id
@ -275,7 +277,8 @@ private :
/// keep infos about which string has been received by the client
std::vector<bool> _KnownStrings;
std::vector<std::string> _DontTranslate;
std::vector<std::string> _DontReceiveTranslation;
std::vector<std::string> _DontSendTranslation;
/**
* Update the audience of this client

@ -552,6 +552,9 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
TClientInfoCont::iterator itCl = _Clients.find( sender );
if( itCl != _Clients.end() )
{
CChatManager &cm = IOS->getChatManager();
CChatClient &senderClient = cm.getClient(sender);
// if( itCl->second->isMuted() )
CEntityId eid = TheDataset.getEntityId(sender);
if(_MutedUsers.find( eid ) != _MutedUsers.end())
@ -603,6 +606,8 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
// clean up container
_DestUsers.clear();
string senderLang = SM->getLanguageCodeString(ci->Language);
switch( itCl->second->getChatMode() )
{
// dynamic group
@ -617,8 +622,6 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
bool have_es = false;
CChatGroup::TMemberCont::iterator itA;
string sender_lang = SM->getLanguageCodeString(ci->Language);
for( itA = itCl->second->getAudience().Members.begin();
itA != itCl->second->getAudience().Members.end();
++itA )
@ -639,16 +642,12 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
receiver_lang = SM->getLanguageCodeString(co->Language);
}
if (EnableDeepL)
if (EnableDeepL && !senderClient.dontSendTranslation(senderLang))
{
CChatClient &client = getClient(*itA);
if (sender_lang == "wk")
receiver_lang = sender_lang;
if (ucstr[0] != '>' && client.haveDisabledTranslation(sender_lang))
receiver_lang = sender_lang;
if (senderLang == "wk")
receiver_lang = senderLang;
if (ucstr[0] == '>') // Sent directly when prefixed by '>', it's the anti-translation code
{
@ -656,7 +655,7 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
{
string usedlang = ucstr.toString().substr(2, 2);
//nlinfo("used: %s, user: %s", usedlang.c_str(), receiver_lang.c_str());
if (usedlang == receiver_lang && !client.haveDisabledTranslation(sender_lang))
if (usedlang == receiver_lang && !client.dontReceiveTranslation(usedlang))
sendChat( itCl->second->getChatMode(), *itA, ucstr.substr(5), sender );
}
else
@ -664,7 +663,7 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
sendChat( itCl->second->getChatMode(), *itA, ucstr.substr(1), sender );
}
}
else if (sender_lang == receiver_lang) // Sent directly if sender and receiver uses same lang
else if (senderLang == receiver_lang || client.dontReceiveTranslation(senderLang)) // Sent directly if sender and receiver uses same lang
{
sendChat( itCl->second->getChatMode(), *itA, ucstr, sender );
}
@ -687,7 +686,7 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
sendChat( itCl->second->getChatMode(), *itA, ucstr, sender );
}
string langs = sender_lang;
string langs = senderLang;
if (have_fr)
langs += "-fr";
if (have_de)
@ -716,11 +715,12 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
if (EnableDeepL)
{
string sender_lang = SM->getLanguageCodeString(ci->Language);
if (ucstr[0] == '>') // Sent directly when prefixed by '>', it's the anti-translation code
chatInGroup( grpId, ucstr.substr(1), sender );
else if (senderClient.dontSendTranslation(senderLang))
chatInGroup( grpId, ucstr, sender );
else
_Log.displayNL("region:%s|%s|*|%s-*|%s", grpId.toString().c_str(), fullName.c_str(), sender_lang.c_str(), ucstr.toString().c_str() );
_Log.displayNL("region:%s|%s|*|%s-*|%s", grpId.toString().c_str(), fullName.c_str(), senderLang.c_str(), ucstr.toUtf8().c_str() );
}
else
chatInGroup( grpId, ucstr, sender );
@ -761,14 +761,16 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
bool sendToMongo = true;
bool sendToAllUni = false;
string autosub = "1";
string autoSub = "1";
uint8 startPos = 0;
string mongoText = ucstr.toUtf8();
string chatId = "all";
string chatType = "univers";
string usedlang = SM->getLanguageCodeString(ci->Language);
if (EnableDeepL)
string usedlang = senderLang;
if (EnableDeepL && !senderClient.dontSendTranslation(senderLang))
{
chatType = "dynamic";
if (ucstr[0] == '>') // Sent directly when prefixed by '>', it's the anti-translation code
@ -788,7 +790,7 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
source_lang = mongoText.substr(6, 2);
string sourceText = mongoText.substr(9, endOfOriginal-9);
strFindReplace(sourceText, ")", "}");
mongoText = "["+source_lang+"](http://chatdev.ryzom.com/channel/pub-universe-"+source_lang+"? "+sourceText+") "+mongoText.substr(endOfOriginal+4, mongoText.size()-endOfOriginal-4);
mongoText = "["+source_lang+"](http://chat.ryzom.com/channel/pub-universe-"+source_lang+"? "+sourceText+") "+mongoText.substr(endOfOriginal+4, mongoText.size()-endOfOriginal-4);
}
else
{
@ -796,14 +798,14 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
mongoText = mongoText.substr(4, mongoText.size()-4);
}
if (source_lang == "en") // in RC the icon are :us:
mongoText = ":us:"+mongoText;
if (source_lang == "en") // in RC the icon are :gb:
mongoText = ":gb:"+mongoText;
else
mongoText = ":"+source_lang+":"+mongoText;
chatId = "FACTION_"+toUpper(usedlang);
if (usedlang != SM->getLanguageCodeString(ci->Language))
autosub = "0";
autoSub = "0";
}
else
@ -813,8 +815,7 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
}
else
{
string sender_lang = SM->getLanguageCodeString(ci->Language);
_Log.displayNL("%s|%s|*|%s-*|%s", "universe", fullName.c_str(), sender_lang.c_str(), ucstr.toUtf8().c_str());
_Log.displayNL("%s|%s|*|%s-*|%s", "universe", fullName.c_str(), senderLang.c_str(), ucstr.toUtf8().c_str());
sendToMongo = false;
}
}
@ -826,15 +827,14 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
{
if (sendToAllUni)
{
string userlang = SM->getLanguageCodeString(ci->Language);
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': '%s', 'chatId': 'FACTION_EN', 'date': %f, 'ig': true, 'autosub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), chatType.c_str(), date, userlang == "en"?"1":"0"));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': '%s', 'chatId': 'FACTION_DE', 'date': %f, 'ig': true, 'autosub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), chatType.c_str(), date, userlang == "de"?"1":"0"));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': '%s', 'chatId': 'FACTION_ES', 'date': %f, 'ig': true, 'autosub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), chatType.c_str(), date, userlang == "es"?"1":"0"));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': '%s', 'chatId': 'FACTION_FR', 'date': %f, 'ig': true, 'autosub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), chatType.c_str(), date, userlang == "fr"?"1":"0"));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': '%s', 'chatId': 'FACTION_RU', 'date': %f, 'ig': true, 'autosub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), chatType.c_str(), date, userlang == "ru"?"1":"0"));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': '%s', 'chatId': 'FACTION_EN', 'date': %f, 'ig': true, 'autoSub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), chatType.c_str(), date, senderLang == "en"?"1":"0"));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': '%s', 'chatId': 'FACTION_DE', 'date': %f, 'ig': true, 'autoSub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), chatType.c_str(), date, senderLang == "de"?"1":"0"));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': '%s', 'chatId': 'FACTION_ES', 'date': %f, 'ig': true, 'autoSub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), chatType.c_str(), date, senderLang == "es"?"1":"0"));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': '%s', 'chatId': 'FACTION_FR', 'date': %f, 'ig': true, 'autoSub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), chatType.c_str(), date, senderLang == "fr"?"1":"0"));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': '%s', 'chatId': 'FACTION_RU', 'date': %f, 'ig': true, 'autoSub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), chatType.c_str(), date, senderLang == "ru"?"1":"0"));
}
else
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': '%s', 'chatId': '%s', 'date': %f, 'ig': true, 'autosub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), chatType.c_str(), chatId.c_str(), date, autosub.c_str()));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': '%s', 'chatId': '%s', 'date': %f, 'ig': true, 'autoSub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), chatType.c_str(), chatId.c_str(), date, autoSub.c_str()));
}
#endif
@ -866,7 +866,7 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
double date = 1000.0*(double)CTime::getSecondsSince1970();
#ifdef HAVE_MONGO
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'guildId', 'chatId': '%s', 'date': %f, 'ig': true, 'autosub': 1 }", CMongo::quote(fullName).c_str(), CMongo::quote(ucstr.toUtf8()).c_str(), sGuildId.str().c_str(), date));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'guildId', 'chatId': '%s', 'date': %f, 'ig': true, 'autoSub': 1 }", CMongo::quote(fullName).c_str(), CMongo::quote(ucstr.toUtf8()).c_str(), sGuildId.str().c_str(), date));
#endif
chatInGroup( grpId, ucstr, sender );
}
@ -892,158 +892,186 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
}
}
const std::string *tmpChatId = _ChanNames.getB(chanId);
string chatId;
if (tmpChatId)
chatId = *tmpChatId;
const std::string *tmpChatId = _ChanNames.getB(chanId);
string chatId;
if (tmpChatId)
chatId = *tmpChatId;
double date = 1000.0*(double)CTime::getSecondsSince1970();
double date = 1000.0*(double)CTime::getSecondsSince1970();
bool sendToMongo = true;
bool sendToAllForge = false;
uint8 startPos = 0;
string mongoText = ucstr.toUtf8();
string usedlang = "";
string autosub = "0";
string mongoText = ucstr.toUtf8();
if (EnableDeepL)
{
if (ucstr[0] == '>') // Sent directly when prefixed by '>', it's the anti-translation code
bool sendMessages = true;
bool sendToAllForge = false;
bool haveOriginMessage = false;
uint8 startPos = 0;
string originLang = senderLang;
string translatedLang = "";
string autoSub = "0";
if (EnableDeepL)
{
startPos = 1;
mongoText = mongoText.substr(1);
string::size_type endOfOriginal = mongoText.find("}@{");
if (mongoText.size() > 4 && mongoText[0] == ':' && mongoText[3] == ':')
if (senderClient.dontSendTranslation(senderLang))
{
startPos = 5;
usedlang = mongoText.substr(1, 2);
string source_lang = usedlang;
if (endOfOriginal != string::npos)
{
if (mongoText.size() > 9)
source_lang = mongoText.substr(6, 2);
string sourceText = mongoText.substr(9, endOfOriginal-9);
strFindReplace(sourceText, ")", "}");
mongoText = "["+source_lang+"](http://chatdev.ryzom.com/channel/pub-forge-"+source_lang+"? "+sourceText+") "+mongoText.substr(endOfOriginal+4, mongoText.size()-endOfOriginal-4);
}
else
sendToAllForge = true;
}
else if (ucstr[0] == '>') // Sent directly when prefixed by '>', it's the anti-translation code
{
startPos = 1;
mongoText = mongoText.substr(1);
string::size_type endOfOriginal = mongoText.find("}@{");
if (mongoText.size() > 4 && mongoText[0] == ':' && mongoText[3] == ':')
{
usedlang = mongoText.substr(1, 2);
mongoText = mongoText.substr(4, mongoText.size()-4);
startPos = 5;
translatedLang = mongoText.substr(1, 2);
if (endOfOriginal != string::npos)
{
haveOriginMessage = true;
if (mongoText.size() > 9)
originLang = mongoText.substr(6, 2);
string originText = mongoText.substr(9, endOfOriginal-9);
strFindReplace(originText, ")", "}");
mongoText = "["+originLang+"](http://chat.ryzom.com/channel/pub-forge-"+originLang+"? "+originText+") "+mongoText.substr(endOfOriginal+4, mongoText.size()-endOfOriginal-4);
}
else
{
originLang = translatedLang;
mongoText = mongoText.substr(4, mongoText.size()-4);
}
if (originLang == "en") // in RC the icon are :gb:
mongoText = ":gb:"+mongoText;
else
mongoText = ":"+originLang+":"+mongoText;
}
else if (chatId == "FACTION_RF") // Only when it's a not translated text
sendToAllForge = true;
if (source_lang == "en") // in RC the icon are :us:
mongoText = ":us:"+mongoText;
else
mongoText = ":"+source_lang+":"+mongoText;
}
else if (chatId == "FACTION_RF")
sendToAllForge = true;
}
else if (chatId == "FACTION_RF" || chatId == "FACTION_EN" || chatId == "FACTION_DE" || chatId == "FACTION_FR" || chatId == "FACTION_ES" || chatId == "FACTION_RU")
{
usedlang = SM->getLanguageCodeString(ci->Language);
_Log.displayNL("%s|%s|*|%s-*|%s", string("#"+chatId).c_str(), fullName.c_str(), usedlang.c_str(), ucstr.toUtf8().c_str());
sendToMongo = false;
// Send for translation
else if (chatId == "FACTION_RF" || chatId == "FACTION_EN" || chatId == "FACTION_DE" || chatId == "FACTION_FR" || chatId == "FACTION_ES" || chatId == "FACTION_RU")
{
_Log.displayNL("%s|%s|*|%s-*|%s", string("#"+chatId).c_str(), fullName.c_str(), senderLang.c_str(), ucstr.toUtf8().c_str());
sendMessages = false; // We need translated it before
}
}
}
#ifdef HAVE_MONGO
if (sendToMongo) // only send to mongo if it's not a translated message
if (sendMessages) // only send to mongo if it's not a message to translate
{
string userlang = SM->getLanguageCodeString(ci->Language);
#ifdef HAVE_MONGO
if (sendToAllForge)
{
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'dynamic', 'chatId': 'FACTION_RF-EN', 'date': %f, 'ig': true, 'autosub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), date, userlang == "en"?"1":"0"));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'dynamic', 'chatId': 'FACTION_RF-DE', 'date': %f, 'ig': true, 'autosub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), date, userlang == "de"?"1":"0"));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'dynamic', 'chatId': 'FACTION_RF-ES', 'date': %f, 'ig': true, 'autosub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), date, userlang == "es"?"1":"0"));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'dynamic', 'chatId': 'FACTION_RF-FR', 'date': %f, 'ig': true, 'autosub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), date, userlang == "fr"?"1":"0"));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'dynamic', 'chatId': 'FACTION_RF-RU', 'date': %f, 'ig': true, 'autosub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), date, userlang == "ru"?"1":"0"));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'dynamic', 'chatId': 'FACTION_RF-EN', 'date': %f, 'ig': true, 'autoSub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), date, senderLang == "en"?"1":"0"));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'dynamic', 'chatId': 'FACTION_RF-DE', 'date': %f, 'ig': true, 'autoSub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), date, senderLang == "de"?"1":"0"));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'dynamic', 'chatId': 'FACTION_RF-ES', 'date': %f, 'ig': true, 'autoSub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), date, senderLang == "es"?"1":"0"));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'dynamic', 'chatId': 'FACTION_RF-FR', 'date': %f, 'ig': true, 'autoSub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), date, senderLang == "fr"?"1":"0"));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'dynamic', 'chatId': 'FACTION_RF-RU', 'date': %f, 'ig': true, 'autoSub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), date, senderLang == "ru"?"1":"0"));
}
else
{
if (chatId == "FACTION_RF")
chatId = "FACTION_RF-"+toUpper(usedlang);
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'dynamic', 'chatId': '%s', 'date': %f, 'ig': true, 'autosub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), chatId.c_str(), date, userlang == usedlang?"1":"0"));
{
if (translatedLang.empty())
chatId = "FACTION_RF-"+toUpper(senderLang);
else
chatId = "FACTION_RF-"+toUpper(translatedLang);
}
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'dynamic', 'chatId': '%s', 'date': %f, 'ig': true, 'autoSub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), chatId.c_str(), date, (translatedLang.empty() || translatedLang == senderLang)?"1":"0"));
}
}
#endif
if (!session->getChan()->getDontBroadcastPlayerInputs() && startPos != 0)
{
// add msg to the historic
CDynChatChan::CHistoricEntry entry;
entry.String = ucstr;
if (ci != NULL)
entry.SenderString = ci->Name;
else
entry.SenderString = "";
if (!session->getChan()->getDontBroadcastPlayerInputs())
{
// add msg to the historic
CDynChatChan::CHistoricEntry entry;
entry.String = ucstr;
if (ci != NULL)
entry.SenderString = ci->Name;
else
entry.SenderString = "";
session->getChan()->Historic.push(entry);
session->getChan()->Historic.push(entry);
ucstring content;
if (!session->getChan()->HideBubble)
{ //normal case
content = ucstr;
}
else
{
// true for control channel (Ring)
ucstring tmp("{no_bubble}");
if (ucstr.find(tmp) == ucstring::npos)
{
tmp += ucstr;
content.swap(tmp);
ucstring content;
if (!session->getChan()->HideBubble)
{ //normal case
content = ucstr;
}
else
{
content = ucstr;
// true for control channel (Ring)
ucstring tmp("{no_bubble}");
if (ucstr.find(tmp) == ucstring::npos)
{
tmp += ucstr;
content.swap(tmp);
}
else
{
content = ucstr;
}
}
}
// broadcast to other client in the channel
CDynChatSession *dcc = session->getChan()->getFirstSession();
while (dcc)
// broadcast to other client in the channel
CDynChatSession *dcc = session->getChan()->getFirstSession();
while (dcc)
{
NLMISC::CEntityId receiverId = TheDataset.getEntityId(dcc->getClient()->getID());
CCharacterInfos* co = IOS->getCharInfos(receiverId);
CChatClient &receiverClient = getClient(dcc->getClient()->getID());
bool canSendChat = true;
if (EnableDeepL)
{
if (receiverClient.dontReceiveTranslation(originLang))
{
if (haveOriginMessage) // Only send untranslated message
canSendChat = false;
}
else if (!translatedLang.empty() && translatedLang != SM->getLanguageCodeString(co->Language))
canSendChat = false;
}
if (canSendChat)
sendChat(itCl->second->getChatMode(), dcc->getClient()->getID(), content.substr(startPos), sender, chanId);
dcc = dcc->getNextChannelSession(); // next session in this channel
}
}
else
{
NLMISC::CEntityId receiverId = TheDataset.getEntityId(dcc->getClient()->getID());
CCharacterInfos* co = IOS->getCharInfos(receiverId);
if (!EnableDeepL || usedlang.empty() || usedlang == SM->getLanguageCodeString(co->Language))
sendChat(itCl->second->getChatMode(), dcc->getClient()->getID(), content.substr(startPos), sender, chanId);
dcc = dcc->getNextChannelSession(); // next session in this channel
// only send an echo to the sender
if (!EnableDeepL) // only send an echo to the sender
sendChat(itCl->second->getChatMode(), itCl->first, ucstr, sender, chanId);
}
}
else
{
// only send an echo to the sender
if (!EnableDeepL || usedlang.empty()) // only send an echo to the sender
sendChat(itCl->second->getChatMode(), itCl->first, ucstr, sender, chanId);
}
if (session->getChan()->getForwardPlayerIntputToOwnerService())
{
// send player input to service owner
NLNET::TServiceId serviceId(chanId.getCreatorId());
if (session->getChan()->getForwardPlayerIntputToOwnerService())
{
// send player input to service owner
NLNET::TServiceId serviceId(chanId.getCreatorId());
TPlayerInputForward pif;
pif.ChanID = chanId;
pif.Sender = sender;
pif.Content = ucstr;
TPlayerInputForward pif;
pif.ChanID = chanId;
pif.Sender = sender;
pif.Content = ucstr;
CMessage msgout( "DYN_CHAT:FORWARD");
msgout.serial(pif);
CMessage msgout( "DYN_CHAT:FORWARD");
msgout.serial(pif);
CUnifiedNetwork::getInstance()->send(serviceId, msgout);
}
if (session->getChan()->getUnifiedChannel())
{
// send the text to other shards
if (IChatUnifierClient::getInstance())
IChatUnifierClient::getInstance()->sendUnifiedDynChat(session->getChan()->getID(), senderName, ucstr);
CUnifiedNetwork::getInstance()->send(serviceId, msgout);
}
if (session->getChan()->getUnifiedChannel())
{
// send the text to other shards
if (IChatUnifierClient::getInstance())
IChatUnifierClient::getInstance()->sendUnifiedDynChat(session->getChan()->getID(), senderName, ucstr);
}
}
}
}
@ -1098,13 +1126,22 @@ void CChatManager::chatInGroup( TGroupId& grpId, const ucstring& ucstr, const TD
list<CEntityId> logDest;
uint8 startPos = 0;
string usedlang;
if (EnableDeepL && ucstr.length() > 4 && ucstr[0] == ':' && ucstr[3] == ':') // check lang prefix
string usedlang = "";
string str = ucstr.toString();
if (EnableDeepL && str.length() > 4 && str[0] == ':' && str[3] == ':') // check lang prefix
{
usedlang = ucstr.toString().substr(1, 2);
usedlang = str.substr(1, 2);
startPos = 4;
}
bool areOriginal = true;
string originLang = usedlang;
if (EnableDeepL && str.length() > 8 && str[4] == '{' && str[5] == ':' && str[8] == ':') // check lang origin
{
areOriginal = false;
originLang = str.substr(6, 2);
}
for( itM = chatGrp.Members.begin(); itM != chatGrp.Members.end(); ++itM )
{
CMirrorPropValueRO<uint32> instanceId( TheDataset, *itM, DSPropertyAI_INSTANCE );
@ -1113,7 +1150,14 @@ void CChatManager::chatInGroup( TGroupId& grpId, const ucstring& ucstr, const TD
{
NLMISC::CEntityId receiverId = TheDataset.getEntityId(*itM);
CCharacterInfos* co = IOS->getCharInfos(receiverId);
if (usedlang != SM->getLanguageCodeString(co->Language))
CChatClient &client = getClient(*itM);
if (client.dontReceiveTranslation(originLang))
{
if (!areOriginal)
continue;
}
else if (usedlang != SM->getLanguageCodeString(co->Language))
continue;
}
@ -1907,7 +1951,7 @@ void CChatManager::sendFarChat(const string &name, const ucstring& ucstr, const
source_lang = mongoText.substr(6, 2);
string sourceText = mongoText.substr(9, endOfOriginal-9);
strFindReplace(sourceText, ")", "}");
mongoText = "["+source_lang+"](http://chatdev.ryzom.com/channel/"+rc_channel+source_lang+"? "+sourceText+") "+mongoText.substr(endOfOriginal+4, mongoText.size()-endOfOriginal-4);
mongoText = "["+source_lang+"](http://chat.ryzom.com/channel/"+rc_channel+source_lang+"? "+sourceText+") "+mongoText.substr(endOfOriginal+4, mongoText.size()-endOfOriginal-4);
}
else
{
@ -1916,8 +1960,8 @@ void CChatManager::sendFarChat(const string &name, const ucstring& ucstr, const
}
if (source_lang == "en") // in RC the icon are :us:
mongoText = ":us:"+mongoText;
if (source_lang == "en") // in RC the icon are :gb:
mongoText = ":gb:"+mongoText;
else
mongoText = ":"+source_lang+":"+mongoText;

@ -65,7 +65,7 @@ void cbImpulsionReadyString( CMessage& msgin, const string &serviceName, TServic
msgin.serial(sender);
msgin.serial(nbBitsToSkip);
msgin.serialMemStream(bms);
// Unpack bitmemstream
uint32 xmlcode;
bms.serial(xmlcode, nbBitsToSkip); // the XML code was already read by tbe sender service
@ -179,7 +179,7 @@ void cbImpulsionChatTeam( CMessage& msgin, const string &serviceName, TServiceId
}
try
{
{
TDataSetRow senderRow = TheDataset.getDataSetRow(sender);
// get current chat mode
const CChatGroup::TGroupType chatModeBck = IOS->getChatManager().getClient(senderRow).getChatMode();
@ -189,7 +189,7 @@ void cbImpulsionChatTeam( CMessage& msgin, const string &serviceName, TServiceId
// send the message
IOS->getChatManager().chat( senderRow, ucstr );
// reset chat mode to old value
IOS->getChatManager().getClient(senderRow).setChatMode( chatModeBck );
IOS->getChatManager().getClient(senderRow).setChatMode( chatModeBck );
}
catch(const Exception &e)
{
@ -240,19 +240,19 @@ void cbImpulsionTell( CMessage& msgin, const string &serviceName, TServiceId ser
static void updateIgnoreStatus(CMessage& msgin, const string &serviceName, TServiceId serviceId, bool ignored)
{
CEntityId senderId;
CEntityId ignoredId;
CEntityId ignoredId;
try
{
msgin.serial(senderId);
msgin.serial(ignoredId);
IOS->getChatManager().getClient(TheDataset.getDataSetRow(senderId)).setIgnoreStatus(ignoredId, ignored);
IOS->getChatManager().getClient(TheDataset.getDataSetRow(senderId)).setIgnoreStatus(ignoredId, ignored);
}
catch(const Exception &e)
{
nlwarning("<impulsionIgnore> %s",e.what());
return;
}
}
}
//-----------------------------------------------
@ -261,7 +261,7 @@ static void updateIgnoreStatus(CMessage& msgin, const string &serviceName, TServ
//-----------------------------------------------
void cbImpulsionIgnore( CMessage& msgin, const string &serviceName, TServiceId serviceId )
{
updateIgnoreStatus(msgin, serviceName, serviceId, true);
updateIgnoreStatus(msgin, serviceName, serviceId, true);
} // impulsionIgnore //
//-----------------------------------------------
@ -281,7 +281,7 @@ void cbImpulsionUnignoreAll( CMessage& msgin, const string &serviceName, TServic
{
CEntityId senderId;
vector<CEntityId> ignoredIds;
try
{
msgin.serial(senderId);
@ -366,7 +366,7 @@ void cbImpulsionChatMode( CMessage& msgin, const string &serviceName, TServiceId
msgin.serial(sender);
uint8 chatMode;
TChanID chanID;
TChanID chanID;
try
{
msgin.serial( chatMode );
@ -393,8 +393,8 @@ void cbImpulsionChatMode( CMessage& msgin, const string &serviceName, TServiceId
IOS->getChatManager().getClient(TheDataset.getDataSetRow(sender)).setChatMode( static_cast<CChatGroup::TGroupType>(chatMode));
nldebug("IOS: Chat mode --> %s", DebugChatModeName[chatMode]);
break;
case CChatGroup::dyn_chat:
IOS->getChatManager().getClient(TheDataset.getDataSetRow(sender)).setChatMode( static_cast<CChatGroup::TGroupType>(chatMode), chanID);
case CChatGroup::dyn_chat:
IOS->getChatManager().getClient(TheDataset.getDataSetRow(sender)).setChatMode( static_cast<CChatGroup::TGroupType>(chatMode), chanID);
break;
default:
if (chatMode < CChatGroup::nbChatMode)
@ -542,7 +542,7 @@ static void cbChatMessage(CMessage& msgin, const string &serviceName, TServiceId
CChatGroup::TGroupType oldMode = IOS->getChatManager().getClient(entityId).getChatMode();
if ( oldMode != CChatGroup::say )
IOS->getChatManager().getClient(entityId).setChatMode(CChatGroup::say);
IOS->getChatManager().getClient(entityId).updateAudience();
IOS->getChatManager().chat( entityId, str );
@ -620,7 +620,7 @@ static void cbCharacterNameId(CMessage& msgin, const string &serviceName, TServi
{
// read character id
msgin.serial( chId );
// character's string Id
msgin.serial( stringId );
}
@ -630,7 +630,7 @@ static void cbCharacterNameId(CMessage& msgin, const string &serviceName, TServi
return;
}
IOS->addCharacterName( chId, SM->getString( stringId ), TSessionId(0) );
} // cbCharacterNameId //
//-----------------------------------------------
@ -777,7 +777,7 @@ static void cbAddNamedGroup( CMessage& msgin, const string &serviceName, TServic
IOS->getChatManager().addGroup( gId, (CChatGroup::TGroupType)gType, name );
if (VerboseChatManagement)
nldebug("IOS: cbAddGroup Adding named group %s with type '%s' as '%s'",
nldebug("IOS: cbAddGroup Adding named group %s with type '%s' as '%s'",
gId.toString().c_str(),
CChatGroup::groupTypeToString((CChatGroup::TGroupType)gType).c_str(),
name.c_str());
@ -913,7 +913,7 @@ static void cbRemoveFromGroup( CMessage& msgin, const string &serviceName, TServ
// {
// try
// {
// if( IOS->getChatManager().getClient(clientInfos->DataSetIndex).knowString(entityInfos->OldNameIndex) == false )
// if( IOS->getChatManager().getClient(clientInfos->DataSetIndex).knowString(entityInfos->OldNameIndex) == false )
// {
// IOS->getChatManager().addDynStr( clientId, entityInfos->OldNameIndex, serviceId );
// }
@ -1022,13 +1022,13 @@ void cbNpcTellEx( CMessage& msgin, const string &serviceName, TServiceId service
TDataSetRow sender;
TDataSetRow receiver;
uint32 phraseId;
msgin.serial(sender);
msgin.serial(receiver);
msgin.serial(phraseId);
CChatManager &cm = IOS->getChatManager();
try
{
// TDataSetRow dsr = TheDataset.getDataSetRow(sender);
@ -1056,19 +1056,19 @@ void cbNpcChatEx( CMessage& msgin, const string &serviceName, TServiceId service
TDataSetRow sender;
CChatGroup::TGroupType type = CChatGroup::nbChatMode;
uint32 phraseId;
msgin.serial(sender);
msgin.serialEnum(type);
msgin.serial(phraseId);
CChatManager &cm = IOS->getChatManager();
try
{
// TDataSetRow dsr = TheDataset.getDataSetRow(sender);
if (sender == INVALID_DATASET_ROW)
{
nlwarning("cbNpcChatEx : ignoring chat because NPC %s:%x Invalid",
nlwarning("cbNpcChatEx : ignoring chat because NPC %s:%x Invalid",
TheDataset.getEntityId(sender).toString().c_str(),
sender.getIndex());
return;
@ -1106,7 +1106,7 @@ void cbNpcChat( CMessage& msgin, const string &serviceName, TServiceId serviceId
// TDataSetRow dsr = TheDataset.getDataSetRow(sender);
if ( !sender.isValid() || !TheDataset.isDataSetRowStillValid(sender) )
{
nlwarning("cbNpcChat : ignoring chat because NPC %x not yet/not anymore in mirror",
nlwarning("cbNpcChat : ignoring chat because NPC %x not yet/not anymore in mirror",
sender.getIndex());
return;
}
@ -1153,7 +1153,7 @@ void cbNpcChatParam( CMessage& msgin, const string &serviceName, NLNET::TService
// TDataSetRow dsr = TheDataset.getDataSetRow(sender);
if ( !sender.isValid() || !TheDataset.isDataSetRowStillValid(sender) )
{
nlwarning("cbNpcChat : ignoring chat because NPC %x not yet/not anymore in mirror",
nlwarning("cbNpcChat : ignoring chat because NPC %x not yet/not anymore in mirror",
sender.getIndex());
return;
}
@ -1190,7 +1190,7 @@ void cbNpcChatSentence( CMessage& msgin, const string &serviceName, TServiceId s
// TDataSetRow dsr = TheDataset.getDataSetRow(sender);
if ( !sender.isValid() || !TheDataset.isDataSetRowStillValid(sender) )
{
nlwarning("cbNpcChatSentence : ignoring chat because NPC %x not yet/not anymore in mirror",
nlwarning("cbNpcChatSentence : ignoring chat because NPC %x not yet/not anymore in mirror",
sender.getIndex());
return;
}
@ -1247,7 +1247,7 @@ void cbNpcChatSentenceChannel( CMessage& msgin, const string &serviceName, TServ
msgin.serial(id);
msgin.serial(sender);
msgin.serial(sentence);
if(sender.isValid())
{
CChatManager &cm = IOS->getChatManager();
@ -1287,7 +1287,7 @@ void cbGroupDynString( CMessage& msgin, const string &serviceName, TServiceId se
nlwarning("cbGroupDynString : ignoring group message because entity %x not yet in mirror", sender.getIndex());
return;
}
list<CReceiver> receiverList;
CChatClient &client = cm.getClient(sender);
@ -1297,7 +1297,7 @@ void cbGroupDynString( CMessage& msgin, const string &serviceName, TServiceId se
CChatGroup::TMemberCont::iterator itM;
for( itM = group.Members.begin(); itM != group.Members.end(); ++itM )
{
const CEntityId &id = TheDataset.getEntityId(*itM);
const CEntityId &id = TheDataset.getEntityId(*itM);
// skip it if excluded
if ( std::find(excluded.begin(), excluded.end(), id) != excluded.end() )
@ -1317,7 +1317,7 @@ void cbGroupDynString( CMessage& msgin, const string &serviceName, TServiceId se
msgout.serialBufferWithSize((uint8*)bms.buffer(), bms.length());
CUnifiedNetwork::getInstance()->send( TServiceId(id.getDynamicId()), msgout );
}
}
}
}
catch(const CChatManager::EChatClient &)
{
@ -1476,9 +1476,9 @@ void cbEmoteCrowd( CMessage& msgin, const string &serviceName, TServiceId servic
string phraseTextId;
TVectorParamCheck params;
vector<TDataSetRow> ignored;
CChatManager &cm = IOS->getChatManager();
try
{
msgin.serial(sender);
@ -1534,9 +1534,9 @@ void cbCustomEmote( CMessage& msgin, const string &serviceName, TServiceId servi
{
TDataSetRow sender;
ucstring emoteCustomText;
CChatManager &cm = IOS->getChatManager();
try
{
msgin.serial(sender);
@ -1544,7 +1544,7 @@ void cbCustomEmote( CMessage& msgin, const string &serviceName, TServiceId servi
// filter emote text
emoteCustomText = IOS->getChatManager().filterClientInputColorCode(emoteCustomText);
// get the player
if ( sender == TDataSetRow::createFromRawIndex(INVALID_DATASET_ROW) )
{
@ -1638,7 +1638,7 @@ void addSession(TDataSetRow client,TChanID chan,bool writeRight)
IOS->getChatManager().addClient( client );
}
CDynChatSession *session = IOS->getChatManager().getDynChat().addSession(chan, client);
if (!session)
if (!session)
{
nlwarning("Couldn't create session");
return;
@ -1665,7 +1665,7 @@ void cbDynChatAddSession(CMessage& msgin, const string &serviceName, TServiceId
IOS->getChatManager().addClient( client );
}
CDynChatSession *session = IOS->getChatManager().getDynChat().addSession(chan, client);
if (!session)
if (!session)
{
nlwarning("Couldn't create session");
return;
@ -1691,7 +1691,7 @@ void cbDynChatAddSessionWithName(CMessage& msgin, const string &serviceName, TSe
msgin.serial(chan);
msgin.serial(clientName);
msgin.serial(writeRight);
if(chan.isUnknownId())
{
nlwarning("unknown channel id! unable to add session!");
@ -1707,7 +1707,7 @@ void cbDynChatAddSessionWithName(CMessage& msgin, const string &serviceName, TSe
IOS->getChatManager().addClient( client );
CDynChatSession *session = IOS->getChatManager().getDynChat().addSession(chan, client);
if (!session)
if (!session)
{
nlwarning("Couldn't create session");
return;
@ -1730,9 +1730,9 @@ void cbDynChatAddSessionWithName(CMessage& msgin, const string &serviceName, TSe
void cbDynChatRemoveSession(CMessage& msgin, const string &serviceName, TServiceId serviceId)
{
TChanID chan;
TDataSetRow client;
TDataSetRow client;
msgin.serial(chan);
msgin.serial(client);
msgin.serial(client);
bool res = IOS->getChatManager().getDynChat().removeSession(chan, client);
if (!res) nlwarning("Couldn't remove session");
}
@ -1745,7 +1745,7 @@ void cbDynChatRemoveSessionWithName(CMessage& msgin, const string &serviceName,
{
TChanID chan;
ucstring clientName;
TDataSetRow client;
TDataSetRow client;
msgin.serial(chan);
msgin.serial(clientName);
CCharacterInfos* cInfo = IOS->getCharInfos(clientName);
@ -1760,9 +1760,9 @@ void cbDynChatRemoveSessionWithName(CMessage& msgin, const string &serviceName,
return;
}*/
bool res = IOS->getChatManager().getDynChat().removeSession(chan, client);
if (!res) nlwarning("Couldn't remove session");
if (!res) nlwarning("Couldn't remove session");
}
}
//-----------------------------------------------
@ -1772,10 +1772,10 @@ void cbDynChatRemoveSessionWithName(CMessage& msgin, const string &serviceName,
void cbDynChatSetWriteRight(CMessage& msgin, const string &serviceName, TServiceId serviceId)
{
TChanID chan;
TDataSetRow client;
TDataSetRow client;
bool writeRight;
msgin.serial(chan);
msgin.serial(client);
msgin.serial(client);
msgin.serial(writeRight);
CDynChatSession *session = IOS->getChatManager().getDynChat().getSession(chan, client);
if (!session)
@ -1794,7 +1794,7 @@ void cbDynChatSetHistoricSize(CMessage& msgin, const string &serviceName, TServi
TChanID chanID;
uint32 historicSize;
msgin.serial(chanID);
msgin.serial(historicSize);
msgin.serial(historicSize);
CDynChatChan *chan = IOS->getChatManager().getDynChat().getChan(chanID);
if (!chan)
{
@ -1807,10 +1807,10 @@ void cbDynChatSetHideBubble(CMessage& msgin, const string &serviceName, TService
{
TChanID chanID;
bool hideBubble;
msgin.serial(chanID);
msgin.serial(hideBubble);
CChatManager &cm = IOS->getChatManager();
CDynChatChan *chan = cm.getDynChat().getChan(chanID);
if (!chan)
@ -1825,10 +1825,10 @@ void cbDynChatSetUniversalChannel(CMessage& msgin, const string &serviceName, TS
{
TChanID chanID;
bool universalChannel;
msgin.serial(chanID);
msgin.serial(universalChannel);
CChatManager &cm = IOS->getChatManager();
CDynChatChan *chan = cm.getDynChat().getChan(chanID);
if (!chan)
@ -1868,10 +1868,10 @@ void cbDynChatServiceChat(CMessage& msgin, const string &serviceName, TServiceId
if(!dcc) nlwarning(("nobody hears on channel "+chanID.toString()).c_str());
while (dcc)
{
{
cm.sendChat(CChatGroup::dyn_chat, dcc->getClient()->getID(), text, TDataSetRow(), chanID, senderName);
dcc = dcc->getNextChannelSession(); // next session in this channel
}
}
}
void cbDynChatServiceTell(CMessage& msgin, const string &serviceName, TServiceId serviceId)
@ -1908,7 +1908,7 @@ void cbDynChatServiceTell(CMessage& msgin, const string &serviceName, TServiceId
break;
}
dcc = dcc->getNextChannelSession(); // next session in this channel
}
}
}
//-----------------------------------------------
@ -1921,7 +1921,7 @@ void cbDynChatReset(CMessage& msgin, const string &serviceName, TServiceId servi
}
//-----------------------------------------------
// update the alias list
// update the alias list
//
//-----------------------------------------------
void cbUpdateAIAlias(CMessage& msgin, const string &serviceName, TServiceId serviceId)
@ -1932,22 +1932,22 @@ void cbUpdateAIAlias(CMessage& msgin, const string &serviceName, TServiceId serv
uint32 subcommand;
msgin.serial(subcommand);
switch(subcommand)
{
{
case Set:
IOS->getAIAliasManager().clear();
case Add:
{
uint32 size;
msgin.serial(size);
uint first = 0;
uint last = size;
for ( ;first != last; ++first)
{
{
uint32 alias;
std::string name;
msgin.serial(alias);
@ -1956,7 +1956,7 @@ void cbUpdateAIAlias(CMessage& msgin, const string &serviceName, TServiceId serv
}
}
break;
/*
case Add: break;
case Delete: break;
@ -2006,7 +2006,7 @@ void cbUserDontTranslateLanguages( CMessage& msgin, const string &serviceName, T
if (player == INVALID_DATASET_ROW)
{
nlwarning("cbUserTranslateLanguage : ignoring chat because Player %s:%x Invalid",
nlwarning("cbUserTranslateLanguage : ignoring chat because Player %s:%x Invalid",
TheDataset.getEntityId(player).toString().c_str(),
player.getIndex());
return;
@ -2019,12 +2019,19 @@ void cbUserDontTranslateLanguages( CMessage& msgin, const string &serviceName, T
CChatClient &client = cm.getClient(player);
nlinfo("USER DISBALED TRANSLATIONS: %s", langs.c_str());
vector<string> vlangs;
NLMISC::splitString(langs, "|", vlangs);
client.resetDisabledTranslations();
for (uint i=0; i<vlangs.size(); i++)
{
client.disableTranslation(vlangs[i]);
if (vlangs[i].size() == 3)
{
if (vlangs[i][0] == '>')
client.disableSendTranslation(vlangs[i].substr(1));
else if (vlangs[i][0] == '<')
client.disableReceiveTranslation(vlangs[i].substr(1));
}
}
}
@ -2071,7 +2078,7 @@ TUnifiedCallbackItem CbIOSArray[]=
// { "READY_STRING", cbImpulsionReadyString },
{ "CLIENT:STRING:CHAT", cbImpulsionChat },
{ "CLIENT:STRING:CHAT_TEAM", cbImpulsionChatTeam },
{ "CLIENT:STRING:TELL", cbImpulsionTell },
{ "CLIENT:STRING:TELL", cbImpulsionTell },
{ "CLIENT:STRING:FILTER", cbImpulsionFilter },
{ "CLIENT:STRING:CHAT_MODE", cbImpulsionChatMode },
{ "CLIENT:STRING:AFK_TXT", cbImpulsionAfkTxt },
@ -2092,8 +2099,8 @@ TUnifiedCallbackItem CbIOSArray[]=
{ "REMOVE_FROM_GROUP", cbRemoveFromGroup },
// { "SEND_DYNAMIC_ID", cbSendDynamicId },
{ "CHAT", cbSysChat }, // talk to a user or a whole group
{ "NPC_CHAT", cbNpcChat }, // Npc talk to a chat group
{ "NPC_CHAT", cbNpcChat }, // Npc talk to a chat group
{ "NPC_CHAT_PARAM", cbNpcChatParam }, // Npc talk to a chat group (with parameter)
{ "NPC_TELL", cbNpcTell }, // Npc tell to a player
@ -2104,7 +2111,7 @@ TUnifiedCallbackItem CbIOSArray[]=
{ "NPC_CHAT_SENTENCE", cbNpcChatSentence}, //Npc chat. receive the sentence to chat
{ "NPC_CHAT_SENTENCE_CHANNEL",cbNpcChatSentenceChannel},
{ "NPC_CHAT_SENTENCE_EX",cbNpcChatSentenceEx},//Npc chat. receive the name of the npc which talks, and the sentence
{ "GROUP_DYN_STRING", cbGroupDynString }, // send a system dynamic string to a group
{ "PHRASE", cbPhrasePrepare },
{ "PHRASE_DEBUG", cbPhrasePrepareDebug },
@ -2130,7 +2137,7 @@ TUnifiedCallbackItem CbIOSArray[]=
{ "EMOTE_CROWD", cbEmoteCrowd }, // EGS wants IOS to dispatch an emote texte to all users around the "emoting" player
{ "EMOTE_PLAYER", cbEmoteSolePlayer }, // EGS wants IOS to dispatch an emote texte to a unique player
{ "CUSTOM_EMOTE", cbCustomEmote }, // EGS wants IOS to dispatch an emote custom text to all users around
{ "SET_PHRASE", cbSetPhrase }, // AIS wants IOS to change a phrase content
{ "SET_PHRASE_LANG", cbSetPhraseLang }, // AIS or EGS wants IOS to change a phrase content for a language

Loading…
Cancel
Save