[11216] Fixed crash at explictly empty string setting for dataDir in mangosd.conf.

This commit is contained in:
VladimirMangos 2011-03-03 22:06:11 +03:00
parent 06fe777f82
commit 5a3f557b19
2 changed files with 12 additions and 7 deletions

View file

@ -839,19 +839,24 @@ void World::LoadConfigSettings(bool reload)
setConfigPos(CONFIG_UINT32_CHARDELETE_KEEP_DAYS, "CharDelete.KeepDays", 30);
///- Read the "Data" directory from the config file
std::string dataPath = sConfig.GetStringDefault("DataDir","./");
if( dataPath.at(dataPath.length()-1)!='/' && dataPath.at(dataPath.length()-1)!='\\' )
std::string dataPath = sConfig.GetStringDefault("DataDir", "./");
// for empty string use current dir as for absent case
if (dataPath.empty())
dataPath = "./";
// normalize dir path to path/ or path\ form
else if (dataPath.at(dataPath.length()-1) != '/' && dataPath.at(dataPath.length()-1) != '\\')
dataPath.append("/");
if(reload)
if (reload)
{
if(dataPath!=m_dataPath)
sLog.outError("DataDir option can't be changed at mangosd.conf reload, using current value (%s).",m_dataPath.c_str());
if (dataPath != m_dataPath)
sLog.outError("DataDir option can't be changed at mangosd.conf reload, using current value (%s).", m_dataPath.c_str());
}
else
{
m_dataPath = dataPath;
sLog.outString("Using DataDir %s",m_dataPath.c_str());
sLog.outString("Using DataDir %s", m_dataPath.c_str());
}
setConfig(CONFIG_BOOL_VMAP_INDOOR_CHECK, "vmap.enableIndoorCheck", true);