Example #1
0
        private void patchConverterToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog.Title = "Select the patch you wish to convert";
            openFileDialog.Filter = "MUO patch (*.muo)|*.muo|UOP patch (*.uop)|*.uop|Verdata patch (verdata.mul)|verdata.mul";
            openFileDialog.FileName = string.Empty;

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                UpdateStatus("Loading " = openFileDialog.FileName + "...");
                PatchReader reader = new PatchReader(File.Open(openFileDialog.FileName, FileMode.Open), PatchReader.ExtensionToPatchFileType(Path.GetExtension(openFileDialog.FileName)));

                UpdateStatus("Reading patches, please wait... ");
                List<Patch> patches = reader.ReadPatches();

                UpdateStatus("Loaded " + patches.Count.ToString() + " patches into memory...");
                saveFileDialog.Title = "Select where you wish to save the patches to";
                saveFileDialog.Filter = "MUO patch (*.muo)|*.muo|UOP patch (*.uop)|*.uop|Verdata patch (verdata.mul)|verdata.mul";
                saveFileDialog.FileName = string.Empty;

                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    PatchFileType type = PatchReader.ExtensionToPatchFileType(Path.GetExtension(saveFileDialog.FileName));

                    UpdateStatus("Saving patches, please wait... ");

                    PatchWriter writer = new PatchWriter(File.Open(saveFileDialog.FileName, FileMode.OpenOrCreate), type);

                    switch (type)
                    {
                        case PatchFileType.MUO:
                            PatchWriter.CreateMUO(saveFileDialog.FileName, patches); break;
                        case PatchFileType.UOP:
                            PatchWriter.CreateUOP(saveFileDialog.FileName, patches); break;
                        case PatchFileType.Verdata:
                            break;
                    }

                    UpdateStatus("Patch conversion complete");
                    MessageBox.Show("Patch conversion complete", "Success");
                }
                else
                    MessageBox.Show("Patch conversion process aborted", "Aborted");

                if (reader != null)
                    reader.Close();

                patches = null;
            }
        }
Example #2
0
        private void ApplyPatches(DirectoryInfo patchFolder)
        {
            OnStatusChange(null, new StatusChangeEventArgs("Gathering Patch data..."));

            FileInfo[] muoFiles = patchFolder.GetFiles("*.muo");
            FileInfo[] uopFiles = patchFolder.GetFiles("*.uop");
            FileInfo[] mulFiles = patchFolder.GetFiles("verdata.mul");

            _allPatchFiles = new List <FileInfo>();
            _allPatchFiles.AddRange(muoFiles);
            _allPatchFiles.AddRange(uopFiles);

            for (int i = 0; i < mulFiles.Length; i++)
            {
                _allPatchFiles.Add(mulFiles[i]);
            }

            if (!CrcCheck(_allPatchFiles))
            {
                List <Patch> patches = new List <Patch>();
                for (int i = 0; i < _allPatchFiles.Count; i++)
                {
                    PatchReader reader = new PatchReader(File.OpenRead(_allPatchFiles[i].FullName), PatchReader.ExtensionToPatchFileType(_allPatchFiles[i].FullName));
                    patches.AddRange(reader.ReadPatches());
                    reader.Close();
                }

                _patcher = new Patcher(patches.ToArray(), patchFolder.FullName, _oldPatchingStyle);                //Switch argument 2 to false for new patching system.
                _patcher.ProgressChange   += new ProgressChangeHandler(OnPatchProgressChange);
                _patcher.PatchingComplete += new OperationCompleteHandler(OnPatchingComplete);
                _patcher.StatusChange     += new StatusChangeHandler(OnStatusChange);
                _patcher.WritePatches();
            }
            else
            {
                OnPatchingComplete(null, new OperationCompleteArgs());
            }
        }
