private void mapFilenamesToTADToolStripMenuItem_Click(object sender, EventArgs e) { if (m_cacheFile == null || m_tadFile == null) { return; } FilenameDatabase filenameDB = new FilenameDatabase(); LoadingDialog loadingDialog = new LoadingDialog(); loadingDialog.SetData(filenameDB); Thread thread = new Thread(delegate() { filenameDB.MapFilenamesToTADInstance(m_cacheFile); }); loadingDialog.ShowDialog(thread); DescriptionDatabase descDB = new DescriptionDatabase(); loadingDialog = new LoadingDialog(); loadingDialog.SetData(descDB); thread = new Thread(delegate() { descDB.MapDescriptionToTADInstance(m_tadFile); }); loadingDialog.ShowDialog(thread); tadDataTable1.SetCache(m_cacheFile); m_cacheFile.Write(m_cacheFile.Filename); }
public void ConvertLegacy(string filename) { DataCollection dataCollection; using (FileStream reader = new FileStream(filename, FileMode.Open)) { BinaryFormatter binaryFormatter = new BinaryFormatter(); dataCollection = (DataCollection)binaryFormatter.Deserialize(reader); } if (dataCollection == null) { return; } Filename = filename.Replace(".shdcache", ".cache"); TADFile = new TADFile(); TADFile.Filename = filename.Replace(".shdcache", ".tad"); TADFile.Header.FileCount = BitConverter.ToUInt32(dataCollection.Header.FileCount1, 0); TADFile.Header.HeaderChecksum = BitConverter.ToUInt32(dataCollection.Header.HeaderChecksum, 0); TADFile.Header.TacSize = BitConverter.ToUInt32(dataCollection.Header.TacSize, 0); TADFile.Header.UnixTimestamp = new DateTime(1970, 1, 1).AddSeconds(BitConverter.ToInt32(dataCollection.Header.UnixTimestamp, 0)); string fileDir = Path.GetDirectoryName(Filename); string dir = fileDir; if (dataCollection.Files.Count > 0) { dir = Path.GetDirectoryName(dataCollection.Files[0].Meta.FilePath); } Header.RelativeOutputFolder = "\\" + Helper.GetRelativePath(dir, fileDir); Header.RelativeTADPath = "\\" + Helper.GetRelativePath(TADFile.Filename, fileDir); Header.RelativeTACPath = "\\" + Helper.GetRelativePath(TADFile.Filename.Replace(".tad", ".tac"), fileDir); foreach (FileStructure file in dataCollection.Files) { TADFileEntry entry = new TADFileEntry(); entry.FileOffset = BitConverter.ToUInt32(file.FileStart, 0); entry.FileSize = BitConverter.ToUInt32(file.FileSize, 0); entry.RelativePath = Helper.GetRelativePath(file.Meta.FilePath, dir); entry.Index = file.Meta.Index; byte[] firstHash = new byte[4]; Array.Copy(file.Hash1, firstHash, 4); entry.FirstHash = BitConverter.ToUInt32(firstHash, 0); byte[] secondHash = new byte[4]; Array.Copy(file.Hash1, 4, secondHash, 0, 4); entry.SecondHash = BitConverter.ToUInt32(secondHash, 0); byte[] unknown = new byte[4]; Array.Copy(file.Hash2, 0, unknown, 0, 4); entry.Unknown = BitConverter.ToUInt32(unknown, 0); entry.MD5Checksum = file.Meta.MD5Hash; TADFile.FileEntries.Add(entry); } FilenameDatabase filenameDB = new FilenameDatabase(); LoadingDialog loadingDialog = new LoadingDialog(); loadingDialog.SetData(filenameDB); Thread thread = new Thread(delegate() { filenameDB.MapFilenamesToTADInstance(this); }); loadingDialog.ShowDialog(thread); DescriptionDatabase descDB = new DescriptionDatabase(); loadingDialog = new LoadingDialog(); loadingDialog.SetData(descDB); thread = new Thread(delegate() { descDB.MapDescriptionToTADInstance(TADFile); }); loadingDialog.ShowDialog(thread); Write(Filename); if (File.Exists(filename)) { File.Delete(filename); } }