示例#1
0
        private static void OnResetPatchesRequested(string request, PageCompiler compiler, ref Socket socket)
        {
            string id    = Utility.ParseUrl(request, "id");
            IEntry entry = ServerList.GetServerById(id);

            if (entry != null && MessageBox.Show("Are you sure you want to reset patches for " + entry.Name + "?", "ConnectUO Desktop", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
            {
                string name = Uri.EscapeDataString(entry.Name);
                string path = Path.Combine(AppSettings.Current.Get <string>("PatchingPath"), Path.Combine("Servers", name));

                if (Directory.Exists(path))
                {
                    bool success = true;
                    try
                    {
                        Directory.Delete(path, true);
                    }
                    catch
                    {
                        success = false;
                    }

                    if (success)
                    {
                        MessageBox.Show("Patches for " + entry.Name + " were reset successfully.", "ConnectUO Desktop");
                    }
                    else
                    {
                        MessageBox.Show("An error occurred while trying to reset the patches for " + entry.Name + ".\n This can be caused by the client still running or some other application that is currently using\n the files in the patch directory for this server.\n Please be sure that nothing is accessing these files and try again.", "ConnectUO Desktop");
                    }
                }
            }

            Core.Server.SendToBrowser(String.Format(Utility.META_REDIRECT, "http://localhost.:1980/favorites.html"), ref socket);
        }
示例#2
0
        public void addLocalServerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddLocalServerDialog d = new AddLocalServerDialog();

            d.Opacity = GetOpacity("AddLocalOpacity");

            bool editmode = (sender != null && sender is object[]);

            d.EditMode = editmode;
            CustomEntry en = null;

            if (editmode)
            {
                string request = (string)((object[])sender)[0];
                Socket socket  = (Socket)((object[])sender)[1];

                en = (CustomEntry)ServerList.GetServerById(Utility.ParseUrl(request, "id"));

                if (en == null)
                {
                    MessageBox.Show("The requested server entry was invalid or did not exist");
                    Core.Server.SendToBrowser(String.Format(Utility.META_REDIRECT, "http://localhost.:1980/favorites.html"), ref socket);
                    //Utility.OpenUrl("http://localhost.:1980/favorites");
                    return;
                }

                d.ServerName        = en.Name;
                d.ServerDescription = en.Description;
                d.ServerAddress     = en.HostAddress;
                d.ServerPort        = en.Port.ToString();
                d.ServerUpdateURL   = en.UpdateUrl;
                d.ServerPatchURL    = en.PatchUrl;
                d.RemoveEnc         = en.RemoveEncryption;

                Core.Server.SendToBrowser(String.Format(Utility.META_REDIRECT, "http://localhost.:1980/favorites.html"), ref socket);
            }

            if (d.ShowDialog() == DialogResult.OK)
            {
                if (!editmode)
                {
                    en = new CustomEntry();
                }

                en.Name             = d.ServerName;
                en.Description      = d.ServerDescription;
                en.HostAddress      = d.ServerAddress;
                en.Port             = int.Parse(d.ServerPort);
                en.UpdateUrl        = d.ServerUpdateURL;
                en.PatchUrl         = d.ServerPatchURL;
                en.RemoveEncryption = d.RemoveEnc;

                Favorites.AddCustom(en);
                Utility.OpenUrl("http://localhost.:1980/favorites.html");
            }
        }
示例#3
0
        private static void Load()
        {
            _favorites = new List <FavoriteEntry>();
            _customs   = new List <CustomEntry>();

            if (File.Exists(Path.Combine(Core.BaseDirectory, "favorites.bin")))
            {
                BinaryReader reader = new BinaryReader(new FileStream(Path.Combine(Core.BaseDirectory, "favorites.bin"), FileMode.OpenOrCreate));

                int ver = reader.ReadInt32();

                switch (ver)
                {
                case 1:
                {
                    int count = reader.ReadInt32();

                    for (int i = 0; i < count; i++)
                    {
                        CustomEntry entry = new CustomEntry();
                        entry.Deserialize(reader);
                        _customs.Add(entry);
                    }

                    goto case 0;
                }

                case 0:
                {
                    int count = reader.ReadInt32();

                    for (int i = 0; i < count; i++)
                    {
                        IEntry entry = ServerList.GetServerById(reader.ReadInt32().ToString());

                        if (entry == null)
                        {
                            continue;
                        }

                        _favorites.Add(new FavoriteEntry(entry.Element));
                    }

                    break;
                }
                }

                reader.Close();
            }
        }
示例#4
0
        /// <summary>
        /// Adds the server to the favorites list.
        /// </summary>
        /// <param name="id">server id</param>
        public static void AddFavorite(string id)
        {
            int value;

            if (Int32.TryParse(id, out value) && !FavoriteExists(value))
            {
                IEntry entry = ServerList.GetServerById(id);

                if (entry != null)
                {
                    MyFavorites.Add(new FavoriteEntry(entry.Element));
                    Save();
                }
            }
        }
示例#5
0
        /// <summary>
        /// Starts the Ultima Online client for the specified server
        /// </summary>
        /// <param name="id"></param>
        /// <param name="custom"></param>
        public static unsafe void Play(string id, string type, Socket socket)
        {
            IEntry entry = ServerList.GetServerById(id);

            if (entry == null)
            {
                System.Windows.Forms.MessageBox.Show("The server information requested was not found", "Invalid Element ID");
                Core.Server.SendToBrowser(String.Format(Utility.META_REDIRECT, "http://localhost.:1980/home.html?page=1"), ref socket);
                return;
            }

            try
            {
                string client = AppSettings.Current.Get <string>("ClientPath");
                string razor  = AppSettings.Current.Get <bool>("LoadRazor") ? AppSettings.Current.Get <string>("RazorPath") : "Not Found";

                if (client == "Not Found")
                {
                    System.Windows.Forms.MessageBox.Show("You do not appear to have Ultima Online installed.", "Ultima Online Not Found");
                    Core.Server.SendToBrowser(String.Format(Utility.META_REDIRECT, "http://localhost.:1980/home.html?page=1"), ref socket);
                    return;
                }

                if (type == "public")
                {
                    Core.Server.SendToBrowser(String.Format(Utility.META_REDIRECT, "http://localhost.:1980/home.html?page=1"), ref socket);
                }
                else
                {
                    Core.Server.SendToBrowser(String.Format(Utility.META_REDIRECT, "http://localhost.:1980/favorites.html"), ref socket);
                }

                byte[] param = new byte[257];

                MemoryStream memStream = new MemoryStream(param);
                BinaryWriter writer    = new BinaryWriter(memStream);

                if (razor != "Not Found")
                {
                    writer.Write((byte)0);                     // when razor is enabled it will remove the encryption for us
                }
                else
                {
                    writer.Write((byte)Convert.ToByte(entry.RemoveEncryption));
                }

                string patch;
                string path = BuildPatchList(entry, out patch);

                writer.Write(path.ToCharArray());

                writer.Close();
                memStream.Close();

                UInt32      pid;
                LoaderError err;

                string encPath = Path.Combine(Core.BaseDirectory, "EncPatcher.dll");

                fixed(byte *para_ptr = param)
                err = (LoaderError)Load(client, encPath, "Attach", para_ptr, param.Length, out pid);

                if (err == LoaderError.SUCCESS)
                {
                    if (pid != 0 && razor != "Not Found" && entry.AllowRazor)
                    {
                        string opts;
                        if (entry.RemoveEncryption)
                        {
                            opts = "--clientenc";
                        }
                        else
                        {
                            opts = "--clientenc --serverenc";
                        }

                        System.Diagnostics.Process.Start(razor, String.Format("{0} --pid {1}", opts, pid));

                        if (MainForm.Instance.Visible)
                        {
                            MainForm.Instance.Invoke((MethodInvoker) delegate { MainForm.Instance.WindowState = FormWindowState.Minimized; });
                        }
                    }
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show(String.Format("Loader.dll ERROR: {0} (pid = {1})", err, pid));
                }
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.ToString());
                Trace.HandleException(e);
            }
        }