コード例 #1
0
        public ServerQueryLogic(GameExtensionPool gameExtensions)
        {
            this.gameExtensions = gameExtensions;

            // fake a completed request
            this.currentRequest = new UpdateRequest(0, 0, 750, gameExtensions.Get(0), false);
            this.currentRequest.PendingTasks = new CountdownEvent(1);
            this.currentRequest.PendingTasks.Signal();
        }
コード例 #2
0
        public void LoadFromIni(IniFile iniFile, IniFile.Section ini, GameExtensionPool pool, bool ignoreMasterServer)
        {
            this.Source                 = (SourceType)ini.GetInt("Type");
            this.Caption                = ini.GetString("TabName");
            this.MasterServer           = (ignoreMasterServer ? null : ini.GetString("MasterServer")) ?? "";
            this.InitialGameID          = ini.GetInt("InitialGameID");
            this.FilterMod              = ini.GetString("FilterMod");
            this.FilterMap              = ini.GetString("FilterMap");
            this.TagsIncludeServer      = ini.GetString("TagsInclude");
            this.TagsExcludeServer      = ini.GetString("TagsExclude");
            this.VersionMatch           = ini.GetString("VersionMatch");
            this.GetEmptyServers        = ini.GetBool("GetEmptyServers", true);
            this.GetFullServers         = ini.GetBool("GetFullServers", true);
            this.MasterServerQueryLimit = ini.GetInt("MasterServerQueryLimit", this.MasterServerQueryLimit);
            this.GridFilter             = ini.GetString("GridFilter");
            this.MinPlayers             = ini.GetInt("MinPlayers");
            this.MinPlayersInclBots     = ini.GetBool("MinPlayersInclBots");
            this.MaxPing                = ini.GetInt("MaxPing");
            this.TagsIncludeClient      = ini.GetString("TagsIncludeClient");
            this.TagsExcludeClient      = ini.GetString("TagsExcludeClient");

            this.CustomDetailColumns.Clear();
            foreach (var detail in (ini.GetString("CustomDetailColumns") ?? "").Split(','))
            {
                if (detail != "")
                {
                    CustomRuleColumns.Add(detail);
                }
            }

            this.CustomRuleColumns.Clear();
            foreach (var rule in (ini.GetString("CustomRuleColumns") ?? "").Split(','))
            {
                if (rule != "")
                {
                    CustomRuleColumns.Add(rule);
                }
            }

            this.HideColumns.Clear();
            foreach (var col in (ini.GetString("HideColumns") ?? "").Split(','))
            {
                if (col != "")
                {
                    HideColumns.Add(col);
                }
            }

            var layout = ini.GetString("GridLayout");

            if (!string.IsNullOrEmpty(layout))
            {
                this.ServerGridLayout = new MemoryStream(Convert.FromBase64String(layout));
            }

            this.gameExtension = pool.Get((Game)this.InitialGameID);

            if (this.Source == SourceType.CustomList)
            {
                this.Servers = new List <ServerRow>();

                // new config format
                var sec = iniFile.GetSection(ini.Name + "_Servers");
                if (sec != null)
                {
                    foreach (var key in sec.Keys)
                    {
                        var row = new ServerRow(Ip4Utils.ParseEndpoint(key), this.gameExtension);
                        row.CachedName = sec.GetString(key);
                        this.Servers.Add(row);
                    }
                }
                else
                {
                    // old config format
                    var oldSetting = ini.GetString("Servers") ?? "";
                    foreach (var server in oldSetting.Split('\n', ' '))
                    {
                        var s = server.Trim();
                        if (s == "")
                        {
                            continue;
                        }
                        this.Servers.Add(new ServerRow(Ip4Utils.ParseEndpoint(s), this.gameExtension));
                    }
                }
            }
        }