public void Remove(ServerData server)
        {
            CharacterHost charToIP = FindServer(server);

            if (charToIP != null)
            {
                AllHosts.Remove(charToIP);
                SaveChanges();
            }
        }
        public bool SetSelected(ServerData server)
        {
            CharacterHost charToIP = FindServer(server);

            if (charToIP != null)
            {
                CurrentSelected = charToIP;
                return(true);
            }
            CurrentSelected = null;
            return(false);
        }
        public string LastJoinHost()
        {
            string ret = "";

            SGGValheimMod.Log("Getting last IP for current character");
            CharacterHost charToIP = LastJoinIP();

            if (charToIP != null)
            {
                ret = charToIP.IPHost;
            }
            return(ret);
        }
        // replaced with AddJoinIP
        //public void SetJoinIP(string currentIP)
        //{
        //    SGGValheimMod.Log("Setting Join IP for : " + Character + " to " + currentIP);
        //    List<CharacterHost> characterToIPList = AllHosts;
        //    CharacterHost charToIP = characterToIPList.Find(x => x.Character == Character && x.ServerType == ServerTypes.JoinIP); //if we find the character and server type, set their last IP.
        //    if (charToIP != null)
        //    {
        //        charToIP.IPHost = currentIP;
        //    }
        //    else
        //    {  // no character found, add them to the list of characters.
        //        charToIP = new CharacterHost() { Character = Character, IPHost = currentIP, ServerType = ServerTypes.JoinIP };
        //        characterToIPList.Add(charToIP);
        //    }

        //    CurrentSelected = charToIP;
        //    SaveChanges();
        //}

        public void AddJoinIP(string currentIP)
        {
            SGGValheimMod.Log("Setting Join IP for : " + Character + " to " + currentIP);
            CharacterHost charToIP = FindServer(currentIP);

            if (charToIP != null) //already exists, no need to resave
            {
                CurrentSelected = charToIP;
                return;
            }

            charToIP = new CharacterHost()
            {
                Character = Character, IPHost = currentIP, ServerType = ServerTypes.JoinIP
            };
            AllHosts.Add(charToIP);
            CurrentSelected = charToIP;
            SaveChanges();
        }
        public void AddFavorite(ServerData server)
        {
            //first check to see if it already exists. if so, update it
            CharacterHost charToIP = FindServer(server);// Current.Find(x => x.ServerName == server.m_name);

            if (charToIP == null)
            {
                charToIP = new CharacterHost();
                AllHosts.Add(charToIP);
            }

            charToIP.Character       = Character;
            charToIP.ServerName      = server.m_name;
            charToIP.ServerType      = ServerTypes.Community;
            charToIP.SteamHostID     = server.m_steamHostID;
            charToIP.SteamHostAddr   = server.m_steamHostAddr;
            charToIP.RequirePassword = server.m_password;

            SaveChanges();
        }
Exemple #6
0
            static bool Prefix(ref ServerData ___m_joinServer)
            {
                if (m_SaveToFaves != null)
                {
                    if (m_SaveToFaves.isOn)
                    {
                        _hostList.AddFavorite(___m_joinServer);
                        Log("saved to faves");
                    }
                }
                Log("Server: " + ___m_joinServer.m_name);

                CharacterHost charToIP = _hostList.FindServer(___m_joinServer);

                if (charToIP != null && charToIP.ServerType == ServerTypes.JoinIP)
                {
                    //joinIP(charToIP.IPHost);
                    m_fejdStartup.m_joinIPAddress.text = charToIP.IPHost;
                    m_fejdStartup.OnJoinIPConnect();
                    return(false);
                }
                return(true);
            }
        public CharacterHost FindServer(string server)
        {
            CharacterHost charToIP = Current.Find(x => x.IPHost == server);

            return(charToIP);
        }
        public CharacterHost FindServer(ServerData server)
        {
            CharacterHost charToIP = Current.Find(x => x.ServerName == server.m_name || x.IPHost == server.m_name);

            return(charToIP);
        }