Пример #1
0
 public GPDSetting(BigEndianStream stream, uint id, GPDSettingType type)
 {
     _stream = stream;
     _offset = stream.Position;
     _id = id;
     _type = type;
 }
Пример #2
0
        public GPDBinarySetting(BigEndianStream stream, uint id, GPDSettingType type)
            : base(stream, id, type)
        {
            const long SkipAmount = 4;

            _size = stream.ReadInt32();
            _dataOffset = stream.Position + SkipAmount;
        }
Пример #3
0
 /// <summary>
 /// Loads an XDBF container from a file.
 /// </summary>
 /// <param name="path">The path to the file to load</param>
 public XDBF(string path)
 {
     _stream = new BigEndianStream(File.Open(path, FileMode.Open, FileAccess.ReadWrite));
     try
     {
         ProcessFile();
     }
     catch
     {
         _stream.Close();
         throw;
     }
 }
Пример #4
0
 private void ReadFromStream(BigEndianStream stream)
 {
     _namespace = stream.ReadUInt16();
     _id = stream.ReadUInt64();
     _offset = stream.ReadUInt32();
     _size = stream.ReadInt32();
 }
Пример #5
0
 public XDBFEntry(BigEndianStream stream, uint entryDataStartOffset)
 {
     ReadFromStream(stream);
     _fileOffset = entryDataStartOffset + _offset;
 }
Пример #6
0
 /// <summary>
 /// Reads an XDBF container from a Stream.
 /// </summary>
 /// <param name="stream">The Stream to read from</param>
 public XDBF(Stream stream)
 {
     _stream = new BigEndianStream(stream);
     ProcessFile();
 }
Пример #7
0
 private void ReadString(XDBFEntry entry, BigEndianStream stream)
 {
     stream.Position = entry.FileOffset;
     _strings[entry.ID] = stream.ReadUTF16();
 }
Пример #8
0
        private void ReadSetting(XDBFEntry entry, BigEndianStream stream)
        {
            const long TypeOffset = 0x8;
            const long SettingHeaderSize = 0x10;

            stream.Position = entry.FileOffset;
            uint id = stream.ReadUInt32();
            stream.Position = entry.FileOffset + TypeOffset;
            GPDSettingType type = (GPDSettingType)stream.ReadByte();
            stream.Position = entry.FileOffset + SettingHeaderSize;

            GPDSetting setting;
            switch (type)
            {
                case GPDSettingType.Binary:
                    setting = new GPDBinarySetting(stream, id, type);
                    break;

                default:
                    setting = new GPDSetting(stream, id, type);
                    break;
            }
            _settings[id] = setting;
        }
Пример #9
0
        private void ProcessEntry(XDBF container, XDBFEntry entry, BigEndianStream stream)
        {
            // Skip over sync lists
            if (entry.ID > 0xFFFFFFFF)
                return;

            switch ((GPDNamespace)entry.Namespace)
            {
                case GPDNamespace.Setting:
                    ReadSetting(entry, stream);
                    break;

                case GPDNamespace.String:
                    ReadString(entry, stream);
                    break;
            }
        }