Exemple #1
0
        public override audDataBase[] ReadDataItems(RageDataFileReadReference file, int itemCount)
        {
            var items = new audDataBase[itemCount];

            for (int i = 0; i < itemCount; i++)
            {
                var hashKey = file.ReadUInt32();

                var offset = file.ReadInt32();

                var length = file.ReadInt32();

                byte[] data = new byte[length];

                Array.Copy(DataSection, offset, data, 0, length);

                items[i] = CreateDerivedDataType(data[0], hashKey);

                items[i].FileOffset = offset;

                items[i].Length = length;

                items[i].Deserialize(data);
            }
            return(items);
        }
Exemple #2
0
        private string[] ReadStringSection(RageDataFileReadReference file, int dataSize, int stringCount)
        {
            var stringDataEnd = file.BaseStream.Position + dataSize;

            var indicesSize = 4 * stringCount; // size of string indices section

            long basePos = file.BaseStream.Position + indicesSize;

            string[] result = new string[stringCount];

            for (int i = 0; i < stringCount; i++) // read string table
            {
                var strOffset = file.ReadInt32();

                long currentPos = file.BaseStream.Position;

                file.BaseStream.Seek(basePos + strOffset, SeekOrigin.Begin);

                result[i] = file.ReadAnsi();

                if (!Nametable.ContainsValue(result[i]))
                {
                    Nametable.Add(result[i].HashKey(), result[i]);
                }

                file.BaseStream.Seek(currentPos, SeekOrigin.Begin);
            }

            file.BaseStream.Seek(stringDataEnd, SeekOrigin.Begin);

            return(result);
        }
Exemple #3
0
        public override audDataBase[] ReadDataItems(RageDataFileReadReference file, int itemCount)
        {
            NametableLength = file.ReadInt32();

            var items = new audDataBase[itemCount];

            for (int i = 0; i < itemCount; i++)
            {
                var variableName = file.ReadString();

                var offset = file.ReadInt32();

                var length = file.ReadInt32();

                int dataType = DataSection[offset];

                byte[] data = new byte[length]; // read item data

                Buffer.BlockCopy(DataSection, offset, data, 0, length);

                switch (dataType)
                {
                    case 0:
                        items[i] = new audInteger(this, variableName);
                        break;
                    case 1:
                        items[i] = new audUInt(this, variableName);
                        break;
                    case 2:
                        items[i] = new audFloat(this, variableName);
                        break;
                    case 3:
                        items[i] = new audString(this, variableName);
                        break;
                    case 5:
                        items[i] = new audVector(this, variableName);
                        break;
                    case 7:
                        items[i] = new audVariableList(this, variableName);
                        break;
                    case 10:
                        items[i] = new audFloatArray(this, variableName);
                        break;
                    default:
                        items[i] = new audByteArray(this, variableName);
                        break;
                }

                items[i].FileOffset = offset;

                items[i].Length = length;

                items[i].Deserialize(data);
            }

            return items;
        }
Exemple #4
0
        public virtual void Read(RageDataFileReadReference file)
        {
            file.FileObject = this;

            Type = (RageAudioMetadataFileType)file.ReadInt32();

            if (!Enum.IsDefined(typeof(RageAudioMetadataFileType), Type))
            {
                throw new FileFormatException("[RageAudioMetadata] Invalid file type: " + Type);
            }

            string nametablePath = Path.ChangeExtension(file.Path, ".nametable");

            NametablePresent = File.Exists(nametablePath);

            if (NametablePresent)
            {
                ReadNametableItems(nametablePath);
            }

            var toRead = file.ReadInt32(); //0x4-0x8

            DataSection = file.ReadBytes(toRead);

            UnkDataSectionValue = BitConverter.ToInt32(DataSection, 0); // what the hell is this? timestamp maybe?

            StringSectionSize = file.ReadInt32() - 4;                   // size of entire string table section indexes + strings

            var tableSize = file.ReadInt32();                           // strings in string table

            StringTable = ReadStringSection(file, StringSectionSize, tableSize);

            var itemCount = file.ReadInt32();

            DataItems = ReadDataItems(file, itemCount);

            //  itemCount = file.ReadInt32();

            //  WaveTracks = ReadWaveTracks(file, itemCount);
        }
Exemple #5
0
        public virtual audHash[] ReadWaveTracks(RageDataFileReadReference file, int itemCount)
        {
            var items = new audHash[itemCount];

            byte[] buffer = new byte[0x4];

            for (int i = 0; i < itemCount; i++)
            {
                var offset = file.ReadInt32();

                offset -= 8;

                Buffer.BlockCopy(DataSection, offset, buffer, 0, 4);

                items[i] = new audHash(this);
                items[i].Deserialize(buffer);
                items[i].FileOffset = offset;
                items[i].Length     = 4;
            }

            return(items);
        }
Exemple #6
0
 public abstract audDataBase[] ReadDataItems(RageDataFileReadReference file, int numItems);