Exemple #1
0
    public void Init(ref ServerBrowser.Server s)
    {
        this.server           = s;
        this.textLabel.Text   = this.server.name;
        this.textPlayers.Text = this.server.currentplayers.ToString() + " / " + this.server.maxplayers.ToString();
        this.textPing.Text    = this.server.ping.ToString();
        dfScrollPanel component = base.transform.parent.GetComponent <dfScrollPanel>();

        if (component != null)
        {
            base.GetComponent <dfControl>().Width = component.Width;
            base.GetComponent <dfControl>().ResetLayout(true, false);
        }
        this.UpdateColours();
    }
Exemple #2
0
    private void Add_Server(int iMaxPlayers, int iCurrentPlayers, int iPing, uint iLastPlayed, [In] string strHostname, [In] string strAddress, int iPort, int iQueryPort, [In] string tags, bool bPassworded, int iType)
    {
        ulong  num;
        string str = string.Concat(strAddress, ":", iPort.ToString());

        ServerBrowser.Server server = new ServerBrowser.Server()
        {
            name           = strHostname,
            address        = strAddress,
            maxplayers     = iMaxPlayers,
            currentplayers = iCurrentPlayers,
            ping           = iPing,
            lastplayed     = iLastPlayed,
            port           = iPort,
            queryport      = iQueryPort,
            fave           = FavouriteList.Contains(str)
        };
        if (server.name.Length > 64)
        {
            server.name = server.name.Substring(0, 64);
        }
        if (this.ShouldIgnoreServer(server))
        {
            return;
        }
        ServerBrowser serverBrowser = this;

        serverBrowser.playerCount = serverBrowser.playerCount + iCurrentPlayers;
        ServerBrowser serverBrowser1 = this;

        serverBrowser1.serverCount = serverBrowser1.serverCount + 1;
        ServerBrowser serverBrowser2 = this;

        serverBrowser2.slotCount   = serverBrowser2.slotCount + iMaxPlayers;
        this.needsServerListUpdate = true;
        int num1 = (int)((float)this.playerCount / (float)this.slotCount * 100f);

        this.detailsLabel.Text = string.Concat(new string[] { "Found ", this.playerCount.ToString(), " players on ", this.serverCount.ToString(), " servers. We are at ", num1.ToString(), "% capacity." });
        if (iType == 3)
        {
            this.servers[5].Add(server);
            this.categoryButtons[5].UpdateServerCount(this.servers[5].Count);
            return;
        }
        if (iType == 4)
        {
            int    num2  = (int)POSIX.Time.ElapsedSecondsSince((int)server.lastplayed);
            string empty = string.Empty;
            if (num2 < 60)
            {
                empty = string.Concat(num2.ToString(), " seconds ago");
            }
            else if (num2 < 3600)
            {
                int num3 = num2 / 60;
                empty = string.Concat(num3.ToString(), " minutes ago");
            }
            else if (num2 >= 172800)
            {
                int num4 = num2 / 60 / 60 / 24;
                empty = string.Concat(num4.ToString(), " days ago");
            }
            else
            {
                int num5 = num2 / 60 / 60;
                empty = string.Concat(num5.ToString(), " hours ago");
            }
            ServerBrowser.Server server1 = server;
            server1.name = string.Concat(server1.name, " (", empty, ")");
            this.servers[4].Add(server);
            this.categoryButtons[4].UpdateServerCount(this.servers[4].Count);
            return;
        }
        if (tags.Contains("official"))
        {
            this.servers[0].Add(server);
            this.categoryButtons[0].UpdateServerCount(this.servers[0].Count);
            return;
        }
        string[] strArrays = tags.Split(new char[] { ',' });
        for (int i = 0; i < (int)strArrays.Length; i++)
        {
            string str1 = strArrays[i];
            if (!str1.StartsWith("mp"))
            {
                if (!str1.StartsWith("cp"))
                {
                    if (str1.StartsWith("sg:") && ulong.TryParse(str1.Substring(3), NumberStyles.HexNumber, null, out num))
                    {
                        if (!SteamGroups.MemberOf(num))
                        {
                            return;
                        }
                        this.servers[3].Add(server);
                        this.categoryButtons[3].UpdateServerCount(this.servers[3].Count);
                        return;
                    }
                }
            }
        }
        if (tags.Contains("modded"))
        {
            this.servers[2].Add(server);
            this.categoryButtons[2].UpdateServerCount(this.servers[2].Count);
            return;
        }
        if (strHostname.Contains("oxide", true))
        {
            return;
        }
        if (strHostname.Contains("rust++", true))
        {
            return;
        }
        this.servers[1].Add(server);
        this.categoryButtons[1].UpdateServerCount(this.servers[1].Count);
    }
