Beispiel #1
0
 public void Read(CustomBinaryReader reader)
 {
     Size           = reader.ReadUInt32();
     _startPosition = reader.Position;
     ID             = reader.ReadUInt32();
     ReadData(reader);
 }
Beispiel #2
0
 public void Read(CustomBinaryReader reader)
 {
     gameParameterID = reader.ReadUInt32();
     yType           = reader.ReadUInt32();
     unknownID       = reader.ReadUInt32();
     //_unknown = reader.ReadByte();
     numPoints = reader.ReadByte();
     _unknown2 = reader.ReadByte();
     points    = reader.ReadMany((r) => new Point(r), (ulong)numPoints);
 }
Beispiel #3
0
 // TODO: Populate Offset
 public virtual void Read(CustomBinaryReader reader, bool readData = true)
 {
     Size           = reader.ReadUInt32();
     _startPosition = reader.Position;
     ID             = reader.ReadUInt32();
     if (readData)
     {
         ReadData(reader);
     }
 }
Beispiel #4
0
 public override void Read(CustomBinaryReader reader, bool readData = true)
 {
     base.Read(reader, false);
     _unknown  = reader.ReadUInt32();
     State     = reader.ReadUInt32();
     IDAudio   = reader.ReadUInt32();
     IDSource  = reader.ReadUInt32();
     SoundType = reader.ReadByte();
     if (readData)
     {
         ReadData(reader);
     }
 }
Beispiel #5
0
 public void Read(CustomBinaryReader reader)
 {
     id = reader.ReadUInt32();
     changeOccursWhen = reader.ReadByte();
     numberOfStates   = reader.ReadUInt16();
     states           = reader.ReadMany((r) => new CustomSettingsState(r), numberOfStates);
 }
Beispiel #6
0
        public StringTableReader(Stream stream)
        {
            reader = new CustomBinaryReader(stream);

            uint count    = reader.ReadUInt32();
            uint dataSize = reader.ReadUInt32();

            long dataPosition = 8 + count * 8;

            for (int i = 0; i < count; i++)
            {
                uint index  = reader.ReadUInt32();
                uint offset = reader.ReadUInt32();
                table.Add(index, dataPosition + offset);
            }
        }
Beispiel #7
0
        public void Read(CustomBinaryReader reader)
        {
            header     = reader.ReadBytes(4);
            headerName = Encoding.UTF8.GetString(header);
            size       = reader.ReadUInt32();
            long _startPosition = reader.Position;

            count   = reader.ReadInt32();
            objects = new List <HIRCObject>();
            long offset = reader.Position;

            for (int i = 0; i < count; i++)
            {
                byte       objType = reader.ReadByte();
                HIRCObject tmp;
                switch (objType)
                {
                case HIRCObject.TYPE_SOUNDSFXVOICE:
                    tmp = new SFXHIRCObject(reader, objType);
                    break;

                case HIRCObject.TYPE_EVENT:
                    tmp = new EventHIRCObject(reader, objType);
                    break;

                case HIRCObject.TYPE_MUSICSEGMENT:
                    tmp = new MusicSegmentHIRCObject(reader, objType);
                    break;

                case HIRCObject.TYPE_MUSICTRACK:
                    tmp = new MusicTrackHIRCObject(reader, objType);
                    break;

                case HIRCObject.TYPE_MUSICSWITCHCONTAINER:
                    tmp = new MusicSwitchContainerHIRCObject(reader, objType);
                    //tmp = new HIRCObject(reader, objType);
                    //File.WriteAllBytes("tempSwitchContainer.dat", tmp.Data);
                    break;

                default:
                    tmp = new HIRCObject(reader, objType);
                    break;
                }
                tmp.Offset = offset.ToString("X");
                offset     = reader.Position;
                objects.Add(tmp);
            }
            // Double check!
            if (size - (reader.Position - _startPosition) != 0)
            {
                Console.WriteLine("Incorrect IO!");
            }
        }
 public override void Read(CustomBinaryReader reader, bool readData = true)
 {
     base.Read(reader, false);
     // I'm hoping this is ALWAYS 10
     _startByte = reader.ReadByte();
     type_state = reader.ReadByte();
     _unknown1  = reader.ReadBytes(8);
     // Followed by ID
     ID1 = reader.ReadUInt32();
     if (type_state == 1)
     {
         _unknown2 = reader.ReadBytes(13);
     }
     else
     {
         _unknown2 = reader.ReadBytes(10);
     }
     ID2 = reader.ReadUInt32();
     if (readData)
     {
         ReadData(reader);
     }
 }
