Esempio n. 1
0
 private void chkAutoPatch_CheckedChanged(object sender, EventArgs e)
 {
     if (isLoading)
     {
         return;
     }
     IniLibrary.instance.AutoPatch = (chkAutoPatch.Checked) ? "true" : "false";
     IniLibrary.Save();
 }
Esempio n. 2
0
 private void chkAutoPlay_CheckedChanged(object sender, EventArgs e)
 {
     if (isLoading)
     {
         return;
     }
     IniLibrary.instance.AutoPlay = (chkAutoPlay.Checked) ? "true" : "false";
     if (chkAutoPlay.Checked)
     {
         LogEvent("To disable autoplay: edit eqemupatcher.yml or wait until next patch.");
     }
     IniLibrary.Save();
 }
Esempio n. 3
0
        private void StartPatch()
        {
            Process[] pname = Process.GetProcessesByName("eqgame");
            if (pname.Length != 0)
            {
                MessageBox.Show("Everquest is running, please close it.");
                return;
            }

            if (isPatching)
            {
                return;
            }
            isPatching    = true;
            btnCheck.Text = "Cancel";

            txtList.Text = "Patching...";

            using (var input = File.OpenText("filelist.yml"))
            {
                var deserializerBuilder = new DeserializerBuilder().WithNamingConvention(new CamelCaseNamingConvention());

                var deserializer = deserializerBuilder.Build();

                filelist = deserializer.Deserialize <FileList>(input);
            }

            foreach (var entry in filelist.downloads)
            {
                Application.DoEvents();
                var path = entry.name.Replace("/", "\\");
                //See if file exists.
                if (!File.Exists(path) || isPatchForce)
                {
                    //Console.WriteLine("Downloading: "+ entry.name);
                    filesToDownload.Add(entry);
                    if (entry.size < 1)
                    {
                        totalBytes += 1;
                    }
                    else
                    {
                        totalBytes += entry.size;
                    }
                }
                else
                {
                    var md5 = UtilityLibrary.GetMD5(path);

                    if (md5.ToUpper() != entry.md5.ToUpper())
                    {
                        Console.WriteLine(entry.name + ": " + md5 + " vs " + entry.md5);
                        filesToDownload.Add(entry);
                        if (entry.size < 1)
                        {
                            totalBytes += 1;
                        }
                        else
                        {
                            totalBytes += entry.size;
                        }
                    }
                }
                Application.DoEvents();
                if (!isPatching)
                {
                    LogEvent("Patching cancelled.");
                    return;
                }
            }

            if (filelist.deletes != null && filelist.deletes.Count > 0)
            {
                foreach (var entry in filelist.deletes)
                {
                    if (File.Exists(entry.name))
                    {
                        LogEvent("Deleting " + entry.name + "...");
                        File.Delete(entry.name);
                    }
                    Application.DoEvents();
                    if (!isPatching)
                    {
                        LogEvent("Patching cancelled.");
                        return;
                    }
                }
            }

            if (filesToDownload.Count == 0)
            {
                LogEvent("Up to date with patch " + filelist.version + ".");
                progressBar.Maximum = progressBar.Value = 1;
                IniLibrary.instance.LastPatchedVersion = filelist.version;
                IniLibrary.Save();
                btnCheck.BackColor = SystemColors.Control;
                btnCheck.Text      = "Force Full Download";
                labelPerc.Text     = "Done";
                isPatching         = false;
                isDone             = true;
                isPatchForce       = false;
                return;
            }

            LogEvent("Downloading " + totalBytes + " bytes for " + filesToDownload.Count + " files...");
            curBytes = 0;

            if (!isAsync)
            {
                //progressBar.Maximum = totalBytes;
                progressBar.Maximum = 100;
                progressBar.Value   = 0;
                foreach (var entry in filesToDownload)
                {
                    //progressBar.Value = (curBytes > totalBytes) ? totalBytes : curBytes;
                    progressBar.Value = (curBytes > totalBytes) ? 100 : (int)((100d / totalBytes) * (curBytes));;
                    string url = filelist.downloadprefix + entry.name.Replace("\\", "/");
                    DownloadFile(url, entry.name);
                    curBytes += entry.size;
                    Application.DoEvents();
                    if (!isPatching)
                    {
                        LogEvent("Patching cancelled.");
                        return;
                    }
                }
                progressBar.Value = progressBar.Maximum;
                LogEvent("Complete! Press Play to begin.");
                IniLibrary.instance.LastPatchedVersion = filelist.version;
                IniLibrary.Save();
                btnCheck.BackColor = SystemColors.Control;
                btnCheck.Text      = "Force Full Download";
                labelPerc.Text     = "Done";
                isPatching         = false;
                isDone             = true;
                isPatchForce       = false;
            }
            else
            {
                progressBar.Maximum = 100;
                progressBar.Value   = 0;
                string path;

                foreach (var entry in filesToDownload)
                {
                    isAsyncDone = false;
                    path        = entry.name.Replace("/", "\\");
                    string url = filelist.downloadprefix + path;

                    LogEvent(path + "...");

                    DownloadFileUrl(url, entry.name);

                    while (!isAsyncDone)
                    {
                        Application.DoEvents();
                        if (isCancelled || isError)
                        {
                            return;
                        }
                    }
                }

                //progressBar.Value = progressBar.Maximum;
                LogEvent("Complete! Press Play to begin.");
                IniLibrary.instance.LastPatchedVersion = filelist.version;
                IniLibrary.Save();
                btnCheck.BackColor = SystemColors.Control;
                btnCheck.Text      = "Force Full Download";
                labelPerc.Text     = "Done";
                isPatching         = false;
                isDone             = true;
                isPatchForce       = false;
            }
        }
