Пример #1
0
        public void Load(Stream file, TES4RecordLoadScheme scheme)
        {
            if (this.size == 0)
            {
                return;
            }

            byte[] fileData = file.Read(this.size);
            //Decompression
            if ((this.flags & 0x00040000) == 0x00040000)
            {
                //Skip the uncompressed data size
                this.size = PHPFunction.UnpackV(fileData.Take(4).ToArray());
                fileData  = PHPFunction.GZUncompress(fileData.Skip(4).ToArray());
            }

            int i = 0;

            while (i < this.size)
            {
                string subrecordType = TES4File.ISO_8859_1.Value.GetString(fileData, i, 4);
                int    subrecordSize = PHPFunction.UnpackV(fileData.Skip(i + 4).Take(2).ToArray());
                if (scheme.ShouldLoad(subrecordType))
                {
                    byte[] subrecordData = fileData.Skip(i + 6).Take(subrecordSize).ToArray();
                    this.subrecords.Add(new KeyValuePair <string, TES4SubrecordData>(subrecordType, new TES4SubrecordData(subrecordData)));
                }

                i += (subrecordSize + 6);
            }
        }
 public void Add(TES4RecordType type, TES4RecordLoadScheme scheme)
 {
     this.records.Add(type, scheme);
 }