Exemplo n.º 1
0
 public void Write(BinaryWriter bw)
 {
     bw.Write(Ultily.WriteIntTo2Bytes(Unknown1));
     bw.Write(Ultily.WriteIntTo2Bytes(Unknown2));
     bw.Write(Size);
     bw.Write(ID);
     bw.Write(Data);
 }
Exemplo n.º 2
0
 public void Write(BinaryWriter bw)
 {
     bw.Write(SubArchiveCount);
     bw.Write(Ultily.WriteIntTo2Bytes(Unknown));
     for (int i = 0; i < SubArchiveCount; i++)
     {
         SubArchives[i].Write(bw);
     }
 }
Exemplo n.º 3
0
        public void Read(BinaryReader br)
        {
            Unknown1 = Ultily.ReadIntFrom2Bytes(br.ReadBytes(2));
            Unknown2 = Ultily.ReadIntFrom2Bytes(br.ReadBytes(2));
            Size     = br.ReadInt32();
            ID       = br.ReadInt32();
            Data     = br.ReadBytes(Size - 12);

            //Console.WriteLine("Size: {0}, ID: {1}", Size, ID);
        }
Exemplo n.º 4
0
        public void Write(BinaryWriter bw)
        {
            bw.Write(Unknown1);
            bw.Write(Ultily.WriteIntTo2Bytes(ID));
            bw.Write(Ultily.WriteIntTo2Bytes(Unknown2));
            bw.Write(Ultily.WriteIntTo2Bytes(Unknown3));
            bw.Write(Size);
            long offsetStart = bw.BaseStream.Position;

            Collection.Write(bw);
            long offsetEnd = bw.BaseStream.Position;

            bw.Seek((int)offsetStart - 4, SeekOrigin.Begin);
            Size = (int)(offsetEnd - offsetStart);
            bw.Write(Size);
            bw.Seek(Size, SeekOrigin.Current);
        }
Exemplo n.º 5
0
        public void Read(BinaryReader br)
        {
            StartAndEndFieldId = br.ReadBytes(16);
            SizeCompressed     = Ultily.ReadIntFrom2Bytes(br.ReadBytes(2));
            byte[] DataCompressed = br.ReadBytes(SizeCompressed);
            SizeDecompressed = Ultily.ReadIntFrom2Bytes(br.ReadBytes(2));

            if (SizeDecompressed < 0)
            {
                Console.WriteLine("SizeCompressed: " + SizeCompressed + "|SizeDecompressed: " + SizeDecompressed);
                //throw new Exception("SizeDecompressed is wrong!");
            }

            byte[] DataDecompressed = m_bnsDat.Deflate(DataCompressed, SizeCompressed, SizeDecompressed);
            FieldLookupCount = br.ReadInt32();
            Fields           = new BDAT_FIELDTABLE[FieldLookupCount];
            Lookups          = new BDAT_LOOKUPTABLE[FieldLookupCount];

            //Console.WriteLine("FieldLookupCount: " + FieldLookupCount);

            BinaryReader mis        = new BinaryReader(new MemoryStream(DataDecompressed));
            int          DataOffset = Ultily.ReadIntFrom2Bytes(br.ReadBytes(2));

            for (int i = 1; i <= FieldLookupCount; i++)
            {
                mis.BaseStream.Seek(DataOffset, SeekOrigin.Begin);
                //Console.WriteLine("test: " + mis.BaseStream.Position + " - " + DataOffset);

                Fields[i - 1] = new BDAT_FIELDTABLE();
                Fields[i - 1].Read(mis);

                if (i < FieldLookupCount)
                {
                    DataOffset = Ultily.ReadIntFrom2Bytes(br.ReadBytes(2));
                }
                else
                {
                    DataOffset = SizeDecompressed;
                }

                Lookups[i - 1]      = new BDAT_LOOKUPTABLE();
                Lookups[i - 1].Size = DataOffset - (int)mis.BaseStream.Position;
                Lookups[i - 1].Read(mis);
            }
        }
Exemplo n.º 6
0
        public BDAT_SUBARCHIVE[] SubArchives; // *

        public void Read(BinaryReader br)
        {
            SubArchiveCount = br.ReadInt32();
            Unknown         = Ultily.ReadIntFrom2Bytes(br.ReadBytes(2));
            SubArchives     = new BDAT_SUBARCHIVE[SubArchiveCount];

            //string DebugText = "";

            for (int i = 0; i < SubArchiveCount; i++)
            {
                SubArchives[i] = new BDAT_SUBARCHIVE();
                SubArchives[i].Read(br);

                //DebugText += SubArchives[i].SizeDecompressed + "|";
            }

            //Console.WriteLine("Count SubArchive in Archive: " + SubArchiveCount);
        }
Exemplo n.º 7
0
        public void Read(BinaryReader br)
        {
            Unknown1 = br.ReadByte();
            ID       = Ultily.ReadIntFrom2Bytes(br.ReadBytes(2));
            Unknown2 = Ultily.ReadIntFrom2Bytes(br.ReadBytes(2));
            Unknown3 = Ultily.ReadIntFrom2Bytes(br.ReadBytes(2));
            Size     = br.ReadInt32();

            long offsetStart = br.BaseStream.Position;

            Collection = new BDAT_COLLECTION();
            Collection.Read(br);
            long offsetEnd = br.BaseStream.Position;

            if (offsetStart + Size != offsetEnd)
            {
                br.BaseStream.Seek(offsetStart + Size, SeekOrigin.Begin);
            }
        }
Exemplo n.º 8
0
        public void Write(BinaryWriter bw)
        {
            BinaryWriter mos = new BinaryWriter(new MemoryStream());

            int[] DataOffsets = new int[FieldLookupCount];
            DataOffsets[0] = 0;
            for (int i = 1; i <= FieldLookupCount; i++)
            {
                Fields[i - 1].Write(mos);
                Lookups[i - 1].Write(mos);
                if (i < FieldLookupCount)
                {
                    DataOffsets[i] = (int)mos.BaseStream.Position;
                }
                if ((int)mos.BaseStream.Length < 65535)
                {
                    m_maxSize = i;
                }
            }

            SizeDecompressed = (int)mos.BaseStream.Length;

            byte[] DataDecompressed = new byte[SizeDecompressed];

            Array.Copy(((MemoryStream)mos.BaseStream).ToArray(), DataDecompressed, SizeDecompressed);//mos.CopyTo(DataDecompressed, SizeDecompressed);

            int SizeCompressedNew;

            byte[] DataCompressed = m_bnsDat.Inflate(DataDecompressed, SizeDecompressed, out SizeCompressedNew, 6);
            SizeCompressed = SizeCompressedNew;

            bw.Write(StartAndEndFieldId);
            bw.Write(Ultily.WriteIntTo2Bytes(SizeCompressed));
            bw.Write(DataCompressed);
            bw.Write(Ultily.WriteIntTo2Bytes(SizeDecompressed));
            bw.Write(FieldLookupCount);
            for (int i = 0; i < FieldLookupCount; i++)
            {
                bw.Write(Ultily.WriteIntTo2Bytes(DataOffsets[i]));
            }
        }