public static void EventSink_ServerList(ServerListEventArgs e) { GameServerListConfig gsl = Core.Config.GameServerListConfig; if (gsl == null) { e.Rejected = true; return; } foreach (GameServerConfig gs in gsl.GameServers) { e.AddServer(gs.Name, gs.Address); } }
private void Load() { document = new XmlDocument(); dataDirectories = new ArrayList(); if (Exists) { XmlTextReader reader = new XmlTextReader(filename); try { document.Load(reader); } finally { reader.Close(); } } else { document.AppendChild(document.CreateElement("sunuo-config")); } // section "global" XmlElement global = GetConfiguration("global"); if (global != null) { multiThreading = GetElementBool(global, "multi-threading", false); } // section "locations" XmlElement locations = GetConfiguration("locations"); foreach (XmlElement dp in locations.GetElementsByTagName("data-path")) { string path = dp.InnerText; if (Directory.Exists(path)) { dataDirectories.Add(path); } } // section "libraries" XmlElement librariesEl = GetConfiguration("libraries"); foreach (XmlElement el in librariesEl.GetElementsByTagName("library")) { string name = el.GetAttribute("name"); if (name == null || name == "") { Console.WriteLine("Warning: library element without name attribute"); continue; } name = name.ToLower(); LibraryConfig libConfig = (LibraryConfig)libraryConfig[name]; if (libConfig == null) { libraryConfig[name] = libConfig = new LibraryConfig(name); } libConfig.Load(el); } if (!libraryConfig.ContainsKey("legacy")) { libraryConfig["legacy"] = new LibraryConfig("legacy"); } // section "login" XmlElement loginEl = GetConfiguration("login"); loginConfig = loginEl == null ? new LoginConfig() : new LoginConfig(loginEl); // section "server-list" XmlElement serverListEl = GetConfiguration("server-list"); if (serverListEl != null) { gameServerListConfig = new GameServerListConfig(serverListEl); } }
private void Load() { document = new XmlDocument(); dataDirectories = new ArrayList(); if (Exists) { XmlTextReader reader = new XmlTextReader(filename); try { document.Load(reader); } finally { reader.Close(); } } else { document.AppendChild(document.CreateElement("sunuo-config")); } // section "global" XmlElement global = GetConfiguration("global"); if (global != null) { multiThreading = GetElementBool(global, "multi-threading", false); } // section "locations" XmlElement locations = GetConfiguration("locations"); foreach (XmlElement dp in locations.GetElementsByTagName("data-path")) { string path = dp.InnerText; if (Directory.Exists(path)) dataDirectories.Add(path); } // section "libraries" XmlElement librariesEl = GetConfiguration("libraries"); foreach (XmlElement el in librariesEl.GetElementsByTagName("library")) { string name = el.GetAttribute("name"); if (name == null || name == "") { Console.WriteLine("Warning: library element without name attribute"); continue; } name = name.ToLower(); LibraryConfig libConfig = (LibraryConfig)libraryConfig[name]; if (libConfig == null) libraryConfig[name] = libConfig = new LibraryConfig(name); libConfig.Load(el); } if (!libraryConfig.ContainsKey("legacy")) libraryConfig["legacy"] = new LibraryConfig("legacy"); // section "login" XmlElement loginEl = GetConfiguration("login"); loginConfig = loginEl == null ? new LoginConfig() : new LoginConfig(loginEl); // section "server-list" XmlElement serverListEl = GetConfiguration("server-list"); if (serverListEl != null) gameServerListConfig = new GameServerListConfig(serverListEl); }