/** * @return bool (false means an error occurred ) * @param inipath Doc at RoamingServer::ReadConfig */ bool MapServer::ReadConfig(const std::string &inipath) { StringsBasedCfg config; ACE_Ini_ImpExp config_importer(config); ACE_Configuration_Section_Key root; std::string map_templates_dir; if(m_endpoint) { //TODO: perform shutdown, and load config ? ACE_DEBUG((LM_WARNING,ACE_TEXT("(%P|%t) MapServer already initialized and running\n") )); return true; } if (config.open () == -1) ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT ("(%P|%t) MapServer: %p\n"), ACE_TEXT ("config")),false); if (config_importer.import_config (inipath.c_str()) == -1) ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT ("(%P|%t) MapServer: Unable to open config file : %s\n"), inipath.c_str()),false); if(-1==config.open_section(config.root_section(),"MapServer",1,root)) ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT ("(%P|%t) MapServer: Config file %s is missing [MapServer] section\n"), inipath.c_str()),false); if(!RoamingServer::ReadConfig(inipath)) return false; config.get_addr(root,ACE_TEXT("listen_addr"),m_listen_point,ACE_INET_Addr(7002,"0.0.0.0")); config.get_addr(root,ACE_TEXT("location_addr"),m_location,ACE_INET_Addr(7002,"127.0.0.1")); config.get_addr(root,ACE_TEXT("location_addr"),m_location,ACE_INET_Addr(7002,"127.0.0.1")); config.get_string_value(root,ACE_TEXT("maps"),map_templates_dir,"."); m_online = false; return m_manager.load_templates(map_templates_dir); }
bool GameServer::ReadConfig(const std::string &inipath) { if(m_endpoint) { ACE_DEBUG((LM_WARNING,ACE_TEXT("(%P|%t) Game server already initialized and running\n") )); return true; } StringsBasedCfg config; if (config.open () == -1) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("config")),false); } ACE_Ini_ImpExp config_importer (config); ACE_Configuration_Section_Key root; if (config_importer.import_config (inipath.c_str()) == -1) ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT ("(%P|%t) GameServer: Unable to open config file : %s\n"), inipath.c_str()),false); if(-1==config.open_section(config.root_section(),"GameServer",1,root)) ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT ("%p GameServer: Config file %s is missing [GameServer] section\n"), inipath.c_str()),false); config.get_addr(root,ACE_TEXT("listen_addr"),m_listen_point,ACE_INET_Addr(7002,"0.0.0.0")); config.get_addr(root,ACE_TEXT("location_addr"),m_location,ACE_INET_Addr(7002,"127.0.0.1")); config.get_string_value(root,ACE_TEXT("server_name"),m_serverName,"unnamed"); config.get_integer_value_with_default(root,ACE_TEXT("max_players"),m_max_players,600); m_current_players = 0; m_id = 1; m_unk1=m_unk2=0; m_online = false; //m_db = new GameServerDb(""); return true; }
/*! * @brief Read server configuration * @param inipath is a path to our configuration file. * @return bool, if it's false, this function failed somehow. */ bool AuthServer::ReadConfig(const std::string &inipath) { if(m_running) ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("(%P|%t) AuthServer: Already initialized and running\n") ),false); StringsBasedCfg config; if (config.open () == -1) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("config")),false); } ACE_Ini_ImpExp config_importer (config); ACE_Configuration_Section_Key root; if (config_importer.import_config (inipath.c_str()) == -1) ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT ("(%P|%t) AuthServer: Unable to open config file : %s\n"), inipath.c_str()),false); if(-1==config.open_section(config.root_section(),"AuthServer",1,root)) ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT ("%p AuthServer: Config file %s is missing [AuthServer] section\n"), inipath.c_str()),false); config.get_addr(root,ACE_TEXT ("listen_addr"),m_location,ACE_INET_Addr(2106,"127.0.0.1")); return true; }
/** * @return int * @param configpath This is a platform specific path to a config file containing * general RoamingServer vars. */ bool RoamingServer::ReadConfig(const std::string &inipath) { StringsBasedCfg config; ACE_Ini_ImpExp config_importer(config); ACE_Configuration_Section_Key root; if (config.open () == -1) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("config")),false); } if (config_importer.import_config (inipath.c_str()) == -1) ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT ("(%P|%t) RoamingServer: Unable to open config file : %s\n"), inipath.c_str()),false); if(-1==config.open_section(config.root_section(),"RoamingServer",1,root)) ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT ("(%P|%t) RoamingServer: Config file %s is missing [RoamingServer] section\n"), inipath.c_str()),false); config.get_addr(root,ACE_TEXT("location_addr"),m_authaddr,ACE_INET_Addr(2106,"127.0.0.1")); config.get_string_value(root,ACE_TEXT("auth_pass"),m_passw,""); return true; }
bool _AdminServer::ReadConfig(const std::string &inipath) { if(m_running) ACE_ERROR_RETURN((LM_ERROR,ACE_TEXT("(%P|%t) AdminServer: Already initialized and running\n") ),false); StringsBasedCfg config; if (config.open () == -1) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("config")),false); } ACE_Ini_ImpExp config_importer (config); if (config_importer.import_config (inipath.c_str()) == -1) ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT ("(%P|%t) AdminServer: Unable to open config file : %s\n"), inipath.c_str()),false); ACE_Configuration_Section_Key root; ACE_Configuration_Section_Key account_db_config; ACE_Configuration_Section_Key character_db_config; if(-1==config.open_section(config.root_section(),"AdminServer",1,root)) ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT ("(%P|%t) AdminServer: Config file %s is missing [AdminServer] section\n"), inipath.c_str()),false); if(-1==config.open_section(root,"AccountDatabase",1,account_db_config)) ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT ("(%P|%t) AdminServer: Config file %s is missing [AccountDatabase] section\n"), inipath.c_str()),false); std::string dbhost,dbname,dbuser,dbpass,dbport,dbdriver; config.get_string_value(account_db_config,ACE_TEXT("db_driver"),dbdriver,"sqlite"); config.get_string_value(account_db_config,ACE_TEXT("db_host"),dbhost,"127.0.0.1"); config.get_string_value(account_db_config,ACE_TEXT("db_port"),dbport,"5432"); config.get_string_value(account_db_config,ACE_TEXT("db_name"),dbname,"segs"); config.get_string_value(account_db_config,ACE_TEXT("db_user"),dbuser,"none"); config.get_string_value(account_db_config,ACE_TEXT("db_pass"),dbpass,"none"); Database *db1; if(dbdriver=="pgsql") { #ifdef HAVE_POSTGRES db1 = new PSqlDatabase; #else ACE_DEBUG((LM_INFO,"PostgreSQL support was not selected during compilation.\n")); db1 = new SqliteDatabase; #endif } else { db1 = new SqliteDatabase; } db1->setConnectionConfiguration(dbhost.c_str(),dbport.c_str(),dbname.c_str(),dbuser.c_str(),dbpass.c_str()); m_db->setDb(db1); if(-1==config.open_section(root,"CharacterDatabase",1,character_db_config)) ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT ("(%P|%t) AdminServer: Config file %s is missing [CharacterDatabase] section\n"), inipath.c_str()),false); config.get_string_value(character_db_config,ACE_TEXT("db_driver"),dbdriver,"sqlite"); config.get_string_value(character_db_config,ACE_TEXT("db_host"),dbhost,"127.0.0.1"); config.get_string_value(character_db_config,ACE_TEXT("db_port"),dbport,"5432"); config.get_string_value(character_db_config,ACE_TEXT("db_name"),dbname,"segs_game"); config.get_string_value(character_db_config,ACE_TEXT("db_user"),dbuser,"none"); config.get_string_value(character_db_config,ACE_TEXT("db_pass"),dbpass,"none"); Database *db2; if(dbdriver=="pgsql") { #ifdef HAVE_POSTGRES db2 = new PSqlDatabase; #else ACE_DEBUG((LM_INFO,"PostgreSQL support was not selected during compilation.\n")); db2 = new SqliteDatabase; #endif } else { db2 = new SqliteDatabase; } db2->setConnectionConfiguration(dbhost.c_str(),dbport.c_str(),dbname.c_str(),dbuser.c_str(),dbpass.c_str()); m_char_db->setDb(db2); return true; }