Merge branch 'deepl'

feature/prepare-cross-merge
Ulukyn 4 years ago committed by kaetemi
parent ea095ca4f3
commit e6bb1f2f54
No known key found for this signature in database
GPG Key ID: 9873C4D40BB479BC

@ -4579,9 +4579,12 @@ NLMISC_COMMAND (connectLangChannel, "Connect to lang channel", "<user id> <lang>
string action; string action;
string lang = args[1]; string lang = args[1];
if (lang != "en" && lang != "fr" && lang != "de" && lang != "ru" && lang != "es" && lang != "rf") 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")
return false; return false;
bool leave = false;
bool leave = !c->havePriv(":DEV:"); // Since June 2020, no any lang channels, players only can leave it
if (args.size() > 2) if (args.size() > 2)
leave = args[2] == "1"; leave = args[2] == "1";
TChanID channel = inst->getFactionDynChannel(lang); TChanID channel = inst->getFactionDynChannel(lang);

@ -645,7 +645,7 @@ CCharacter::CCharacter()
_LastUrlIndex = 0; _LastUrlIndex = 0;
_CustomMissionsParams.clear(); _CustomMissionsParams.clear();
_FriendVisibility = VisibleToAll; _FriendVisibility = VisibleToAll;
_LangChannel = "en"; _LangChannel = "rf";
_NewTitle = "Refugee"; _NewTitle = "Refugee";
initDatabase(); initDatabase();

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

@ -1185,6 +1185,11 @@ void CPVPManager2::onIOSMirrorUp()
createExtraFactionChannel("ru", true); createExtraFactionChannel("ru", true);
createExtraFactionChannel("es", true); createExtraFactionChannel("es", true);
createExtraFactionChannel("rf", true); createExtraFactionChannel("rf", true);
createExtraFactionChannel("rf-fr", true);
createExtraFactionChannel("rf-en", true);
createExtraFactionChannel("rf-es", true);
createExtraFactionChannel("rf-ed", true);
createExtraFactionChannel("rf-ru", true);
#ifdef HAVE_MONGO #ifdef HAVE_MONGO
CUniquePtr<DBClientCursor> cursor = CMongo::query("ryzom_channels", toString("{}")); CUniquePtr<DBClientCursor> cursor = CMongo::query("ryzom_channels", toString("{}"));

@ -569,21 +569,17 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
// info for log the chat message // info for log the chat message
string senderName; string senderName;
ucstring ucSenderName; string fullName;
{
// ignore muted users
// if ( _MutedUsers.find( eid ) != _MutedUsers.end() )
// return;
if (ci == NULL) if (ci == NULL)
{ {
senderName = TheDataset.getEntityId(sender).toString(); senderName = TheDataset.getEntityId(sender).toString();
fullName = senderName;
} }
else else
{ {
ucSenderName = ci->Name; fullName = IOS->getRocketName(ci->Name);
senderName = ucSenderName.toString(); senderName = ci->Name.toString();
}
} }
static const char* groupNames[]= static const char* groupNames[]=
@ -622,9 +618,6 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
CChatGroup::TMemberCont::iterator itA; CChatGroup::TMemberCont::iterator itA;
string sender_lang = SM->getLanguageCodeString(ci->Language); string sender_lang = SM->getLanguageCodeString(ci->Language);
if (sender_lang == "en") // 'en' must be converted to 'us' because translation uses :us: code
sender_lang = "us";
for( itA = itCl->second->getAudience().Members.begin(); for( itA = itCl->second->getAudience().Members.begin();
itA != itCl->second->getAudience().Members.end(); itA != itCl->second->getAudience().Members.end();
@ -644,8 +637,6 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
{ {
receiverName = co->Name.toString(); receiverName = co->Name.toString();
receiver_lang = SM->getLanguageCodeString(co->Language); receiver_lang = SM->getLanguageCodeString(co->Language);
if (receiver_lang == "en") // en must be converted to us because translation uses :us: code
receiver_lang = "us";
} }
if (EnableDeepL) if (EnableDeepL)
@ -658,13 +649,14 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
if (ucstr[0] != '>' && client.haveDisabledTranslation(sender_lang)) if (ucstr[0] != '>' && client.haveDisabledTranslation(sender_lang))
receiver_lang = sender_lang; receiver_lang = sender_lang;
if (ucstr[0] == '>') // Sent directly when prefixed by '>', it's the anti-translation code if (ucstr[0] == '>') // Sent directly when prefixed by '>', it's the anti-translation code
{ {
if (ucstr.length() > 5 && ucstr[1] == ':' && ucstr[4] == ':') // check lang prefix if (ucstr.length() > 5 && ucstr[1] == ':' && ucstr[4] == ':') // check lang prefix
{ {
string usedlang = ucstr.toString().substr(2, 2); string usedlang = ucstr.toString().substr(2, 2);
//nlinfo("used: %s, user: %s", usedlang.c_str(), receiver_lang.c_str()); //nlinfo("used: %s, user: %s", usedlang.c_str(), receiver_lang.c_str());
if (usedlang == receiver_lang) if (usedlang == receiver_lang && !client.haveDisabledTranslation(sender_lang))
sendChat( itCl->second->getChatMode(), *itA, ucstr.substr(5), sender ); sendChat( itCl->second->getChatMode(), *itA, ucstr.substr(5), sender );
} }
else else
@ -678,12 +670,11 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
} }
else else
{ {
if (!have_fr && receiver_lang == "fr") if (!have_fr && receiver_lang == "fr")
have_fr = true; have_fr = true;
if (!have_de && receiver_lang == "de") if (!have_de && receiver_lang == "de")
have_de = true; have_de = true;
if (!have_en && receiver_lang == "us") if (!have_en && receiver_lang == "en")
have_en = true; have_en = true;
if (!have_ru && receiver_lang == "ru") if (!have_ru && receiver_lang == "ru")
have_ru = true; have_ru = true;
@ -702,14 +693,14 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
if (have_de) if (have_de)
langs += "-de"; langs += "-de";
if (have_en) if (have_en)
langs += "-us"; langs += "-en";
if (have_ru) if (have_ru)
langs += "-ru"; langs += "-ru";
if (have_es) if (have_es)
langs += "-es"; langs += "-es";
if (nbr_receiver > 0) if (nbr_receiver > 0)
_Log.displayNL("|%s|(%s:%d:%s)|%s", IOS->getRocketName(senderName).c_str(), groupNames[itCl->second->getChatMode()], nbr_receiver, langs.c_str(), ucstr.toUtf8().c_str() ); _Log.displayNL("%s|%s|%d|%s|%s", groupNames[itCl->second->getChatMode()], fullName.c_str(), nbr_receiver, langs.c_str(), ucstr.toUtf8().c_str() );
} }
break; break;
case CChatGroup::region : case CChatGroup::region :
@ -723,10 +714,20 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
TGroupId grpId = itCl->second->getRegionChatGroup(); TGroupId grpId = itCl->second->getRegionChatGroup();
_DestUsers.push_back(grpId); _DestUsers.push_back(grpId);
_Log.displayNL("'%s' (%s) : \t\"%s\"", senderName.c_str(), groupNames[itCl->second->getChatMode()], ucstr.toString().c_str() ); 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
_Log.displayNL("region:%s|%s|*|%s-*|%s", grpId.toString().c_str(), fullName.c_str(), sender_lang.c_str(), ucstr.toString().c_str() );
}
else
chatInGroup( grpId, ucstr, sender ); chatInGroup( grpId, ucstr, sender );
break;
} }
break;
case CChatGroup::universe: case CChatGroup::universe:
{ {
CEntityId eid = TheDataset.getEntityId(sender); CEntityId eid = TheDataset.getEntityId(sender);
@ -754,30 +755,98 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
// } // }
TGroupId grpId = CEntityId(RYZOMID::chatGroup, 0); TGroupId grpId = CEntityId(RYZOMID::chatGroup, 0);
_Log.displayNL("'%s' (%s) : \t\"%s\"", senderName.c_str(), groupNames[itCl->second->getChatMode()], ucstr.toString().c_str() );
_DestUsers.push_back(grpId); _DestUsers.push_back(grpId);
double date = 1000.0*(double)CTime::getSecondsSince1970(); double date = 1000.0*(double)CTime::getSecondsSince1970();
string name; bool sendToMongo = true;
if (!ucSenderName.empty()) bool sendToAllUni = false;
name = IOS->getRocketName(ucSenderName); string autosub = "1";
uint8 startPos = 0;
string mongoText = ucstr.toUtf8();
string chatId = "all";
string chatType = "univers";
string usedlang = SM->getLanguageCodeString(ci->Language);
if (EnableDeepL)
{
chatType = "dynamic";
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] == ':')
{
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-universe-"+source_lang+"? "+sourceText+") "+mongoText.substr(endOfOriginal+4, mongoText.size()-endOfOriginal-4);
}
else
{
usedlang = mongoText.substr(1, 2);
mongoText = mongoText.substr(4, mongoText.size()-4);
}
if (source_lang == "en") // in RC the icon are :us:
mongoText = ":us:"+mongoText;
else
mongoText = ":"+source_lang+":"+mongoText;
chatId = "FACTION_"+toUpper(usedlang);
if (usedlang != SM->getLanguageCodeString(ci->Language))
autosub = "0";
}
else
sendToAllUni = true;
chatInGroup( grpId, ucstr.substr(1), sender );
}
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());
sendToMongo = false;
}
}
else else
name = senderName; chatInGroup( grpId, ucstr, sender );
#ifdef HAVE_MONGO #ifdef HAVE_MONGO
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'univers', 'chatId': 'all', 'date': %f, 'ig': true }", CMongo::quote(name).c_str(), CMongo::quote(ucstr.toUtf8()).c_str(), date)); if (sendToMongo) // only send to mongo if it's not a translated message
{
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"));
}
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()));
}
#endif #endif
chatInGroup( grpId, ucstr, sender );
} }
break; break;
case CChatGroup::team: case CChatGroup::team:
{ {
TGroupId grpId = itCl->second->getTeamChatGroup(); TGroupId grpId = itCl->second->getTeamChatGroup();
_DestUsers.push_back(grpId); _DestUsers.push_back(grpId);
_Log.displayNL("'%s' (%s) : \t\"%s\"", senderName.c_str(), groupNames[itCl->second->getChatMode()], ucstr.toString().c_str() ); _Log.displayNL("'%s' (%s) : %s", fullName.c_str(), groupNames[itCl->second->getChatMode()], ucstr.toString().c_str() );
chatInGroup( grpId, ucstr, sender ); chatInGroup( grpId, ucstr, sender );
} }
break; break;
@ -787,10 +856,7 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
TGroupId grpId = itCl->second->getGuildChatGroup(); TGroupId grpId = itCl->second->getGuildChatGroup();
_DestUsers.push_back(grpId); _DestUsers.push_back(grpId);
_Log.displayNL("'%s' (%s) : \t\"%s\"", _Log.displayNL("%s' (%s) : %s", fullName.c_str(), groupNames[itCl->second->getChatMode()], ucstr.toString().c_str() );
senderName.c_str(),
groupNames[itCl->second->getChatMode()],
ucstr.toString().c_str() );
uint32 guildId = grpId.getShortId() - 0x10000000; uint32 guildId = grpId.getShortId() - 0x10000000;
@ -799,14 +865,8 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
double date = 1000.0*(double)CTime::getSecondsSince1970(); double date = 1000.0*(double)CTime::getSecondsSince1970();
string name;
if (!ucSenderName.empty())
name = IOS->getRocketName(ucSenderName);
else
name = senderName;
#ifdef HAVE_MONGO #ifdef HAVE_MONGO
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'guildId', 'chatId': '%s', 'date': %f, 'ig': true }", CMongo::quote(name).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 #endif
chatInGroup( grpId, ucstr, sender ); chatInGroup( grpId, ucstr, sender );
} }
@ -832,25 +892,88 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
} }
} }
#ifdef HAVE_MONGO
const std::string *tmpChatId = _ChanNames.getB(chanId); const std::string *tmpChatId = _ChanNames.getB(chanId);
string chatId; string chatId;
if (tmpChatId) if (tmpChatId)
chatId = *tmpChatId; chatId = *tmpChatId;
nlinfo("CHAT : %s", chatId.c_str());
double date = 1000.0*(double)CTime::getSecondsSince1970(); double date = 1000.0*(double)CTime::getSecondsSince1970();
string name; bool sendToMongo = true;
if (!ucSenderName.empty()) bool sendToAllForge = false;
name = IOS->getRocketName(ucSenderName); uint8 startPos = 0;
string mongoText = ucstr.toUtf8();
string usedlang = "";
string autosub = "0";
if (EnableDeepL)
{
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] == ':')
{
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 else
name = senderName; {
usedlang = mongoText.substr(1, 2);
mongoText = mongoText.substr(4, mongoText.size()-4);
}
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'dynamic', 'chatId': '%s', 'date': %f, 'ig': true }", CMongo::quote(name).c_str(), CMongo::quote(ucstr.toUtf8()).c_str(), chatId.c_str(), date)); 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;
}
}
#ifdef HAVE_MONGO
if (sendToMongo) // only send to mongo if it's not a translated message
{
string userlang = SM->getLanguageCodeString(ci->Language);
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"));
}
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"));
}
}
#endif #endif
if (!session->getChan()->getDontBroadcastPlayerInputs()) if (!session->getChan()->getDontBroadcastPlayerInputs() && startPos != 0)
{ {
// add msg to the historic // add msg to the historic
CDynChatChan::CHistoricEntry entry; CDynChatChan::CHistoricEntry entry;
@ -887,15 +1010,20 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
CDynChatSession *dcc = session->getChan()->getFirstSession(); CDynChatSession *dcc = session->getChan()->getFirstSession();
while (dcc) while (dcc)
{ {
sendChat(itCl->second->getChatMode(), dcc->getClient()->getID(), content, sender, chanId); 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 dcc = dcc->getNextChannelSession(); // next session in this channel
} }
} }
else else
{ {
// only send an echo to the sender // 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); sendChat(itCl->second->getChatMode(), itCl->first, ucstr, sender, chanId);
} }
if (session->getChan()->getForwardPlayerIntputToOwnerService()) if (session->getChan()->getForwardPlayerIntputToOwnerService())
{ {
// send player input to service owner // send player input to service owner
@ -968,10 +1096,27 @@ void CChatManager::chatInGroup( TGroupId& grpId, const ucstring& ucstr, const TD
CChatGroup &chatGrp = itGrp->second; CChatGroup &chatGrp = itGrp->second;
CChatGroup::TMemberCont::const_iterator itM; CChatGroup::TMemberCont::const_iterator itM;
list<CEntityId> logDest; list<CEntityId> logDest;
uint8 startPos = 0;
string usedlang;
if (EnableDeepL && ucstr.length() > 4 && ucstr[0] == ':' && ucstr[3] == ':') // check lang prefix
{
usedlang = ucstr.toString().substr(1, 2);
startPos = 4;
}
for( itM = chatGrp.Members.begin(); itM != chatGrp.Members.end(); ++itM ) for( itM = chatGrp.Members.begin(); itM != chatGrp.Members.end(); ++itM )
{ {
CMirrorPropValueRO<uint32> instanceId( TheDataset, *itM, DSPropertyAI_INSTANCE ); CMirrorPropValueRO<uint32> instanceId( TheDataset, *itM, DSPropertyAI_INSTANCE );
if (EnableDeepL && !usedlang.empty())
{
NLMISC::CEntityId receiverId = TheDataset.getEntityId(*itM);
CCharacterInfos* co = IOS->getCharInfos(receiverId);
if (usedlang != SM->getLanguageCodeString(co->Language))
continue;
}
// check the ai instance for region chat // check the ai instance for region chat
if (chatGrp.Type != CChatGroup::region if (chatGrp.Type != CChatGroup::region
|| instanceId == senderInstanceId) || instanceId == senderInstanceId)
@ -997,7 +1142,7 @@ void CChatManager::chatInGroup( TGroupId& grpId, const ucstring& ucstr, const TD
// check the exclude list // check the exclude list
if ( std::find( excluded.begin(), excluded.end(), *itM ) == excluded.end() ) if ( std::find( excluded.begin(), excluded.end(), *itM ) == excluded.end() )
{ {
sendChat( itGrp->second.Type, *itM, ucstr, sender ); sendChat( itGrp->second.Type, *itM, ucstr.substr(startPos), sender );
_DestUsers.push_back(TheDataset.getEntityId(*itM)); _DestUsers.push_back(TheDataset.getEntityId(*itM));
} }
} }
@ -1011,7 +1156,7 @@ void CChatManager::chatInGroup( TGroupId& grpId, const ucstring& ucstr, const TD
// forward to chat unifier to dispatch to other shards // forward to chat unifier to dispatch to other shards
if (IChatUnifierClient::getInstance()) if (IChatUnifierClient::getInstance())
{ {
IChatUnifierClient::getInstance()->sendFarGuildChat(charInfos->Name, uint32(grpId.getShortId()), ucstr); IChatUnifierClient::getInstance()->sendFarGuildChat(charInfos->Name, uint32(grpId.getShortId()), ucstr.substr(startPos));
} }
} }
} }
@ -1026,7 +1171,7 @@ void CChatManager::chatInGroup( TGroupId& grpId, const ucstring& ucstr, const TD
{ {
// determine the session id as the home session id for normal players and the current session id for GMs // determine the session id as the home session id for normal players and the current session id for GMs
uint32 sessionId= (charInfos->HavePrivilege && !IsRingShard)? IService::getInstance()->getShardId(): (uint32)charInfos->HomeSessionId; uint32 sessionId= (charInfos->HavePrivilege && !IsRingShard)? IService::getInstance()->getShardId(): (uint32)charInfos->HomeSessionId;
IChatUnifierClient::getInstance()->sendUniverseChat(charInfos->Name, sessionId, ucstr); IChatUnifierClient::getInstance()->sendUniverseChat(charInfos->Name, sessionId, ucstr.substr(startPos));
} }
} }
} }
@ -1043,16 +1188,26 @@ void CChatManager::farChatInGroup(TGroupId &grpId, uint32 homeSessionId, const u
map< TGroupId, CChatGroup >::iterator itGrp = _Groups.find( grpId ); map< TGroupId, CChatGroup >::iterator itGrp = _Groups.find( grpId );
if( itGrp != _Groups.end() ) if( itGrp != _Groups.end() )
{ {
uint8 startPos = 0;
string usedlang;
if (EnableDeepL && text.length() > 4 && text[0] == ':' && text[3] == ':') // check lang prefix
{
usedlang = text.toString().substr(1, 2);
startPos = 4;
}
CChatGroup &chatGrp = itGrp->second; CChatGroup &chatGrp = itGrp->second;
CChatGroup::TMemberCont::const_iterator itM; CChatGroup::TMemberCont::const_iterator itM;
for( itM = chatGrp.Members.begin(); itM != chatGrp.Members.end(); ++itM ) for( itM = chatGrp.Members.begin(); itM != chatGrp.Members.end(); ++itM )
{
if (homeSessionId != 0)
{ {
CCharacterInfos *charInfo = IOS->getCharInfos(TheDataset.getEntityId(*itM)); CCharacterInfos *charInfo = IOS->getCharInfos(TheDataset.getEntityId(*itM));
if (charInfo==NULL) if (charInfo==NULL)
continue; continue;
if (homeSessionId != 0)
{
// determine the session id as the home session id for normal players and the current session id for GMs // determine the session id as the home session id for normal players and the current session id for GMs
uint32 sessionId= (charInfo->HavePrivilege && !IsRingShard)? IService::getInstance()->getShardId(): (uint32)charInfo->HomeSessionId; uint32 sessionId= (charInfo->HavePrivilege && !IsRingShard)? IService::getInstance()->getShardId(): (uint32)charInfo->HomeSessionId;
@ -1060,7 +1215,11 @@ void CChatManager::farChatInGroup(TGroupId &grpId, uint32 homeSessionId, const u
if (sessionId != homeSessionId) if (sessionId != homeSessionId)
continue; continue;
} }
sendFarChat( itGrp->second.Type, *itM, text, senderName );
if (EnableDeepL && !usedlang.empty() && usedlang != SM->getLanguageCodeString(charInfo->Language))
continue;
sendFarChat( itGrp->second.Type, *itM, text.substr(startPos), senderName );
} }
} }
else else
@ -1711,6 +1870,85 @@ void CChatManager::sendChat( CChatGroup::TGroupType senderChatMode, const TDataS
} // sendChat // } // sendChat //
void CChatManager::sendFarChat(const string &name, const ucstring& ucstr, const string &chan)
{
const TChanID *chanId = _ChanNames.getA(chan);
if (chanId || chan == "universe")
{
string usedlang = "";
string mongoText = ucstr.toUtf8();
string::size_type endOfOriginal = mongoText.find("}@{");
uint8 startPos = 0;
if (mongoText.length() > 4 && mongoText[0] == ':' && mongoText[3] == ':') // check lang prefix
{
startPos = 4;
double date = 1000.0*(double)CTime::getSecondsSince1970();
string chatId;
usedlang = mongoText.substr(1, 2);
string rc_channel = "";
if (chan == "FACTION_RF")
{
chatId = "FACTION_RF-"+toUpper(usedlang);
rc_channel = "pub-forge-";
}
else if (chan == "universe")
{
chatId = "FACTION_"+toUpper(usedlang);
rc_channel = "pub-universe-";
}
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/"+rc_channel+source_lang+"? "+sourceText+") "+mongoText.substr(endOfOriginal+4, mongoText.size()-endOfOriginal-4);
}
else
{
usedlang = mongoText.substr(1, 2);
mongoText = mongoText.substr(4, mongoText.size()-4);
}
if (source_lang == "en") // in RC the icon are :us:
mongoText = ":us:"+mongoText;
else
mongoText = ":"+source_lang+":"+mongoText;
#ifdef HAVE_MONGO
if (endOfOriginal != string::npos)
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'dynamic', 'chatId': '%s', 'date': %f, 'ig': true }", CMongo::quote(name).c_str(), CMongo::quote(mongoText).c_str(), chatId.c_str(), date));
#endif
}
if (chan == "universe")
{
TGroupId grpId = CEntityId(RYZOMID::chatGroup, 0);
farChatInGroup(grpId, 0, ucstr, ucstring("~")+ucstring(name));
}
else
{
CDynChatSession *dcc = _DynChat.getChan(*chanId)->getFirstSession();
while (dcc)
{
NLMISC::CEntityId receiverId = TheDataset.getEntityId(dcc->getClient()->getID());
CCharacterInfos* co = IOS->getCharInfos(receiverId);
if (!EnableDeepL || usedlang.empty() || usedlang == SM->getLanguageCodeString(co->Language))
sendFarChat((CChatGroup::TGroupType)12, dcc->getClient()->getID(), ucstr.substr(startPos), ucstring("~")+ucstring(name), *chanId);
dcc = dcc->getNextChannelSession(); // next session in this channel
}
}
}
}
void CChatManager::sendFarChat( CChatGroup::TGroupType senderChatMode, const TDataSetRow &receiver, const ucstring& ucstr, const ucstring &senderName, TChanID chanID) void CChatManager::sendFarChat( CChatGroup::TGroupType senderChatMode, const TDataSetRow &receiver, const ucstring& ucstr, const ucstring &senderName, TChanID chanID)
{ {
CCharacterInfos * receiverInfos = IOS->getCharInfos( TheDataset.getEntityId(receiver) ); CCharacterInfos * receiverInfos = IOS->getCharInfos( TheDataset.getEntityId(receiver) );
@ -2570,7 +2808,7 @@ ucstring CChatManager::filterClientInput(ucstring &text)
// 1st, remove any beginning or ending white space // 1st, remove any beginning or ending white space
ucstring::size_type pos = 0; ucstring::size_type pos = 0;
// skip begin white spaces // skip begin white spaces or : (used by deepl)
while (pos < text.size() && (text[pos] == ' ' || text[pos] == '\t')) while (pos < text.size() && (text[pos] == ' ' || text[pos] == '\t'))
++pos; ++pos;
@ -2578,6 +2816,12 @@ ucstring CChatManager::filterClientInput(ucstring &text)
while (text.size() > 0 && (*(text.rbegin()) == ' ' || *(text.rbegin()) == '\t')) while (text.size() > 0 && (*(text.rbegin()) == ' ' || *(text.rbegin()) == '\t'))
text.resize(text.size()-1); text.resize(text.size()-1);
if (pos < text.size() && text[pos] == ':')
++pos;
if (pos+1 < text.size() && text[pos] == '>' && text[pos+1] == ':')
pos += 2;
// copy string, removing multi white space between words // copy string, removing multi white space between words
// filter out color code // filter out color code
bool lastIsWhite = false; bool lastIsWhite = false;
@ -2703,6 +2947,19 @@ void CChatManager::update()
} }
else if (chatType == "dynamic") else if (chatType == "dynamic")
{ {
if (EnableDeepL && chatId.size() >= 10 && (chatId.substr(0, 11) == "FACTION_RF-" || chatId == "FACTION_EN" || chatId == "FACTION_DE" || chatId == "FACTION_FR" || chatId == "FACTION_ES" || chatId == "FACTION_RU"))
{
string usedlang;
if (chatId.substr(0, 11) == "FACTION_RF-")
usedlang = chatId.substr(11, 2);
else
usedlang = chatId.substr(8, 2);
_Log.displayNL("%s|%s|*|%s-*|%s", chatId.c_str(), string("~"+name).c_str(), toLower(usedlang).c_str(), text.toUtf8().c_str());
}
else
{
// broadcast to other client in the channel // broadcast to other client in the channel
const TChanID *chanId = _ChanNames.getA(chatId); const TChanID *chanId = _ChanNames.getA(chatId);
if (chanId) if (chanId)
@ -2714,13 +2971,22 @@ void CChatManager::update()
dcc = dcc->getNextChannelSession(); // next session in this channel dcc = dcc->getNextChannelSession(); // next session in this channel
} }
} }
}
// void CChatManager::sendFarChat( C const ucstring& ucstr, const ucstring &senderName, TChanID chanID) // void CChatManager::sendFarChat( C const ucstring& ucstr, const ucstring &senderName, TChanID chanID)
continue; continue;
} }
else if (chatType == "univers") {
// Send to Deepl
if (EnableDeepL)
{
_Log.displayNL("%s|%s|wk|wk-*|%s", "universe", name.c_str(), chat.c_str());
continue;
}
}
else if (chatType == "username") else if (chatType == "username")
{ {
if (IService::getInstance()->getShardId() == 301) if (IService::getInstance()->getShardId() == 501)
chatId = chatId+"(Yubo)"; chatId = chatId+"(Gingo)";
else else
chatId = chatId+"(Atys)"; chatId = chatId+"(Atys)";
@ -2736,3 +3002,7 @@ void CChatManager::update()
} }
#endif #endif
} }
TChanID CChatManager::getChanId(const string name) {
return *_ChanNames.getA(name);
}