Esempio n. 4
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            if (MainForm.defaultAutoPlay || MainForm.defaultAutoPatch)
            {
                Console.WriteLine("Auto default enabled");
            }

            isLoading = true;

            txtList.Visible     = false;
            chkLogPatch.Checked = false;

            splashLogo.Visible = true;
            if (this.Width < 432)
            {
                this.Width = 432;
            }
            if (this.Height < 550)
            {
                this.Height = 550;
            }
            buildClientVersions();
            IniLibrary.Load();
            detectClientVersion();

            if (IniLibrary.instance.ClientVersion == VersionTypes.Unknown)
            {
                detectClientVersion();
                if (currentVersion == VersionTypes.Unknown)
                {
                    this.Close();
                }
                IniLibrary.instance.ClientVersion = currentVersion;
                IniLibrary.Save();
            }
            string suffix = "unk";

            if (currentVersion == VersionTypes.Titanium)
            {
                suffix = "tit";
            }
            if (currentVersion == VersionTypes.Underfoot)
            {
                suffix = "und";
            }
            if (currentVersion == VersionTypes.Seeds_Of_Destruction)
            {
                suffix = "sod";
            }
            if (currentVersion == VersionTypes.Broken_Mirror)
            {
                suffix = "bro";
            }
            if (currentVersion == VersionTypes.Secrets_Of_Feydwer)
            {
                suffix = "sof";
            }
            if (currentVersion == VersionTypes.Rain_Of_Fear || currentVersion == VersionTypes.Rain_Of_Fear_2)
            {
                suffix = "rof";
            }

            bool isSupported = false;

            foreach (var ver in supportedClients)
            {
                if (ver != currentVersion)
                {
                    continue;
                }
                isSupported = true;
                break;
            }
            if (!isSupported)
            {
                MessageBox.Show("The server " + serverName + " does not work with this copy of Everquest (" + currentVersion.ToString().Replace("_", " ") + ")", serverName);
                this.Close();
                return;
            }

            this.Text = serverName + " (Client: " + currentVersion.ToString().Replace("_", " ") + ")";

            string webUrl   = filelistUrl + suffix + "/filelist_" + suffix + ".yml";
            string response = DownloadFile(webUrl, "filelist.yml");

            if (response != "")
            {
                MessageBox.Show("Failed to fetch filelist from " + webUrl + ": " + response);
                this.Close();
                return;
            }

            txtList.Visible     = false;
            chkLogPatch.Checked = false;

            splashLogo.Visible = true;
            FileList filelist;

            using (var input = File.OpenText("filelist.yml"))
            {
                var deserializerBuilder = new DeserializerBuilder().WithNamingConvention(new CamelCaseNamingConvention());

                var deserializer = deserializerBuilder.Build();

                filelist = deserializer.Deserialize <FileList>(input);
            }

            if (filelist.version != IniLibrary.instance.LastPatchedVersion)
            {
                isNeedingPatch     = true;
                btnCheck.BackColor = Color.Red;
            }
            else
            {
                if (IniLibrary.instance.AutoPlay.ToLower() == "true")
                {
                    PlayGame();
                }
            }
            chkAutoPlay.Checked   = (IniLibrary.instance.AutoPlay == "true");
            chkAutoPatch.Checked  = (IniLibrary.instance.AutoPatch == "true");
            chkAsyncPatch.Checked = (IniLibrary.instance.Async == "true");

            isLoading = false;
            if (File.Exists("eqemupatcher.png"))
            {
                splashLogo.Load("eqemupatcher.png");
            }
        }
