/// <summary> /// This function searches through all the IFFs in the game to /// find chunks of the type specified by the user. /// </summary> private void ScanIFFs() { string ObjDataPath = "", HouseDataPath = ""; bool LookingForSprites = false; if (m_TSOPath != "" || TxtTSOPath.Text != "") { if (TxtChunkType.Text != "") { if(TxtChunkType.Text.Contains("SPR#") || TxtChunkType.Text.Contains("SPR2") || TxtChunkType.Text.Contains("DGRP")) LookingForSprites = true; string[] Dirs = Directory.GetDirectories(m_TSOPath); foreach (string Dir in Dirs) { if (Dir.Contains("objectdata")) ObjDataPath = Dir; if (Dir.Contains("housedata")) HouseDataPath = Dir; } string[] ObjDataDirs = Directory.GetDirectories(ObjDataPath); string[] HouseDataDirs = Directory.GetDirectories(HouseDataPath); foreach (string Dir in ObjDataDirs) { string[] Files = Directory.GetFiles(Dir); foreach (string ArchivePath in Files) { if (ArchivePath.Contains(".far")) { FARArchive Archive = new FARArchive(ArchivePath); List<KeyValuePair<string, byte[]>> ArchiveFiles = Archive.GetAllEntries(); foreach (KeyValuePair<string, byte[]> ArchiveFile in ArchiveFiles) { if (!LookingForSprites) { //Skip the OTFs in 'objotf.far'... if (ArchiveFile.Key.Contains(".iff")) { Iff IffFile; List<IffChunk> Chunks = new List<IffChunk>(); int NumChunks = 0; LblScanning.Invoke(m_OnUpdateStatus, new object[] { ArchiveFile.Key }); if (!m_Debug) IffFile = new Iff(ArchiveFile.Value, ArchiveFile.Key); else IffFile = new Iff(ArchiveFile.Value); //Figure out how many chunks of the type being searched for //is in the current IFF archive. Is there a faster way to do this? foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) NumChunks++; } List<IffInfo> InfoList = new List<IffInfo>(); foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) { LstChunkTypes.Invoke(m_OnFoundChunk, new object[] { ArchiveFile.Key }); IffInfo Info = new IffInfo(); Info.ArchivePath = ArchivePath; Info.IffName = ArchiveFile.Key; Info.NumChunks = NumChunks; InfoList.Add(Info); } } m_IffInfoList.Add(Path.GetFileName(ArchivePath) + "\\" + ArchiveFile.Key, InfoList); } } else { Iff IffFile; int NumChunks = 0; if (ArchiveFile.Key.Contains(".spf") || ArchiveFile.Key.Contains(".wll") || ArchiveFile.Key.Contains(".flr")) { LblScanning.Invoke(m_OnUpdateStatus, new object[] { ArchiveFile.Key }); if (!m_Debug) IffFile = new Iff(ArchiveFile.Value, ArchiveFile.Key); else IffFile = new Iff(ArchiveFile.Value); //Figure out how many chunks of the type is being searched for //is in the current IFF archive. Is there a faster way to do this? foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) NumChunks++; } List<IffInfo> InfoList = new List<IffInfo>(); foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) { LstChunkTypes.Invoke(m_OnFoundChunk, new object[] { ArchiveFile.Key }); IffInfo Info = new IffInfo(); Info.ArchivePath = ArchivePath; Info.IffName = ArchiveFile.Key; Info.NumChunks = NumChunks; InfoList.Add(Info); } } m_IffInfoList.Add(Path.GetFileName(ArchivePath) + "\\" + ArchiveFile.Key, InfoList); } } } } else //The files in "objectdata\globals\" are not in a FAR archive... { //Some of the files in "objectdata\globals\" are *.otf files... if (ArchivePath.Contains(".iff")) { if (!LookingForSprites) { Iff IffFile = new Iff(ArchivePath); int NumChunks = 0; LblScanning.Invoke(m_OnUpdateStatus, new object[] { ArchivePath }); //Figure out how many chunks of the type is being searched for //is in the current IFF archive. Is there a faster way to do this? foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) NumChunks++; } List<IffInfo> InfoList = new List<IffInfo>(); foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) { LstChunkTypes.Invoke(m_OnFoundChunk, new object[] { Path.GetFileName(ArchivePath) }); IffInfo Info = new IffInfo(); Info.ArchivePath = ""; Info.IffName = IffFile.Path; Info.NumChunks = NumChunks; InfoList.Add(Info); } } m_IffInfoList.Add(Path.GetFileName(ArchivePath), InfoList); } } } } } foreach (string Dir in HouseDataDirs) { string[] Files = Directory.GetFiles(Dir); if (Dir.Contains("walls") || Dir.Contains("floors")) { foreach (string ArchivePath in Files) { FARArchive Archive = new FARArchive(ArchivePath); List<KeyValuePair<string, byte[]>> ArchiveFiles = Archive.GetAllEntries(); foreach (KeyValuePair<string, byte[]> ArchiveFile in ArchiveFiles) { if (!LookingForSprites) { //Don't waste time scanning *.spf files if not looking for sprites... if(!ArchiveFile.Key.Contains(".spf")) { Iff IffFile; int NumChunks = 0; LblScanning.Invoke(m_OnUpdateStatus, new object[] { ArchiveFile.Key }); if (!m_Debug) IffFile = new Iff(ArchiveFile.Value, ArchiveFile.Key); else IffFile = new Iff(ArchiveFile.Value); //Figure out how many chunks of the type is being searched for //is in the current IFF archive. Is there a faster way to do this? foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) NumChunks++; } List<IffInfo> InfoList = new List<IffInfo>(); foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) { LstChunkTypes.Invoke(m_OnFoundChunk, new object[] { ArchiveFile.Key }); IffInfo Info = new IffInfo(); Info.ArchivePath = ArchivePath; Info.IffName = ArchiveFile.Key; Info.NumChunks = NumChunks; InfoList.Add(Info); } } m_IffInfoList.Add(Path.GetFileName(ArchivePath) + "\\" + ArchiveFile.Key, InfoList); } } else { if (ArchiveFile.Key.Contains(".spf") || ArchiveFile.Key.Contains(".wll") || ArchiveFile.Key.Contains(".flr")) { Iff IffFile; int NumChunks = 0; LblScanning.Invoke(m_OnUpdateStatus, new object[] { ArchiveFile.Key }); if (!m_Debug) IffFile = new Iff(ArchiveFile.Value, ArchiveFile.Key); else IffFile = new Iff(ArchiveFile.Value); //Figure out how many chunks of the type is being searched for //is in the current IFF archive. Is there a faster way to do this? foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) NumChunks++; } List<IffInfo> InfoList = new List<IffInfo>(); foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) { LstChunkTypes.Invoke(m_OnFoundChunk, new object[] { ArchiveFile.Key }); IffInfo Info = new IffInfo(); Info.ArchivePath = ArchivePath; Info.IffName = ArchiveFile.Key; Info.NumChunks = NumChunks; InfoList.Add(Info); } } m_IffInfoList.Add(Path.GetFileName(ArchivePath) + "\\" + ArchiveFile.Key, InfoList); } } } } } } } else MessageBox.Show("Please specify a chunktype to search for!"); } LblScanning.Invoke((MethodInvoker)delegate() { LblScanning.Text = "Done, found: " + TotalNumberOfChunksFound() + " chunks."; }); BtnAbort.Invoke((MethodInvoker)delegate() { BtnAbort.Visible = false; }); m_WorkerThread.Abort(); }
/// <summary> /// This function searches through all the IFFs in the game to /// find chunks of the type specified by the user. /// </summary> private void ScanIFFs() { string ObjDataPath = "", HouseDataPath = ""; bool LookingForSprites = false; if (m_TSOPath != "" || TxtTSOPath.Text != "") { if (TxtChunkType.Text != "") { if (TxtChunkType.Text.Contains("SPR#") || TxtChunkType.Text.Contains("SPR2") || TxtChunkType.Text.Contains("DGRP")) { LookingForSprites = true; } string[] Dirs = Directory.GetDirectories(m_TSOPath); foreach (string Dir in Dirs) { if (Dir.Contains("objectdata")) { ObjDataPath = Dir; } if (Dir.Contains("housedata")) { HouseDataPath = Dir; } } string[] ObjDataDirs = Directory.GetDirectories(ObjDataPath); string[] HouseDataDirs = Directory.GetDirectories(HouseDataPath); foreach (string Dir in ObjDataDirs) { string[] Files = Directory.GetFiles(Dir); foreach (string ArchivePath in Files) { if (ArchivePath.Contains(".far")) { FARArchive Archive = new FARArchive(ArchivePath); List <KeyValuePair <string, byte[]> > ArchiveFiles = Archive.GetAllEntries(); foreach (KeyValuePair <string, byte[]> ArchiveFile in ArchiveFiles) { if (!LookingForSprites) { //Skip the OTFs in 'objotf.far'... if (ArchiveFile.Key.Contains(".iff")) { Iff IffFile; List <IffChunk> Chunks = new List <IffChunk>(); int NumChunks = 0; LblScanning.Invoke(m_OnUpdateStatus, new object[] { ArchiveFile.Key }); if (!m_Debug) { IffFile = new Iff(ArchiveFile.Value, ArchiveFile.Key); } else { IffFile = new Iff(ArchiveFile.Value); } //Figure out how many chunks of the type being searched for //is in the current IFF archive. Is there a faster way to do this? foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) { NumChunks++; } } List <IffInfo> InfoList = new List <IffInfo>(); foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) { LstChunkTypes.Invoke(m_OnFoundChunk, new object[] { ArchiveFile.Key }); IffInfo Info = new IffInfo(); Info.ArchivePath = ArchivePath; Info.IffName = ArchiveFile.Key; Info.NumChunks = NumChunks; InfoList.Add(Info); } } m_IffInfoList.Add(Path.GetFileName(ArchivePath) + "\\" + ArchiveFile.Key, InfoList); } } else { Iff IffFile; int NumChunks = 0; if (ArchiveFile.Key.Contains(".spf") || ArchiveFile.Key.Contains(".wll") || ArchiveFile.Key.Contains(".flr")) { LblScanning.Invoke(m_OnUpdateStatus, new object[] { ArchiveFile.Key }); if (!m_Debug) { IffFile = new Iff(ArchiveFile.Value, ArchiveFile.Key); } else { IffFile = new Iff(ArchiveFile.Value); } //Figure out how many chunks of the type is being searched for //is in the current IFF archive. Is there a faster way to do this? foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) { NumChunks++; } } List <IffInfo> InfoList = new List <IffInfo>(); foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) { LstChunkTypes.Invoke(m_OnFoundChunk, new object[] { ArchiveFile.Key }); IffInfo Info = new IffInfo(); Info.ArchivePath = ArchivePath; Info.IffName = ArchiveFile.Key; Info.NumChunks = NumChunks; InfoList.Add(Info); } } m_IffInfoList.Add(Path.GetFileName(ArchivePath) + "\\" + ArchiveFile.Key, InfoList); } } } } else //The files in "objectdata\globals\" are not in a FAR archive... { //Some of the files in "objectdata\globals\" are *.otf files... if (ArchivePath.Contains(".iff")) { if (!LookingForSprites) { Iff IffFile = new Iff(ArchivePath); int NumChunks = 0; LblScanning.Invoke(m_OnUpdateStatus, new object[] { ArchivePath }); //Figure out how many chunks of the type is being searched for //is in the current IFF archive. Is there a faster way to do this? foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) { NumChunks++; } } List <IffInfo> InfoList = new List <IffInfo>(); foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) { LstChunkTypes.Invoke(m_OnFoundChunk, new object[] { Path.GetFileName(ArchivePath) }); IffInfo Info = new IffInfo(); Info.ArchivePath = ""; Info.IffName = IffFile.Path; Info.NumChunks = NumChunks; InfoList.Add(Info); } } m_IffInfoList.Add(Path.GetFileName(ArchivePath), InfoList); } } } } } foreach (string Dir in HouseDataDirs) { string[] Files = Directory.GetFiles(Dir); if (Dir.Contains("walls") || Dir.Contains("floors")) { foreach (string ArchivePath in Files) { FARArchive Archive = new FARArchive(ArchivePath); List <KeyValuePair <string, byte[]> > ArchiveFiles = Archive.GetAllEntries(); foreach (KeyValuePair <string, byte[]> ArchiveFile in ArchiveFiles) { if (!LookingForSprites) { //Don't waste time scanning *.spf files if not looking for sprites... if (!ArchiveFile.Key.Contains(".spf")) { Iff IffFile; int NumChunks = 0; LblScanning.Invoke(m_OnUpdateStatus, new object[] { ArchiveFile.Key }); if (!m_Debug) { IffFile = new Iff(ArchiveFile.Value, ArchiveFile.Key); } else { IffFile = new Iff(ArchiveFile.Value); } //Figure out how many chunks of the type is being searched for //is in the current IFF archive. Is there a faster way to do this? foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) { NumChunks++; } } List <IffInfo> InfoList = new List <IffInfo>(); foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) { LstChunkTypes.Invoke(m_OnFoundChunk, new object[] { ArchiveFile.Key }); IffInfo Info = new IffInfo(); Info.ArchivePath = ArchivePath; Info.IffName = ArchiveFile.Key; Info.NumChunks = NumChunks; InfoList.Add(Info); } } m_IffInfoList.Add(Path.GetFileName(ArchivePath) + "\\" + ArchiveFile.Key, InfoList); } } else { if (ArchiveFile.Key.Contains(".spf") || ArchiveFile.Key.Contains(".wll") || ArchiveFile.Key.Contains(".flr")) { Iff IffFile; int NumChunks = 0; LblScanning.Invoke(m_OnUpdateStatus, new object[] { ArchiveFile.Key }); if (!m_Debug) { IffFile = new Iff(ArchiveFile.Value, ArchiveFile.Key); } else { IffFile = new Iff(ArchiveFile.Value); } //Figure out how many chunks of the type is being searched for //is in the current IFF archive. Is there a faster way to do this? foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) { NumChunks++; } } List <IffInfo> InfoList = new List <IffInfo>(); foreach (IffChunk Chunk in IffFile.Chunks) { if (Chunk.Resource == TxtChunkType.Text) { LstChunkTypes.Invoke(m_OnFoundChunk, new object[] { ArchiveFile.Key }); IffInfo Info = new IffInfo(); Info.ArchivePath = ArchivePath; Info.IffName = ArchiveFile.Key; Info.NumChunks = NumChunks; InfoList.Add(Info); } } m_IffInfoList.Add(Path.GetFileName(ArchivePath) + "\\" + ArchiveFile.Key, InfoList); } } } } } } } else { MessageBox.Show("Please specify a chunktype to search for!"); } } LblScanning.Invoke((MethodInvoker) delegate() { LblScanning.Text = "Done, found: " + TotalNumberOfChunksFound() + " chunks."; }); BtnAbort.Invoke((MethodInvoker) delegate() { BtnAbort.Visible = false; }); m_WorkerThread.Abort(); }