Exemple #3
0
    public void UpdateServerList()
    {
        this.needsServerListUpdate = false;
        int maxServers = this.GetMaxServers();

        maxServers = Math.Min(this.servers[this.serverType].Count, maxServers);
        int num = this.pageNumber * maxServers;

        if (this.servers[this.serverType].Count == 0)
        {
            return;
        }
        if (num < 0)
        {
            return;
        }
        if (num > this.servers[this.serverType].Count)
        {
            return;
        }
        int num1 = (int)Mathf.Ceil((float)this.servers[this.serverType].Count / (float)maxServers);

        if (this.serverType != 4)
        {
            if (this.orderType == 0)
            {
                this.servers[this.serverType].Sort((ServerBrowser.Server x, ServerBrowser.Server y) => (x.fave == y.fave ? string.Compare(x.name, y.name) : y.fave.CompareTo(x.fave)));
            }
            if (this.orderType == 1)
            {
                this.servers[this.serverType].Sort((ServerBrowser.Server x, ServerBrowser.Server y) => (x.fave == y.fave ? (x.currentplayers == y.currentplayers ? string.Compare(x.name, y.name) : y.currentplayers.CompareTo(x.currentplayers)) : y.fave.CompareTo(x.fave)));
            }
            if (this.orderType == 2)
            {
                this.servers[this.serverType].Sort((ServerBrowser.Server x, ServerBrowser.Server y) => (x.fave == y.fave ? (x.ping == y.ping ? string.Compare(x.name, y.name) : x.ping.CompareTo(y.ping)) : y.fave.CompareTo(x.fave)));
            }
        }
        else
        {
            this.servers[this.serverType].Sort((ServerBrowser.Server x, ServerBrowser.Server y) => (x.lastplayed == y.lastplayed ? string.Compare(x.name, y.name) : y.lastplayed.CompareTo(x.lastplayed)));
        }
        if (num + maxServers > this.servers[this.serverType].Count)
        {
            maxServers = this.servers[this.serverType].Count - num;
        }
        List <ServerBrowser.Server> range = this.servers[this.serverType].GetRange(num, maxServers);

        this.pagination.Setup(num1, this.pageNumber);
        string empty = string.Empty;

        foreach (ServerBrowser.Server server in range)
        {
            empty = string.Concat(empty, server.address);
        }
        if (empty == this.currentServerChecksum)
        {
            return;
        }
        this.ClearServers();
        Vector3 vector3 = new Vector3(0f, 0f, 0f);

        this.currentServerChecksum = empty;
        bool flag = false;

        foreach (ServerBrowser.Server server1 in range)
        {
            ServerBrowser.Server server2 = server1;
            if (flag && !server1.fave)
            {
                vector3.y = vector3.y - 2f;
            }
            flag = server1.fave;
            GameObject gameObject = this.NewServerItem();
            gameObject.GetComponent <ServerItem>().Init(ref server2);
            dfControl component = gameObject.GetComponent <dfControl>();
            component.Width    = this.serverContainer.Width;
            component.Position = vector3;
            component.Show();
            vector3.y = vector3.y - 34f;
        }
        this.serverContainer.Invalidate();
    }