Esempio n. 5
0
        private void StartPatch()
        {
            if (isPatching)
            {
                return;
            }
            isPatching    = true;
            btnCheck.Text = "Cancel";

            txtList.Text = "Patching...";
            FileList filelist;

            using (var input = File.OpenText("filelist.yml"))
            {
                var deserializerBuilder = new DeserializerBuilder().WithNamingConvention(new CamelCaseNamingConvention());

                var deserializer = deserializerBuilder.Build();

                filelist = deserializer.Deserialize <FileList>(input);
            }
            int totalBytes = 0;
            List <FileEntry> filesToDownload = new List <FileEntry>();

            foreach (var entry in filelist.downloads)
            {
                Application.DoEvents();
                var path = entry.name.Replace("/", "\\");
                //See if file exists.
                if (!File.Exists(path))
                {
                    //Console.WriteLine("Downloading: "+ entry.name);
                    filesToDownload.Add(entry);
                    if (entry.size < 1)
                    {
                        totalBytes += 1;
                    }
                    else
                    {
                        totalBytes += entry.size;
                    }
                }
                else
                {
                    var md5 = UtilityLibrary.GetMD5(path);

                    if (md5.ToUpper() != entry.md5.ToUpper())
                    {
                        Console.WriteLine(entry.name + ": " + md5 + " vs " + entry.md5);
                        filesToDownload.Add(entry);
                        if (entry.size < 1)
                        {
                            totalBytes += 1;
                        }
                        else
                        {
                            totalBytes += entry.size;
                        }
                    }
                }
                Application.DoEvents();
                if (!isPatching)
                {
                    LogEvent("Patching cancelled.");
                    return;
                }
            }

            if (filelist.deletes != null && filelist.deletes.Count > 0)
            {
                foreach (var entry in filelist.deletes)
                {
                    if (File.Exists(entry.name))
                    {
                        LogEvent("Deleting " + entry.name + "...");
                        File.Delete(entry.name);
                    }
                    Application.DoEvents();
                    if (!isPatching)
                    {
                        LogEvent("Patching cancelled.");
                        return;
                    }
                }
            }

            if (filesToDownload.Count == 0)
            {
                LogEvent("Up to date with patch " + filelist.version + ".");
                progressBar.Maximum = progressBar.Value = 1;
                IniLibrary.instance.LastPatchedVersion = filelist.version;
                IniLibrary.Save();
                btnCheck.BackColor = SystemColors.Control;
                btnCheck.Text      = "Patch";
                return;
            }

            LogEvent("Downloading " + totalBytes + " bytes for " + filesToDownload.Count + " files...");
            int curBytes = 0;

            progressBar.Maximum = totalBytes;
            progressBar.Value   = 0;
            foreach (var entry in filesToDownload)
            {
                progressBar.Value = (curBytes > totalBytes) ? totalBytes : curBytes;
                string url = filelist.downloadprefix + entry.name.Replace("\\", "/");
                DownloadFile(url, entry.name);
                curBytes += entry.size;
                Application.DoEvents();
                if (!isPatching)
                {
                    LogEvent("Patching cancelled.");
                    return;
                }
            }
            progressBar.Value = progressBar.Maximum;
            LogEvent("Complete! Press Play to begin.");
            IniLibrary.instance.LastPatchedVersion = filelist.version;
            IniLibrary.Save();
            btnCheck.BackColor = SystemColors.Control;
            btnCheck.Text      = "Patch";
        }