Beispiel #9
0
 public void Read(CustomBinaryReader reader)
 {
     //overrideParentEffects = reader.ReadBoolean();
     //effectCount = reader.ReadByte();
     //if (effectCount > 0)
     //{
     //    bitmaskEffect = reader.ReadByte();
     //    effects = reader.ReadMany((r) => new EffectStructure(r), (ulong)effectCount);
     //}
     //outputBusID = reader.ReadUInt32();
     //parentID = reader.ReadUInt32();
     //overrideParentPlayback = reader.ReadBoolean();
     //offsetPrioritySetting = reader.ReadBoolean();
     //additionalParametersCount = reader.ReadByte();
     //additionalParameters = reader.ReadMany((r) => r.ReadByte(), (ulong)additionalParametersCount);
     //additionalParameterValues = reader.ReadMany((r) => r.ReadBytes(4), (ulong)additionalParametersCount);
     //_zero = reader.ReadByte();
     //positioningSection = reader.ReadBoolean();
     //if (positioningSection)
     //{
     //    positioningType = reader.ReadByte();
     //    if (positioningType == 0)
     //    {
     //        enablePanner = reader.ReadBoolean();
     //    } else if (positioningType == 1)
     //    {
     //        positionSource = reader.ReadUInt32();
     //        attenuationID = reader.ReadUInt32();
     //        enableSpatialization = reader.ReadBoolean();
     //    } else if (positioningType == 2)
     //    {
     //        playType = reader.ReadUInt32();
     //        loop = reader.ReadBoolean();
     //        transitionTime = reader.ReadUInt32();
     //        listenerOrientation = reader.ReadBoolean();
     //    } else if (positioningType == 3)
     //    {
     //        update = reader.ReadBoolean();
     //    } else
     //    {
     //        // ERROR!
     //        throw new ParseException($"Could not parse positioningType from {nameof(SoundStructure)}! Value: {positioningType} is not between 0 - 3, at reader offset: 0x{reader.Position:X}");
     //    }
     //}
     //overrideParentAuxiliary = reader.ReadBoolean();
     //gameDefinedAuxiliary = reader.ReadBoolean();
     //overrideParentUserAuxiliary = reader.ReadBoolean();
     //userAuxiliaryExists = reader.ReadBoolean();
     //if (userAuxiliaryExists)
     //{
     //    busID0 = reader.ReadUInt32();
     //    busID1 = reader.ReadUInt32();
     //    busID2 = reader.ReadUInt32();
     //    busID3 = reader.ReadUInt32();
     //}
     //playbackLimit = reader.ReadBoolean();
     //if (playbackLimit)
     //{
     //    priorityEqualApproach = reader.ReadByte();
     //    limitReachedApproach = reader.ReadByte();
     //    limitSoundsTo = reader.ReadUInt16();
     //}
     //limitSoundInstances = reader.ReadByte();
     //virtualVoiceBehavior = reader.ReadByte();
     //overrideParentPlaybackLimit = reader.ReadBoolean();
     //overrideVirtualVoice = reader.ReadBoolean();
     unknown4_0       = reader.ReadUInt32();
     unknown_id       = reader.ReadUInt32();
     _unknown4_0      = reader.ReadBytes(4);
     unknown1_0       = reader.ReadByte();
     unknown1_1       = reader.ReadByte();
     unknown1_2       = reader.ReadByte();
     someFloat        = reader.ReadSingle();
     twoFlags         = reader.ReadUInt32();
     id               = reader.ReadUInt32();
     _unknown12_0     = reader.ReadBytes(12);
     booleanData      = reader.ReadUInt32();
     stateGroupsCount = reader.ReadUInt32();
     stateGroups      = reader.ReadMany((r) => new StateGroup(r), (ulong)stateGroupsCount);
     rtpcCount        = reader.ReadUInt16();
     rtpcs            = reader.ReadMany((r) => new RTPC(r), (ulong)rtpcCount);
 }
