コード例 #1
0
        public Filetype(DAT dat, TERF terf)
        {
            mmap_data       = new MMAP();
            compressed_data = new List <byte>();
            undefined_data  = new List <byte>();
            filetype        = "";
            nullfile        = false;
            changed         = false;
            needsfixed      = false;
            size            = 0;

            this.Read(dat, terf, false, -1);
        }
コード例 #2
0
ファイル: DATA.cs プロジェクト: maddeninthehouse/maddenAMP
        public void Read(DAT dat, TERF terf)
        {
            if (this.Data_id != dat.binreader.ReadUInt32())
            {
                dat.binreader.BaseStream.Position -= 4;
                dat.errormsg = "Problem with DIR1 / COMP";
                return;
            }

            this.datalength = dat.binreader.ReadUInt32();
            dat.binreader.BaseStream.Position += (terf.GetPad(8));                                  //  Advance through any needed padding

            #region Read Data files
            this.DataFiles = new List <Filetype>();

            for (int c = 0; c < terf.files; c++)
            {
                bool compressed = false;
                int  size       = -1;

                size = (int)terf.Dir1.DirTable[c].filelength;                                       //  set size from dir info
                if (terf.Comp.length > 0)                                                           //  If there is a comp table
                {
                    if (terf.Comp.CompTable[c].file_complevel == 5)                                 //  If this file is compressed
                    {
                        compressed = true;
                    }
                }

                Filetype ft = new Filetype();                                                       //  Set up new instance of data type
                ft.Read(dat, terf, compressed, size);                                               //  Read in this data file

                if (dat.errormsg != "")
                {
                    return;
                }

                DataFiles.Add(ft);                                                                  //  Add to datafiles list
                if (size == 0)
                {
                    ft.nullfile = true;
                }

                int pad = terf.GetPad(size);
                dat.binreader.BaseStream.Position += pad;                                           //  Skip through padding for this file
            }


            #endregion
        }
コード例 #3
0
ファイル: DATA.cs プロジェクト: maddeninthehouse/maddenAMP
        public void Write(DAT dat, TERF terf, ProgressBar datprogress)
        {
            dat.binwriter.Write(this.Data_id);
            dat.binwriter.Write(this.datalength);

            dat.WriteNulls(terf.GetPad(8));

            for (int c = 0; c < terf.files; c++)
            {
                DataFiles[c].Write(dat, terf, c);
                dat.WriteNulls(terf.GetPad((int)terf.Dir1.DirTable[c].filelength));
                datprogress.PerformStep();
            }
        }
コード例 #4
0
        public void Write(DAT dat, ProgressBar datprogress)
        {
            dat.binwriter.Write(this.terf_id);
            dat.binwriter.Write(this.headerlength);
            dat.binwriter.Write(this.unknown);
            dat.binwriter.Write(this.filepad);
            dat.binwriter.Write(this.files);
            datprogress.Maximum = this.files;

            dat.WriteNulls((int)this.headerlength - 16);

            this.Dir1.Write(dat, this);
            this.Comp.Write(dat, this);
            this.Data.Write(dat, this, datprogress);
        }
コード例 #5
0
ファイル: DIR1.cs プロジェクト: maddeninthehouse/maddenAMP
        public void Init(DAT dat)
        {
            this.length = 8 + Convert.ToUInt32(dat.ParentTerf.files * 8);
            int pad = dat.GetPad((int)length, (int)dat.ParentTerf.filepad);

            this.length  += (uint)pad;
            this.DirTable = new List <direntry>();

            for (int c = 0; c < dat.ParentTerf.files; c++)
            {
                direntry entry = new direntry();
                entry.filelength       = 0;
                entry.datatable_offset = 0;

                this.DirTable.Add(entry);
            }
        }
コード例 #6
0
ファイル: DIR1.cs プロジェクト: maddeninthehouse/maddenAMP
        public void Write(DAT dat, TERF terf)
        {
            if (needsfixed)
            {
                this.Fix(terf);
            }

            dat.binwriter.Write(this.dir1_id);
            dat.binwriter.Write(this.length);
            foreach (direntry entry in this.DirTable)
            {
                dat.binwriter.Write(entry.datatable_offset);
                dat.binwriter.Write(entry.filelength);
            }

            dat.WriteNulls(terf.GetPad((this.DirTable.Count * 8) + 8));
        }
コード例 #7
0
ファイル: COMP.cs プロジェクト: maddeninthehouse/maddenAMP
        public void Write(DAT dat, TERF terf)
        {
            if (needsfixed)
            {
                Fix(terf);
            }
            if (!valid)
            {
                return;
            }

            dat.binwriter.Write(this.comp_id);
            dat.binwriter.Write(this.length);

            foreach (ct_entry entry in this.CompTable)
            {
                dat.binwriter.Write(entry.file_complevel);
                dat.binwriter.Write(entry.file_uncomplength);
            }

            dat.WriteNulls(terf.GetPad((int)this.length));
        }
コード例 #8
0
ファイル: DIR1.cs プロジェクト: maddeninthehouse/maddenAMP
        public void Read(DAT dat, TERF terf)
        {
            if (this.dir1_id != dat.binreader.ReadUInt32())
            {
                dat.binreader.BaseStream.Position -= 4;
                dat.errormsg = "Problem with Terf header";
                return;
            }

            this.DirTable = new List <direntry>();
            this.length   = dat.binreader.ReadUInt32();

            for (int c = 0; c < dat.ParentTerf.files; c++)
            {
                direntry de = new direntry();
                de.datatable_offset = dat.binreader.ReadUInt32();
                de.filelength       = dat.binreader.ReadUInt32();

                this.DirTable.Add(de);
            }

            dat.binreader.BaseStream.Position += terf.GetPad(8 + (this.DirTable.Count * 8));    //  Padding is part of the dir1 size
        }
コード例 #9
0
        public void Read(DAT dat, TERF terf, bool compressed, int dirsize)
        {
            size = dirsize;

            if (dirsize == 0)
            {
                filetype = "NULL";
                nullfile = true;
                return;
            }

            else if (compressed)
            {
                filetype = "COMP";
                for (int c = 0; c < dirsize; c++)
                {
                    this.compressed_data.Add(dat.binreader.ReadByte());
                }
                return;
            }

            else if (this.mmap_data.Read(dat) == true)
            {
                filetype = "MMAP";
                return;
            }

            else if (dirsize > 0)
            {
                for (int c = 0; c < dirsize; c++)
                {
                    this.undefined_data.Add(dat.binreader.ReadByte());
                }
                filetype     = "????";
                dat.errormsg = "Format";
            }
        }
コード例 #10
0
ファイル: COMP.cs プロジェクト: maddeninthehouse/maddenAMP
        public void Read(DAT dat, TERF terf)
        {
            this.CompTable = new List <ct_entry>();

            if (this.comp_id != dat.binreader.ReadUInt32())
            {
                dat.binreader.BaseStream.Position -= 4;
                valid = false;
                return;
            }

            valid       = true;
            this.length = dat.binreader.ReadUInt32();

            for (int c = 0; c < dat.ParentTerf.files; c++)
            {
                ct_entry ct = new ct_entry();
                ct.file_complevel    = dat.binreader.ReadUInt32();
                ct.file_uncomplength = dat.binreader.ReadUInt32();
                dat.bytecount       += 8;

                this.CompTable.Add(ct);
            }
        }
コード例 #11
0
 public void WriteFileNumber(DAT dat, int filenum)
 {
     this.Data.DataFiles[filenum].Write(dat, this, filenum);
 }