// Ryzom - MMORPG Framework
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
#include "stdpch.h"
#include "shard_names.h"
using namespace std;
using namespace NLMISC;
// ***************************************************************************
void CShardNames::init(NLMISC::CConfigFile &configFile)
{
// read the mainland session name table
CConfigFile::CVar *sessionNames = configFile.getVarPtr("HomeMainlandNames");
if (sessionNames == NULL)
{
nlwarning("No variable 'HomeMainlandNames', domain unified character names will not work correctly !");
}
else
{
uint32 sessionId;
for (uint i=0; isize()/3; ++i)
{
TSessionName sn;
fromString(sessionNames->asString(i*3), sessionId);
sn.SessionId = (TSessionId)sessionId;
sn.DisplayName = sessionNames->asString(i*3+1);
sn.ShortName = sessionNames->asString(i*3+2);
sn.DisplayNameId = CStringMapper::map(sn.DisplayName);
_SessionNames.push_back(sn);
}
nlinfo("Read %u home session names from config files", _SessionNames.size());
}
// read the var to append or not (). Use DontUseSU one for simplicity (but this is for server only...)
CConfigFile::CVar *dontUseSU = configFile.getVarPtr("DontUseSU");
_AppendParenthesisWhenSessionNotFound= true; // default
if(dontUseSU!=NULL)
{
// do not append () if DontUseSU==1
_AppendParenthesisWhenSessionNotFound= dontUseSU->asInt()==0;
}
}
// ***************************************************************************
void CShardNames::saveShardNames(std::vector &outData) const
{
// backup a vector version of the data
outData.resize(_SessionNames.size()*3);
for(uint i=0;i<_SessionNames.size();i++)
{
const TSessionName &sn= _SessionNames[i];
outData[i*3+0]= toString(sn.SessionId);
outData[i*3+1]= sn.DisplayName;
outData[i*3+2]= sn.ShortName;
}
}
// ***************************************************************************
void CShardNames::loadShardNames(const std::vector &inData)
{
// reset
_SessionNames.clear();
uint32 sessionId;
// parse the vector of string
for (uint i=0; i