Example #3
0
        internal void Import(string path)
        {
            PatchReader reader = new PatchReader(File.OpenRead(path));
            string ext = Path.GetExtension(path);

            if( ext == ".uop" )
            {
                if( reader.ReadInt32() != PatchReader.UOPHeader )
                {
                    MessageBox.Show("Invalid UOP file, Aborting", "Invalid File");
                    return;
                }

                int count = reader.ReadInt32();
                reader.ReadInt32();//UNKNOWN FIELD

                for( int i = 0; i < count; i++ )
                {
                    Patch p = reader.ReadUOPPatch();

                    if( IsValid(p.FileID) && !ContainsPatch(p) )
                        _patches.Add(p);
                }
            }
            else if ( ext == ".muo" )
            {
                if( reader.ReadInt32() != PatchReader.MUOHeader )
                {
                    MessageBox.Show("Invalid MUO file, Aborting", "Invalid File");
                    return;
                }

                string[] data = reader.ReadMUOHeaderData();
                int count = reader.ReadInt32();

                for( int i = 0; i < count; i++ )
                {
                    Patch p = reader.ReadMUOPatch();

                    if( IsValid(p.FileID) && !ContainsPatch(p) )
                        _patches.Add(p);
                }
            }
            else if( ext == ".puo" )
            {
                if( reader.ReadInt32() != PatchReader.UOPHeader )
                {
                    MessageBox.Show("Invalid UOP file, Aborting", "Invalid File");
                    return;
                }
                reader.Close();

                PatchUOFileReader puoReader = new PatchUOFileReader(File.OpenRead(path));

                List<Patch> patches = puoReader.ReadPatches();
                for( int i = 0; i < patches.Count; i++ )
                {
                    Patch p = patches[i];

                    if( IsValid(p.FileID) && !ContainsPatch(p) )
                        _patches.Add(p);
                }

                puoReader.Close();
            }
            else if( ext == ".mul" )
            {
                try
                {
                    int count = reader.ReadInt32();

                    for( int i = 0; i < count; i++ )
                    {
                        Patch p = reader.ReadVerdataPatch();

                        if( IsValid(p.FileID) && !ContainsPatch(p) )
                            _patches.Add(p);
                    }
                }
                catch
                {
                    MessageBox.Show("Invalid or corrupt verdata file.", "Error");
                }
            }
            else
                MessageBox.Show("That file extension is invalid.", "Not Supported");

            if( reader != null )
                reader.Close();
        }
Example #4
0
        private void ApplyPatches(DirectoryInfo patchFolder)
        {
            OnStatusChange(null, new StatusChangeEventArgs("Gathering Patch data..."));

            FileInfo[] muoFiles = patchFolder.GetFiles("*.muo");
            FileInfo[] uopFiles = patchFolder.GetFiles("*.uop");
            FileInfo[] mulFiles = patchFolder.GetFiles("verdata.mul");

            _allPatchFiles = new List<FileInfo>();
            _allPatchFiles.AddRange(muoFiles);
            _allPatchFiles.AddRange(uopFiles);

            for( int i = 0; i < mulFiles.Length; i++ )
                    _allPatchFiles.Add(mulFiles[i]);

            if( !CrcCheck(_allPatchFiles) )
            {
                List<Patch> patches = new List<Patch>();
                for( int i = 0; i < _allPatchFiles.Count; i++ )
                {
                    PatchReader reader = new PatchReader(File.OpenRead(_allPatchFiles[i].FullName), PatchReader.ExtensionToPatchFileType(_allPatchFiles[i].FullName));
                    patches.AddRange(reader.ReadPatches());
                    reader.Close();
                }

                _patcher = new Patcher(patches.ToArray(), patchFolder.FullName, _oldPatchingStyle);//Switch argument 2 to false for new patching system.
                _patcher.ProgressChange += new ProgressChangeHandler(OnPatchProgressChange);
                _patcher.PatchingComplete += new OperationCompleteHandler(OnPatchingComplete);
                _patcher.StatusChange += new StatusChangeHandler(OnStatusChange);
                _patcher.WritePatches();
            }
            else
                OnPatchingComplete(null, new OperationCompleteArgs());
        }