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; } }
private void InitializePatchingProcess() { Invoke((MethodInvoker) delegate() { lblStatus.Text = "Status: Gathering patching information..."; }); DirectoryInfo directory = new DirectoryInfo(_serverDirectory); List <FileInfo> files = new List <FileInfo>(); FileInfo[] muoFiles = directory.GetFiles("*.muo"); FileInfo[] uopFiles = directory.GetFiles("*.uop"); FileInfo[] mulFiles = directory.GetFiles("verdata.mul"); List <FileInfo> patchFiles = new List <FileInfo>(); patchFiles.AddRange(muoFiles); patchFiles.AddRange(uopFiles); patchFiles.AddRange(mulFiles); List <Patch> patches = new List <Patch>(); for (int i = 0; i < patchFiles.Count; i++) { PatchReader reader = new PatchReader( File.OpenRead(patchFiles[i].FullName), PatchReader.ExtensionToPatchFileType(patchFiles[i].FullName)); patches.AddRange(reader.ReadPatches()); reader.Close(); } for (int i = 0; i < muoFiles.Length; i++) { muoFiles[i].Delete(); } for (int i = 0; i < uopFiles.Length; i++) { uopFiles[i].Delete(); } for (int i = 0; i < mulFiles.Length; i++) { mulFiles[i].Delete(); } if (patches.Count <= 0) { Complete(); return; } Dictionary <int, List <Patch> > typedPatchTable = new Dictionary <int, List <Patch> >(); for (int i = 0; i < patches.Count; i++) { if (!typedPatchTable.ContainsKey(patches[i].FileId)) { typedPatchTable.Add(patches[i].FileId, new List <Patch>()); } typedPatchTable[patches[i].FileId].Add(patches[i]); } Invoke((MethodInvoker) delegate() { lvDownloads.Items.Clear(); columnHeader1.Text = "Mul File"; columnHeader2.Text = "Total"; columnHeader3.Text = "Completed"; columnHeader4.Text = "Progress"; columnHeader7.Text = "Status"; }); List <int> keys = new List <int>(typedPatchTable.Keys); _patchCount = keys.Count; for (int i = 0; i < keys.Count; i++) { int key = keys[i]; patches = typedPatchTable[keys[i]]; if (patches.Count > 0) { FileId id = (FileId)i; PatchingTask task = new PatchingTask(patches.ToArray(), _serverDirectory, id.ToString().Replace('_', '.')); task.ProgressUpdate += new EventHandler <ProgressUpdateEventArgs>(OnPatchingProgressUpdate); task.ProgressCompleted += new EventHandler <ProgressCompletedEventArgs>(OnPatchingProgressCompleted); ListViewItem item = new ListViewItem(new string[5]); Invoke((MethodInvoker) delegate() { lvDownloads.Items.Add(item); UpdatePatchingStatus(task, item, 0, 100, 0, "Patching Queued"); }); _patchTable.Add(task, item); _patchManager.Queue(task); } } _patchManager.Begin(); }
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(); } }