/** * @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; }
/** * @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; }
/*! * @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; }