public void Deserialize(Stream input, Endian endian)
        {
            var baseName         = input.ReadStringZ(Encoding.ASCII);
            var basePath         = input.ReadStringZ(Encoding.ASCII);
            var internalPriority = input.ReadValueU32(endian);
            var externalCount    = input.ReadValueU32(endian);

            string internalDataPath = null;
            uint   internalCount    = 0;

            if (internalPriority != 0)
            {
                internalDataPath = input.ReadStringZ(Encoding.ASCII);
                internalCount    = input.ReadValueU32(endian);
            }

            var internalEntries = new InternalEntry[internalCount];

            for (uint i = 0; i < internalCount; i++)
            {
                internalEntries[i] = InternalEntry.Read(input, endian);
            }

            if (input.Position == input.Length)
            {
                externalCount = 0; // cheap hack for All_Levels.toc_group
            }

            var externalEntries = new ExternalEntry[externalCount];

            for (uint i = 0; i < externalCount; i++)
            {
                externalEntries[i] = ExternalEntry.Read(input, endian);
            }

            this._BaseName         = baseName;
            this._BasePath         = basePath;
            this._InternalPriority = internalPriority;
            this._InternalDataPath = internalDataPath;
            this._InternalEntries.Clear();
            this._InternalEntries.AddRange(internalEntries);
            this._ExternalEntries.Clear();
            this._ExternalEntries.AddRange(externalEntries);
        }
예제 #2
0
파일: MTD.cs 프로젝트: JKAnderson/DSFormats
        private MTD(byte[] bytes)
        {
            BinaryReaderEx br = new BinaryReaderEx(false, bytes);

            br.AssertInt32(0);
            int fileSize = br.ReadInt32();

            br.AssertInt32(0);
            br.AssertInt32(3);
            unk1 = br.ReadInt32();
            br.AssertInt32(0);
            br.AssertInt32(0x1C);
            br.AssertInt32(1);
            br.AssertInt32(2);
            unk2 = br.ReadInt32();
            br.AssertInt32(4);
            br.AssertASCII("MTD ");
            unk3 = br.ReadInt32();
            br.AssertInt32(0x3E8);
            unk4 = br.ReadInt32();
            br.AssertInt32(0);
            int dataSize = br.ReadInt32();

            br.AssertInt32(2);
            br.AssertInt32(4);
            unk5        = br.ReadInt32();
            SpxPath     = br.ReadShiftJISLengthPrefixed(0xA3);
            Description = br.ReadShiftJISLengthPrefixed(0x03);
            br.AssertInt32(1);
            br.AssertInt32(0);
            unk6 = br.ReadInt32();
            br.AssertInt32(3);
            br.AssertInt32(4);
            unk7 = br.ReadInt32();
            br.AssertInt32(0);
            unk8 = br.ReadInt32();

            Internal = new List <InternalEntry>();
            int internalEntryCount = br.ReadInt32();

            for (int i = 0; i < internalEntryCount; i++)
            {
                Internal.Add(InternalEntry.Read(br));
            }

            unk9 = br.ReadInt32();

            External = new List <ExternalEntry>();
            int externalEntryCount = br.ReadInt32();

            for (int i = 0; i < externalEntryCount; i++)
            {
                External.Add(ExternalEntry.Read(br));
            }

            unk10 = br.ReadInt32();
            br.AssertInt32(0);
            unk11 = br.ReadInt32();
            br.AssertInt32(0);
            unk12 = br.ReadInt32();
            br.AssertInt32(0);
        }
 public static void Write(Stream output, ExternalEntry instance, Endian endian)
 {
     output.WriteStringZ(instance.Name, Encoding.ASCII);
     output.WriteValueU32(instance.Size, endian);
     output.WriteStringZ(instance.Path, Encoding.ASCII);
 }