Exemple #4
0
    private bool ShouldIgnoreServer(ServerBrowser.Server item)
    {
        string lower = item.name.ToLower();

        if (lower.Contains("[color"))
        {
            return(true);
        }
        if (lower.Contains("[sprite"))
        {
            return(true);
        }
        if (lower.Contains("--"))
        {
            return(true);
        }
        if (lower.Contains("%%"))
        {
            return(true);
        }
        if (!char.IsLetterOrDigit(lower[0]))
        {
            return(true);
        }
        if (!char.IsLetterOrDigit(lower[lower.Length - 1]))
        {
            return(true);
        }
        string str = lower;

        for (int i = 0; i < str.Length; i++)
        {
            char chr = str[i];
            if (!char.IsLetterOrDigit(chr))
            {
                if (chr != '\'')
                {
                    if (chr != '[')
                    {
                        if (chr != ']')
                        {
                            if (chr != '|')
                            {
                                if (chr != ' ')
                                {
                                    if (chr != '-')
                                    {
                                        if (chr != '(')
                                        {
                                            if (chr != '%')
                                            {
                                                if (chr != ')')
                                                {
                                                    if (chr != '\u005F')
                                                    {
                                                        if (chr != '@')
                                                        {
                                                            if (chr != '+')
                                                            {
                                                                if (chr != '&')
                                                                {
                                                                    if (chr != ':')
                                                                    {
                                                                        if (chr != '/')
                                                                        {
                                                                            if (chr != '.')
                                                                            {
                                                                                if (chr != '?')
                                                                                {
                                                                                    if (chr != '#')
                                                                                    {
                                                                                        if (chr != '!')
                                                                                        {
                                                                                            if (chr != ',')
                                                                                            {
                                                                                                return(true);
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        if (item.currentplayers > item.maxplayers)
        {
            return(true);
        }
        if (item.currentplayers > 500)
        {
            return(true);
        }
        return(false);
    }
Exemple #5
0
 private void Add_Server(int iMaxPlayers, int iCurrentPlayers, int iPing, uint iLastPlayed, [In] string strHostname, [In] string strAddress, int iPort, int iQueryPort, [In] string tags, bool bPassworded, int iType)
 {
     ulong num;
     string str = string.Concat(strAddress, ":", iPort.ToString());
     ServerBrowser.Server server = new ServerBrowser.Server()
     {
         name = strHostname,
         address = strAddress,
         maxplayers = iMaxPlayers,
         currentplayers = iCurrentPlayers,
         ping = iPing,
         lastplayed = iLastPlayed,
         port = iPort,
         queryport = iQueryPort,
         fave = FavouriteList.Contains(str)
     };
     if (server.name.Length > 64)
     {
         server.name = server.name.Substring(0, 64);
     }
     if (this.ShouldIgnoreServer(server))
     {
         return;
     }
     ServerBrowser serverBrowser = this;
     serverBrowser.playerCount = serverBrowser.playerCount + iCurrentPlayers;
     ServerBrowser serverBrowser1 = this;
     serverBrowser1.serverCount = serverBrowser1.serverCount + 1;
     ServerBrowser serverBrowser2 = this;
     serverBrowser2.slotCount = serverBrowser2.slotCount + iMaxPlayers;
     this.needsServerListUpdate = true;
     int num1 = (int)((float)this.playerCount / (float)this.slotCount * 100f);
     this.detailsLabel.Text = string.Concat(new string[] { "Found ", this.playerCount.ToString(), " players on ", this.serverCount.ToString(), " servers. We are at ", num1.ToString(), "% capacity." });
     if (iType == 3)
     {
         this.servers[5].Add(server);
         this.categoryButtons[5].UpdateServerCount(this.servers[5].Count);
         return;
     }
     if (iType == 4)
     {
         int num2 = (int)POSIX.Time.ElapsedSecondsSince((int)server.lastplayed);
         string empty = string.Empty;
         if (num2 < 60)
         {
             empty = string.Concat(num2.ToString(), " seconds ago");
         }
         else if (num2 < 3600)
         {
             int num3 = num2 / 60;
             empty = string.Concat(num3.ToString(), " minutes ago");
         }
         else if (num2 >= 172800)
         {
             int num4 = num2 / 60 / 60 / 24;
             empty = string.Concat(num4.ToString(), " days ago");
         }
         else
         {
             int num5 = num2 / 60 / 60;
             empty = string.Concat(num5.ToString(), " hours ago");
         }
         ServerBrowser.Server server1 = server;
         server1.name = string.Concat(server1.name, " (", empty, ")");
         this.servers[4].Add(server);
         this.categoryButtons[4].UpdateServerCount(this.servers[4].Count);
         return;
     }
     if (tags.Contains("official"))
     {
         this.servers[0].Add(server);
         this.categoryButtons[0].UpdateServerCount(this.servers[0].Count);
         return;
     }
     string[] strArrays = tags.Split(new char[] { ',' });
     for (int i = 0; i < (int)strArrays.Length; i++)
     {
         string str1 = strArrays[i];
         if (!str1.StartsWith("mp"))
         {
             if (!str1.StartsWith("cp"))
             {
                 if (str1.StartsWith("sg:") && ulong.TryParse(str1.Substring(3), NumberStyles.HexNumber, null, out num))
                 {
                     if (!SteamGroups.MemberOf(num))
                     {
                         return;
                     }
                     this.servers[3].Add(server);
                     this.categoryButtons[3].UpdateServerCount(this.servers[3].Count);
                     return;
                 }
             }
         }
     }
     if (tags.Contains("modded"))
     {
         this.servers[2].Add(server);
         this.categoryButtons[2].UpdateServerCount(this.servers[2].Count);
         return;
     }
     if (strHostname.Contains("oxide", true))
     {
         return;
     }
     if (strHostname.Contains("rust++", true))
     {
         return;
     }
     this.servers[1].Add(server);
     this.categoryButtons[1].UpdateServerCount(this.servers[1].Count);
 }