Beispiel #10
0
        protected override void DoOpen()
        {
            using (CustomBinaryReader reader = new CustomBinaryReader(new FileStream(ArchivePath, FileMode.Open, FileAccess.Read)))
            {
                uint signature = reader.ReadUInt32();
                if (signature != 0x415342)
                {
                    throw new InvalidDataException("File is not BSA");
                }

                uint version      = reader.ReadUInt32();
                uint folderOffset = reader.ReadUInt32();
                flags = (ArchiveFlags)reader.ReadUInt32();
                uint folderCount           = reader.ReadUInt32();
                uint fileCount             = reader.ReadUInt32();
                uint totalFolderNameLength = reader.ReadUInt32();
                uint totalFileNameLength   = reader.ReadUInt32();
                uint fileExtensions        = reader.ReadUInt32();

                FolderInfo[] folders = new FolderInfo[(int)folderCount];

                // Read folders
                reader.BaseStream.Position = folderOffset;
                for (int i = 0; i < folderCount; i++)
                {
                    ulong hash    = reader.ReadUInt64();
                    uint  count   = reader.ReadUInt32();
                    uint  unknown = reader.ReadUInt32();
                    ulong offset  = reader.ReadUInt64() - totalFileNameLength;
                    folders[i] = new FolderInfo()
                    {
                        FileCount     = count,
                        ContentOffset = offset
                    };
                }

                // Read folder content (name and files)
                foreach (var folder in folders)
                {
                    byte folderNameLength = reader.ReadByte();
                    folder.Path = Encoding.UTF8.GetString(reader.ReadBytes(folderNameLength - 1));
                    byte zero = reader.ReadByte();

                    folder.Files = new FileInfo[folder.FileCount];
                    for (ulong i = 0; i < folder.FileCount; i++)
                    {
                        ulong hash = reader.ReadUInt64();
                        uint  size = reader.ReadUInt32();

                        bool compressed = flags.HasFlag(ArchiveFlags.DefaultCompressed);
                        if ((size & 0xf0000000) != 0)
                        {
                            size      &= 0xfffffff;
                            compressed = !compressed;
                        }

                        uint offset = reader.ReadUInt32();
                        folder.Files[i] = new FileInfo()
                        {
                            Size         = size,
                            DataOffset   = offset,
                            IsCompressed = compressed
                        };
                    }
                }

                long   total    = fileCount;
                long   loaded   = 0;
                string filename = Path.GetFileName(ArchivePath);

                // Read file names
                foreach (var folder in folders)
                {
                    foreach (var file in folder.Files)
                    {
                        file.Filename = reader.ReadStringZeroTerminated();
                        loaded++;
                    }
                }

                // Convert to nested sorted dictionary for fast search
                for (int i = 0; i < folderCount; i++)
                {
                    var files = new SortedDictionary <string, FileInfo>();
                    for (ulong j = 0; j < folders[i].FileCount; j++)
                    {
                        files.Add(folders[i].Files[j].Filename, folders[i].Files[j]);
                    }
                    sorted.Add(folders[i].Path, files);
                }

                return;
            }
        }
Beispiel #11
0
 public void Read(CustomBinaryReader reader)
 {
     x          = reader.ReadSingle();
     y          = reader.ReadSingle();
     curveShape = reader.ReadUInt32();
 }
        protected override void DoOpen()
        {
            using (CustomBinaryReader reader = new CustomBinaryReader(new FileStream(ArchivePath, FileMode.Open, FileAccess.Read)))
            {
                uint signature = reader.ReadUInt32();
                if (signature != 0x58445442)
                {
                    throw new InvalidDataException("File is not BA2");
                }

                version = reader.ReadUInt32();
                if (version > 1)
                {
                    throw new InvalidDataException("Unsupported archive file version: " + version);
                }

                type = (ArchiveType)reader.ReadUInt32();
                if (type != ArchiveType.General)
                {
                    Log.Fine("Skipping archive file which is not the general purpose type.");
                    return;
                }

                long baseOffset          = reader.BaseStream.Position;
                uint fileCount           = reader.ReadUInt32();
                long fileNameTableOffset = reader.ReadInt64();

                FileInfo[] files = new FileInfo[fileCount];
                for (int i = 0; i < fileCount; i++)
                {
                    files[i] = new FileInfo()
                    {
                        NameHash             = reader.ReadUInt32(),
                        Type                 = reader.ReadUInt32(),
                        DirectoryNameHash    = reader.ReadUInt32(),
                        Unknown1             = reader.ReadUInt32(),
                        DataOffset           = reader.ReadInt64(),
                        DataCompressedSize   = reader.ReadUInt32(),
                        DataUncompressedSize = reader.ReadUInt32(),
                        Unknown2             = reader.ReadUInt32()
                    };
                }

                reader.BaseStream.Position = fileNameTableOffset;
                for (int i = 0; i < fileCount; i++)
                {
                    ushort length = reader.ReadUInt16();
                    string path   = reader.ReadStringFixedLength(length).ToLower();

                    string dir      = Path.GetDirectoryName(path).ToLower();
                    string filename = Path.GetFileName(path).ToLower();
                    if (!sorted.ContainsKey(dir))
                    {
                        sorted.Add(dir, new SortedDictionary <string, FileInfo>());
                    }
                    sorted[dir].Add(filename, files[i]);
                }
            }
        }
Beispiel #13
0
 public void Read(CustomBinaryReader reader)
 {
     index    = reader.ReadByte();
     id       = reader.ReadUInt32();
     _unknown = reader.ReadBytes(2);
 }