Example #1
0
        private void openiffToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog OFD = new OpenFileDialog();

            OFD.Filter       = "Iff files (*.iff)|*.iff|Floor files (*.flr)|*.flr|Wall files (*.wll)|*.wll|SPF files (*.spf)|*.spf";
            OFD.Title        = "Open Iff Archive...";
            OFD.AddExtension = true;

            m_CurrentSPRFrame   = 0;
            m_CurrentSPR2Frame  = 0;
            m_CurrentGroupFrame = 0;

            if (OFD.ShowDialog() == DialogResult.OK)
            {
                m_CurrentArchive = new Iffinator.Flash.Iff(OFD.FileName);

                LblNumChunks.Visible = true;
                LblNumChunks.Text    = "Number of chunks: " + m_CurrentArchive.Chunks.Count;

                if (m_CurrentArchive.SPR2s.Count > 0)
                {
                    m_CurrentSPR2          = m_CurrentArchive.GetSprite(0);
                    PictCurrentFrame.Image = m_CurrentSPR2.GetFrame(m_CurrentSPR2Frame).BitmapData.BitMap;
                }

                LstSPR2s.Items.Clear();

                /*foreach (Flash.IffChunk Chunk in m_CurrentArchive.Chunks)
                 * {
                 *  if (Chunk.Resource == "SPR2")
                 *      LstSPR2s.Items.Add("ID: " + Chunk.ID);
                 * }*/
            }
        }
        private void openiffToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog OFD = new OpenFileDialog();
            OFD.Filter = "Iff files (*.iff)|*.iff|Floor files (*.flr)|*.flr|Wall files (*.wll)|*.wll|SPF files (*.spf)|*.spf";
            OFD.Title = "Open Iff Archive...";
            OFD.AddExtension = true;

            m_CurrentSPRFrame = 0;
            m_CurrentSPR2Frame = 0;
            m_CurrentGroupFrame = 0;

            if (OFD.ShowDialog() == DialogResult.OK)
            {
                m_CurrentArchive = new Iffinator.Flash.Iff(OFD.FileName);

                LblNumChunks.Visible = true;
                LblNumChunks.Text = "Number of chunks: " + m_CurrentArchive.Chunks.Count;

                if (m_CurrentArchive.SPR2s.Count > 0)
                {
                    m_CurrentSPR2 = m_CurrentArchive.GetSprite(0);
                    PictCurrentFrame.Image = m_CurrentSPR2.GetFrame(m_CurrentSPR2Frame).BitmapData.BitMap;
                }

                LstSPR2s.Items.Clear();

                /*foreach (Flash.IffChunk Chunk in m_CurrentArchive.Chunks)
                {
                    if (Chunk.Resource == "SPR2")
                        LstSPR2s.Items.Add("ID: " + Chunk.ID);
                }*/
            }
        }
        /// <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();
        }
Example #4
0
        private Iff m_SemiGlobal;           //Related semi-global IFF file.

        public BHAVAnalyzer(Iff IffFile)
        {
            m_MyFile = IffFile;
        }
Example #5
0
        private Iff m_SemiGlobal; //Related semi-global IFF file.

        #endregion Fields

        #region Constructors

        public BHAVAnalyzer(Iff IffFile)
        {
            m_MyFile = IffFile;
        }