@ -385,6 +385,7 @@ public:
/** /**
* Send a far chat message * Send a far chat message
*/ */
void sendFarChat(const std::string &name, const ucstring& ucstr, const std::string &chan);
void sendFarChat( CChatGroup::TGroupType senderChatMode, const TDataSetRow &receiver, const ucstring& ucstr, const ucstring &senderName, TChanID chanID = NLMISC::CEntityId::Unknown); void sendFarChat( CChatGroup::TGroupType senderChatMode, const TDataSetRow &receiver, const ucstring& ucstr, const ucstring &senderName, TChanID chanID = NLMISC::CEntityId::Unknown);
/** /**
@ -417,6 +418,8 @@ public:
void sendChatCustomEmote( const TDataSetRow &sender, const TDataSetRow &receiver, const ucstring& ucstr ); void sendChatCustomEmote( const TDataSetRow &sender, const TDataSetRow &receiver, const ucstring& ucstr );
void update(); void update();
TChanID getChanId(const std::string name);
}; };

@ -688,22 +688,55 @@ NLMISC_COMMAND(chat, "send message chat", "<char_name> <chat_group> <message>")
return false; return false;
} }
CChatGroup::TGroupType mode = CChatGroup::stringToGroupType(args[1]); TChanID chanId = CEntityId::Unknown;
TGroupId groupId = CEntityId::Unknown;
CChatGroup::TGroupType mode;
if (args[1] == "FACTION_RF") // The current only translated dynamic chat
{
chanId = IOS->getChatManager().getChanId("FACTION_RF");
mode = CChatGroup::dyn_chat;
}
else if (args[1].substr(0, 7) == "region:")
{
mode = CChatGroup::region;
groupId.fromString(args[1].substr(7).c_str());
}
else
{
mode = CChatGroup::stringToGroupType(args[1]);
}
string chat_group = args[1];
ucstring ucstr; ucstring ucstr;
ucstr.fromUtf8(args[2]); ucstr.fromUtf8(args[2]);
TDataSetRow rowId = ci->DataSetIndex; TDataSetRow rowId = ci->DataSetIndex;
try try
{ {
CChatGroup::TGroupType oldMode = IOS->getChatManager().getClient(rowId).getChatMode(); CChatGroup::TGroupType oldMode = IOS->getChatManager().getClient(rowId).getChatMode();
TChanID oldChanId = IOS->getChatManager().getClient(rowId).getDynChatChan();
TGroupId oldRegionId =IOS->getChatManager().getClient(rowId).getRegionChatGroup();
if (mode != oldMode) if (mode != oldMode)
IOS->getChatManager().getClient(rowId).setChatMode(mode); IOS->getChatManager().getClient(rowId).setChatMode(mode, chanId);
if (mode == CChatGroup::region)
IOS->getChatManager().getClient(rowId).setRegionChatGroup(groupId);
IOS->getChatManager().getClient(rowId).updateAudience(); IOS->getChatManager().getClient(rowId).updateAudience();
IOS->getChatManager().chat(rowId, ucstr); IOS->getChatManager().chat(rowId, ucstr);
if (oldMode != mode) if (oldMode != mode)
{
if (oldMode == CChatGroup::dyn_chat)
IOS->getChatManager().getClient(rowId).setChatMode(oldMode, oldChanId);
else if (oldMode == CChatGroup::region)
IOS->getChatManager().getClient(rowId).setRegionChatGroup(oldRegionId);
else
IOS->getChatManager().getClient(rowId).setChatMode(oldMode); IOS->getChatManager().getClient(rowId).setChatMode(oldMode);
} }
}
catch(const Exception &e) catch(const Exception &e)
{ {
nlwarning("<cbChatMessage> %s",e.what()); nlwarning("<cbChatMessage> %s",e.what());
@ -712,6 +745,20 @@ NLMISC_COMMAND(chat, "send message chat", "<char_name> <chat_group> <message>")
return true; return true;
} }
NLMISC_COMMAND(farChat, "send far message chat", "<char_name> <chat_id> <message>")
{
if (args.size() < 3)
return false;
uint32 id;
ucstring ucstr;
string name = args[0];
ucstr.fromUtf8(args[2]);
IOS->getChatManager().sendFarChat(name, ucstr, args[1]);
}
NLMISC_COMMAND(getRealName, "getRealName", "<char_name>") NLMISC_COMMAND(getRealName, "getRealName", "<char_name>")
{ {
if (args.size() != 1) if (args.size() != 1)
@ -724,7 +771,7 @@ NLMISC_COMMAND(getRealName, "getRealName", "<char_name>")
return true; return true;
} }
log.displayNL("%s", ci->ShortName.c_str()); log.displayNL("%s", ci->ShortRealName.c_str());
return true; return true;
} }

@ -565,12 +565,14 @@ void CInputOutputService::addCharacterName( const TDataSetRow& chId, const ucstr
{ {
charInfos = new CCharacterInfos(); charInfos = new CCharacterInfos();
// store association // store association
_IdToInfos.insert( make_pair(eid,charInfos) ); _IdToInfos.insert( make_pair(eid, charInfos) );
} }
else else
{ {
// remove previous name association (because name have changed) // remove previous name only if it's different than real name (Real Name association can't be deleted)
if (charInfos->ShortName != charInfos->ShortRealName)
_NameToInfos.erase(charInfos->ShortName.toUtf8()); _NameToInfos.erase(charInfos->ShortName.toUtf8());
oldname = charInfos->ShortName; // save the old name oldname = charInfos->ShortName; // save the old name
if (charInfos->EntityId != eid) if (charInfos->EntityId != eid)
@ -629,32 +631,14 @@ void CInputOutputService::addCharacterName( const TDataSetRow& chId, const ucstr
// it will try to match it as a homeland name // it will try to match it as a homeland name
string::size_type pos = name.find('('); string::size_type pos = name.find('(');
if (pos == string::npos) if (pos == string::npos)
{
name = CShardNames::getInstance().makeFullName(name, charInfos->HomeSessionId); name = CShardNames::getInstance().makeFullName(name, charInfos->HomeSessionId);
}
TCharInfoCont::iterator itInfos = _NameToInfos.find( name ); TCharInfoCont::iterator itInfos = _NameToInfos.find( name );
if( itInfos == _NameToInfos.end() ) if( itInfos == _NameToInfos.end() || name == charInfos->ShortRealName.toUtf8() )
{ {
// New name does not exist // New name does not exist or is the real name
charInfos->ShortName.fromUtf8(name); charInfos->ShortName.fromUtf8(name);
} }
TIdRealNames::iterator itRealName = _IdToRealName.find(eid);
if( itRealName != _IdToRealName.end() ) //Erase if found realname. New name will be added if need
_IdToRealName.erase(eid);
// Lookup on _RenamedCharInfos about realname (if found => the player have a rename )
itInfos = _RenamedCharInfos.find( charInfos->ShortName.toUtf8() );
if( itInfos != _RenamedCharInfos.end() ) // New name was in the saved list; player is getting original name back
{
_RenamedCharInfos.erase(charInfos->ShortName.toUtf8());
}
else // New name was not in the list, save old name (it's the real name)
{
_IdToRealName.insert(make_pair(eid, oldname.toUtf8()));
_RenamedCharInfos.insert( make_pair(oldname.toUtf8(), charInfos) );
}
} }
} }
@ -733,10 +717,6 @@ void CInputOutputService::addCharacterName( const TDataSetRow& chId, const ucstr
else else
{ {
nlwarning( "ERROR: Received CHARACTER_NAME with null row!" ); nlwarning( "ERROR: Received CHARACTER_NAME with null row!" );
// Previously: not yet in the mirror
/*if ( ! charInfos->NameIndex.isReadable() )
charInfos->NameIndex.tempAllocate();
charInfos->NameIndex.tempReassign(SM->storeString(charInfos->Name));*/
} }
if (VerboseNameTranslation) if (VerboseNameTranslation)
{ {
@ -753,12 +733,12 @@ void CInputOutputService::addCharacterName( const TDataSetRow& chId, const ucstr
chId.getIndex()); chId.getIndex());
} }
// store name assoc // Store realname only the first time (so never change)
// _NameToInfos.insert( make_pair(ucname,charInfos) ); if (charInfos->ShortRealName.empty())
charInfos->ShortRealName = charInfos->ShortName;
// store the short name assoc. // store the short name assoc.
_NameToInfos.insert( make_pair(charInfos->ShortName.toUtf8(), charInfos) ); _NameToInfos.insert( make_pair(charInfos->ShortName.toUtf8(), charInfos) );
// TODO : remove when dynDB removed
// charInfos->OldNameIndex = IOS->getChatManager().getDynamicDB().add(charInfos->ShortName, false);
} // addCharacterName // } // addCharacterName //
@ -770,56 +750,43 @@ void CInputOutputService::addCharacterName( const TDataSetRow& chId, const ucstr
//----------------------------------------------- //-----------------------------------------------
string CInputOutputService::getRocketName(const ucstring& chName) string CInputOutputService::getRocketName(const ucstring& chName)
{ {
ucstring charname = chName;
string realName; string realName;
string reName; string name;
ucstring::size_type pos = charname.find('$'); TCharInfoCont::iterator itInfos;
CCharacterInfos * charInfos = NULL;
ucstring::size_type pos = chName.find('$');
if (pos != string::npos) if (pos != string::npos)
charname = charname.substr(0, pos); itInfos = _NameToInfos.find(chName.substr(0, pos).toUtf8());
else
itInfos = _NameToInfos.find(chName.toUtf8());
CCharacterInfos * charInfos = NULL; // Get informations about a player.
TCharInfoCont::iterator itInfos = _NameToInfos.find(charname.toUtf8()); if (itInfos != _NameToInfos.end())
if (itInfos != _NameToInfos.end()) // Char can have a rename, need found it on _IdToRealName
{ {
charInfos = itInfos->second; charInfos = itInfos->second;
realName = charInfos->Name.toString(); realName = charInfos->ShortRealName.toUtf8();
name = charInfos->ShortName.toUtf8();
} }
else else
{ {
itInfos = _RenamedCharInfos.find(charname.toUtf8()); nlwarning("Name not found : %s", chName.toUtf8().c_str());
if (itInfos != _RenamedCharInfos.end()) // Char is renamed return "unknown";
{
realName = chName.toString();
charInfos = itInfos->second;
if (charInfos != NULL) {
reName = charInfos->Name.toString();
}
}
}
if (reName.empty() && charInfos != NULL) // Search for a rename
{
TIdRealNames::iterator itRealName = _IdToRealName.find(charInfos->EntityId);
if (itRealName != _IdToRealName.end())
{
reName = realName;
realName = itRealName->second;
}
} }
string::size_type spos = realName.find('('); string::size_type spos = realName.find('(');
if (spos != string::npos) if (spos != string::npos)
realName = realName.substr(0, spos); realName = realName.substr(0, spos);
if (!reName.empty()) if (!name.empty())
{ {
spos = reName.find('('); spos = name.find('(');
if (spos != string::npos) if (spos != string::npos)
reName = reName.substr(0, spos); name = name.substr(0, spos);
} }
if (charInfos != NULL && !reName.empty() && !charInfos->HavePrivilege) if (charInfos != NULL && !name.empty() && !charInfos->HavePrivilege)
realName = reName+"@"+realName; realName = name+"@"+realName;
return realName; return realName;
@ -864,13 +831,6 @@ CCharacterInfos * CInputOutputService::getCharInfos( const ucstring& chName )
{ {
return itInfos->second; return itInfos->second;
} }
// Not found so check any renamed players
itInfos = _RenamedCharInfos.find( chName.toUtf8() );
if( itInfos != _RenamedCharInfos.end() )
{
return itInfos->second;
}
else else
{ {
return NULL; return NULL;
@ -928,39 +888,14 @@ void CInputOutputService::removeEntity( const TDataSetRow &chId )
// index = itInfos->second->OldNameIndex; // index = itInfos->second->OldNameIndex;
_NameToInfos.erase(itInfos->second->ShortName.toUtf8()); _NameToInfos.erase(itInfos->second->ShortName.toUtf8());
TIdRealNames::iterator itRealName = _IdToRealName.find(eid); if (!itInfos->second->ShortRealName.empty() && itInfos->second->ShortRealName.toUtf8() != itInfos->second->ShortName.toUtf8())
if( itRealName != _IdToRealName.end() ) //Erase if found rename _NameToInfos.erase(itInfos->second->ShortRealName.toUtf8());
{
_RenamedCharInfos.erase(itRealName->second);
_IdToRealName.erase(eid);
}
// erase the entry in _IdToInfos // erase the entry in _IdToInfos
delete itInfos->second; delete itInfos->second;
itInfos->second = NULL; itInfos->second = NULL;
_IdToInfos.erase( itInfos ); _IdToInfos.erase( itInfos );
// erase the entry in _NameToInfos
/* CDynamicStringInfos * infos = _ChatManager.getDynamicDB().getInfos( index );
if( infos )
{
name = infos->Str;
map<ucstring,CCharacterInfos *>::iterator itInfos2 = _NameToInfos.find( name );
if( itInfos2 != _NameToInfos.end() )
{
_NameToInfos.erase( itInfos2 );
}
*/
/* else
{
nlwarning("<CInputOutputService::removeEntity> Unknown entity : %s",name.toString().c_str());
}
*//* }
else
{
nlwarning("<CInputOutputService::removeEntity> Dynamic string %d unknown",index);
}
*/
} }
else else
{ {
@ -1015,7 +950,7 @@ void CInputOutputService::display(NLMISC::CLog &log)
infos->Str.toString().c_str()*/); infos->Str.toString().c_str()*/);
} }
log.displayNL("CHAT GROUPS : "); log.displayNL("CHAT GROUPS : ");
IOS->getChatManager().displayChatGroups(log, false, false); IOS->getChatManager().displayChatGroups(log, true, false);
} // display // } // display //

