Exemplo n.º 1
0
        private void frmMain_Shown(object sender, EventArgs e)
        {
            if (RegHelper.Initialize() == false)
            {
                MessageBox.Show("Failed to access the registry!\nPlease check your user access.", "Patch error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
                return;
            }

            DataHelper.ValidateInstallDir();

            CheckStatus();
            Application.DoEvents();

            UpdateStatus("Check for Patcher updates..");
            UpdateHandler uHandler = new UpdateHandler();

            if (uHandler.CheckVersion(System.Reflection.Assembly.GetExecutingAssembly(), "http://blubbro.de/patcher/") == true && uHandler.StartUpdate() == true)
            {
                UpdateStatus("Patcher update found. Start download..");
                Close();
                return;
            }

            btnGameStart.Enabled = false;
            PatchlistHelper.OnPatchProgressComplete = ProgressPatches;
            PatchlistHelper.Download(mPatchUrl + "Patches.txt");
        }
Exemplo n.º 2
0
        private void mChecksumWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            // tell user we are ready
            UpdateProgressbar(100);

            // write fetched offsets
            RegHelper.WriteValue("ChkData", (int)ChecksumData);
            RegHelper.WriteValue("ChkInsane", (int)ChecksumInsane);

            // we are done!
            FinishPatcher();
        }
Exemplo n.º 3
0
        private void HandlePatchFinish(ClientPatch Patch, bool Cancel)
        {
            UpdateProgressbar(100);

            if (ApplyPatch(Patch) == true)
            {
                RegHelper.SavePatch(Patch.PatchID);
                mPatchedFiles.Add(Patch.PatchID);
            }

            mPatchProgress++;
            ProgressPatches();
        }
Exemplo n.º 4
0
        public static void ValidateInstallDir()
        {
            string filename   = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "BlubbRO Patcher.dat");
            bool   firstStart = File.Exists(filename);

            if (firstStart == true)
            {
                return;
            }

            // first install, reset patches
            RegHelper.PatchReset(0);
            // write "check file"
            File.WriteAllLines(filename, new string[1] {
                filename
            });
        }
Exemplo n.º 5
0
        public void ProgressPatches()
        {
            UpdateProgressbar(0);
            if (PatchlistHelper.Patches.Count == 0 || mPatchedFiles.Count >= PatchlistHelper.Patches.Count)
            {
                UpdateProgressbar(100);
                FinalizePatching();
                return;
            }

            if (RegHelper.HasPatch(PatchlistHelper.Patches[mPatchProgress].PatchID) == true)
            {
                mPatchedFiles.Add(PatchlistHelper.Patches[mPatchProgress].PatchID);
                mPatchProgress++;
                ProgressPatches();
                return;
            }

            PatchlistHelper.Patches[mPatchProgress].Download(HandlePatchProgress, HandlePatchFinish);
        }
Exemplo n.º 6
0
 private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
 {
     RegHelper.Close();
 }
Exemplo n.º 7
0
        private bool ApplyPatch(ClientPatch Patch)
        {
            string grfPath;
            bool   retVal = true;

            switch (Patch.PatchAction)
            {
            case EPatchAction.PatcherUpdate:
            case EPatchAction.None:
                return(true);


            case EPatchAction.PatchReset:
                // reset reg
                RegHelper.PatchReset(Patch.PatchID);
                // fake count, so no patch proceed
                PatchlistHelper.Patches.Clear();
                // info
                MessageBox.Show("Your patches has been reset.\nPlease restart the Patcher to patch again.\n\nThank you.", "Patcher notice", MessageBoxButtons.OK, MessageBoxIcon.Information);
                // close app
                Close();
                // dont try to update on success
                return(false);

            case EPatchAction.GrfAdd:
                grfPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Patch.Target) + ".grf";
                try {
                    GrfHelper.GrfFromCache(Patch.Target, grfPath);                             // ensure GRF get loaded
                    GrfHelper.MergeGrf(Patch.Target, Patch.FilePath);
                } catch (Exception e) {
                    retVal = false;
                    MessageBox.Show("Failed to apply Patch \"" + Patch.PatchName + "\".\nSkip..");
                    System.Diagnostics.Debug.WriteLine(e);
                }
                break;

            case EPatchAction.GrfDelete:
                grfPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Patch.Target) + ".grf";
                try {
                    GrfHelper.GrfFromCache(Patch.Target, grfPath);                             // ensure GRF get loaded
                    GrfHelper.DeleteFromGrf(Patch.Target, Patch.PatchName);
                } catch (Exception e) {
                    retVal = false;
                    MessageBox.Show("Failed to apply Patch \"" + Patch.PatchName + "\".\nSkip..");
                    System.Diagnostics.Debug.WriteLine(e);
                }
                break;

            case EPatchAction.DataAdd:
                if (DataHelper.AddFiles(Patch.FilePath) == false)
                {
                    retVal = false;
                    MessageBox.Show("Failed to apply Patch \"" + Patch.PatchName + "\".\nSkip..");
                }
                break;

            case EPatchAction.DataDelete:
                if (DataHelper.DeleteFile(Patch.PatchName) == false)
                {
                    retVal = false;
                    MessageBox.Show("Failed to apply Patch \"" + Patch.PatchName + "\".\nSkip..");
                }
                break;
            }

            return(retVal);
        }