Fixed: Remove hardcoding of mongo server and db. Prevent crash of ios

feature/prepare-cross-merge
Ulukyn 5 years ago committed by kaetemi
parent 1a6b197411
commit 230ca5ffdb
No known key found for this signature in database
GPG Key ID: 9873C4D40BB479BC

@ -978,6 +978,9 @@ void CChatManager::chatInGroup( TGroupId& grpId, const ucstring& ucstr, const TD
CCharacterInfos *senderChar = IOS->getCharInfos(TheDataset.getEntityId(sender)); CCharacterInfos *senderChar = IOS->getCharInfos(TheDataset.getEntityId(sender));
CCharacterInfos *receiverChar = IOS->getCharInfos(TheDataset.getEntityId(*itM)); CCharacterInfos *receiverChar = IOS->getCharInfos(TheDataset.getEntityId(*itM));
if (senderChar == NULL || receiverChar == NULL)
continue;
// set GM mode if either speaker of listener is a GM // set GM mode if either speaker of listener is a GM
bool isGM= senderChar->HavePrivilege || receiverChar->HavePrivilege; bool isGM= senderChar->HavePrivilege || receiverChar->HavePrivilege;

@ -25,6 +25,8 @@ using namespace NLMISC;
using namespace NLNET; using namespace NLNET;
CVariable<string> MongoPassword("mongo", "MongoPassword", "Set the password to access mongo", string(""), 0, true); CVariable<string> MongoPassword("mongo", "MongoPassword", "Set the password to access mongo", string(""), 0, true);
CVariable<string> ChatDbName("mongo", "ChatDbName", "Set the mongo db", string(""), 0, true);
CVariable<string> ChatServer("mongo", "ChatServer", "Set the server host", string(""), 0, true);
DBClientConnection CMongo::conn(true); DBClientConnection CMongo::conn(true);
string CMongo::dbname; string CMongo::dbname;
@ -32,19 +34,18 @@ string CMongo::dbname;
void CMongo::init() void CMongo::init()
{ {
if (IService::getInstance()->getShardId() == 101) dbname = ChatDbName.get();
dbname = "megacorp_live";
else
dbname = "megacorp_dev";
try try
{ {
bool res; bool res;
string errmsg; string errmsg;
res = conn.connect("chat.ryzom.com:22110", errmsg); res = conn.connect(ChatServer.get(), errmsg);
if(!res) nlerror("mongo: init failed, cannot connect '%s'", errmsg.c_str()); if (!res)
else nlinfo("mongo: connection ok"); nlerror("mongo: init failed, cannot connect '%s'", errmsg.c_str());
else
nlinfo("mongo: connection ok");
/*res = conn.auth(dbname, "megacorp", MongoPassword.get(), errmsg); /*res = conn.auth(dbname, "megacorp", MongoPassword.get(), errmsg);
if(!res) nlerror("mongo: init failed, cannot auth '%s'", errmsg.c_str()); if(!res) nlerror("mongo: init failed, cannot auth '%s'", errmsg.c_str());

Loading…
Cancel
Save