@ -81,6 +81,10 @@ public:
CMirrorPropValue< uint32, CPropLocationPacked<2> > NameIndex; CMirrorPropValue< uint32, CPropLocationPacked<2> > NameIndex;
/// Short name (ie name without the $title$ spec) /// Short name (ie name without the $title$ spec)
ucstring ShortName; ucstring ShortName;
/// Short rename (ie name without the $title$ spec)
ucstring ShortRealName;
/// Short name index /// Short name index
uint32 ShortNameIndex; uint32 ShortNameIndex;
/// The home mainland session id /// The home mainland session id
@ -202,12 +206,8 @@ private:
/// infos on a character from his name /// infos on a character from his name
TCharInfoCont _NameToInfos; TCharInfoCont _NameToInfos;
TIdRealNames _IdToRealName;
/// Original information about renamed characters
TCharInfoCont _RenamedCharInfos;
typedef std::map<NLMISC::CEntityId, std::pair<NLMISC::TGameCycle, CCharacterInfos*> > TTempCharInfoCont; typedef std::map<NLMISC::CEntityId, std::pair<NLMISC::TGameCycle, CCharacterInfos*> > TTempCharInfoCont;
/// Temporary storage for removed entities, will survive here for 3000 ticks. /// Temporary storage for removed entities, will survive here for 3000 ticks.
TTempCharInfoCont _RemovedCharInfos; TTempCharInfoCont _RemovedCharInfos;

Loading…
Cancel
Save