Beispiel #1
0
        /*
         *      public void AddStruct(char structType, IntPtr data, int len, IntPtr oldPtr, int code)
         *      {
         *              btBulletFile_addStruct(_native, structType._native, data, len, oldPtr, code);
         *      }
         */
        public override void Parse(FileVerboseMode verboseMode)
        {
            byte[] dna = (IntPtr.Size == 8) ? Serializer.GetBulletDna64() : Serializer.GetBulletDna();

            _dnaCopy = new byte[dna.Length];
            Buffer.BlockCopy(dna, 0, _dnaCopy, 0, _dnaCopy.Length);

            ParseInternal(verboseMode, _dnaCopy);

            //the parsing will convert to cpu endian
            _flags &= ~FileFlags.EndianSwap;

            _fileBuffer[8] = BitConverter.IsLittleEndian ? (byte)'v' : (byte)'V';
        }
Beispiel #2
0
        private void LoadDna(FileVerboseMode verboseMode)
        {
            bool swap = (Flags & FileFlags.EndianSwap) != 0;

            using (var stream = new MemoryStream(_fileBuffer, false))
            {
                using (var reader = new BulletReader(stream))
                {
                    long dnaStart = FindDnaChunk(reader);
                    OK = dnaStart != -1;
                    if (!OK)
                    {
                        return;
                    }

                    stream.Position = dnaStart;
                    _fileDna        = Dna.Load(reader, swap);
                }
            }

            if (_fileDna.IsBroken(_version))
            {
                Console.WriteLine("Warning: broken DNA version");
                Flags |= FileFlags.BrokenDna;
            }

            //if ((verboseMode & FileVerboseMode.DumpDnaTypeDefinitions) != 0)
            //    _fileDna.DumpTypeDefinitions();

            byte[] memoryDnaData = IntPtr.Size == 8
                ? Serializer.GetBulletDna64()
                : Serializer.GetBulletDna();
            _memoryDna = Dna.Load(memoryDnaData, !BitConverter.IsLittleEndian);

            _structChanged = _fileDna.Compare(_memoryDna);
        }