public LoginServerConnection(Constants.OperatingSystem opSystem, ushort version, string accountName, string password, bool openTibia, LoginServer[] loginServers, bool debug)
 {
     this.version = version;
     this.accName = accountName;
     this.password = password;
     this.ot = openTibia;
     this.debug = debug;
     this.loginServers = loginServers;
     this.maxLoginServers = loginServers.Length;
     this.os = (byte)opSystem;
 }
 /// <summary>
 /// Set the client to use the given OT server
 /// </summary>
 /// <param name="ls"></param>
 /// <returns></returns>
 public void SetOT(LoginServer ls)
 {
     SetOT(ls.Server, ls.Port);
 }
Exemple #3
0
        public static Client ChooseClient(ClientChooserOptions options, object selectedItem, LoginServer ls)
        {
            Client client = null;
            if (selectedItem.GetType() == typeof(string))
            {
                switch ((string)selectedItem)
                {
                    case NewClientDefaultText:
                        client = Client.OpenMC();
                        break;
                    case NewClientCustomText:
                        OpenFileDialog dialog = new OpenFileDialog();
                        dialog.Filter =
                           "Executable files (*.exe)|*.exe|All files (*.*)|*.*";
                        dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
                        dialog.Title = "Select a Tibia client executable";
                        if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(dialog.FileName);
                            if (fvi.ProductName.Equals("Tibia Player"))
                            {
                                client = Client.Open(dialog.FileName, options.Arguments);
                                if (options.SaveClientPath == true)
                                {
                                    ClientChooserBase.SaveClientPath(
                                        options.SavedClientPathsLocation,
                                        dialog.FileName,
                                        fvi.FileVersion);
                                }

                            }
                            else
                            {
                                client = null;
                            }
                        }
                        else
                        {
                            client = null;
                        }
                        break;
                }
            }
            else if (selectedItem.GetType() == typeof(ClientPathInfo))
            {
                string clientPath = ((ClientPathInfo)selectedItem).Path;
               // Version.Set(FileVersionInfo.GetVersionInfo(clientPath).FileVersion);
                client = Client.OpenMC(clientPath, options.Arguments);
            }
            else
            {
                client = (Client)selectedItem;
            }

            // Set addresses
            if (client != null)
                Version.Set(client.Version, client.Process);

            // Set OT server
            if (client != null && options.UseOT)
            {
                client.Login.SetOT(ls);
                SaveOtServer(options.SavedServersLocation, ls, client.Version);
            }
            
            // Set client to run on one processor if instructed by the user
            if (options.UseSingleProcessor)
                client.Process.ProcessorAffinity = (IntPtr)1;

            return client;
        }
Exemple #4
0
        public static void SaveOtServer(string location, LoginServer ot, string version)
        {
            XmlDocument document = new XmlDocument();
            XmlElement servers = null;
            bool exists = false;

            if (File.Exists(location))
            {
                document.Load(location);
                servers = document["servers"];
                foreach (XmlElement clientPath in servers)
                {
                    if (clientPath.GetAttribute("ip").Equals(ot.Server) &&
                        clientPath.GetAttribute("port").Equals(ot.Port.ToString()))
                    {
                        exists = true;
                        break;
                    }
                }
            }
            else
            {
                XmlDeclaration Declaration = document.CreateXmlDeclaration("1.0", "", "");
                document.AppendChild(Declaration);
                servers = document.CreateElement("servers");
                document.AppendChild(servers);
            }

            if (!exists)
            {
                XmlElement server = document.CreateElement("server");

                XmlAttribute ipAttr = document.CreateAttribute("ip");
                ipAttr.InnerText = ot.Server;

                XmlAttribute portAttr = document.CreateAttribute("port");
                portAttr.InnerText = ot.Port.ToString();

                XmlAttribute versionAttr = document.CreateAttribute("version");
                versionAttr.InnerText = version;

                server.Attributes.Append(ipAttr);
                server.Attributes.Append(portAttr);
                server.Attributes.Append(versionAttr);

                servers.AppendChild(server);

                if (!Directory.Exists(Constants.TAConstants.AppDataPath))
                    Directory.CreateDirectory(Constants.TAConstants.AppDataPath);

                document.Save(location);
            }
        }
 private void ChooseClient()
 {
     options.UseOT = uxUseOT.IsExpanded;
     LoginServer ls = null;
     if (options.UseOT)
     {
         string[] split = uxLoginServer.Text.Split(new char[] { ':' });
         ls = new LoginServer(split[0], short.Parse(split[1]));
     }
     client = ClientChooserBase.ChooseClient(options, uxClients.SelectedItem, ls);
     newClientChooser.Close();
 }
Exemple #6
0
        private void ChooseClient()
        {
            options.UseOT = uxUseOT.Checked;
            LoginServer ls = null;

            if (options.UseOT)
            {
                string[] split = uxLoginServer.Text.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);

                if (split.Length == 2)
                    ls = new LoginServer(split[0].Trim(), short.Parse(split[1]));
                else
                    ls = new LoginServer(uxLoginServer.Text.Trim(), 7171);
            }

            client = ClientChooserBase.ChooseClient(options, uxClients.SelectedItem, ls);
            newClientChooser.Dispose();
        }
Exemple #7
0
 /// <summary>
 /// Set the client to use the given OT server
 /// </summary>
 /// <param name="ls"></param>
 /// <returns></returns>
 public void SetOT(LoginServer ls)
 {
     SetOT(ls.Server, ls.Port);
 }