/// <summary> /// Deserializes file data from a stream. /// </summary> protected override void Read(BinaryReaderEx br) { br.BigEndian = false; br.AssertASCII("MSB "); br.AssertInt32(1); br.AssertInt32(0x10); br.AssertBoolean(false); // isBigEndian br.AssertBoolean(false); // isBitBigEndian br.AssertByte(1); // textEncoding br.AssertByte(0xFF); // is64BitOffset Entries entries = default; Models = new ModelParam(); entries.Models = Models.Read(br); Events = new EventParam(); entries.Events = Events.Read(br); Regions = new PointParam(); entries.Regions = Regions.Read(br); Routes = new RouteParam(); entries.Routes = Routes.Read(br); Layers = new LayerParam(); entries.Layers = Layers.Read(br); Parts = new PartsParam(); entries.Parts = Parts.Read(br); PartsPoses = new MapstudioPartsPose(); entries.PartsPoses = PartsPoses.Read(br); BoneNames = new MapstudioBoneName(); entries.BoneNames = BoneNames.Read(br); if (br.Position != 0) { throw new InvalidDataException("The next param offset of the final param should be 0, but it wasn't."); } MSB.DisambiguateNames(entries.Models); MSB.DisambiguateNames(entries.Parts); MSB.DisambiguateNames(entries.Regions); foreach (Event evt in entries.Events) { evt.GetNames(this, entries); } foreach (Region region in entries.Regions) { region.GetNames(this, entries); } foreach (Part part in entries.Parts) { part.GetNames(this, entries); } foreach (PartsPose pose in entries.PartsPoses) { pose.GetNames(this, entries); } }
internal static void AssertHeader(BinaryReaderEx br) { br.AssertASCII("MSB "); br.AssertInt32(1); br.AssertInt32(0x10); br.AssertBoolean(false); // isBigEndian br.AssertBoolean(false); // isBitBigEndian br.AssertByte(1); // textEncoding br.AssertByte(0xFF); // is64BitOffset }
/// <summary> /// Deserializes file data from a stream. /// </summary> protected override void Read(BinaryReaderEx br) { br.BigEndian = false; br.AssertASCII("MSB "); br.AssertInt32(1); br.AssertInt32(0x10); br.AssertBoolean(false); // isBigEndian br.AssertBoolean(false); // isBitBigEndian br.AssertByte(1); // textEncoding br.AssertByte(0xFF); // is64BitOffset Entries entries; Models = new ModelParam(); entries.Models = Models.Read(br); Events = new EventParam(); entries.Events = Events.Read(br); Regions = new PointParam(); entries.Regions = Regions.Read(br); Routes = new RouteParam(); entries.Routes = Routes.Read(br); Layers = new EmptyParam(0x23, "LAYER_PARAM_ST"); Layers.Read(br); Parts = new PartsParam(); entries.Parts = Parts.Read(br); PartsPoses = new EmptyParam(0, "MAPSTUDIO_PARTS_POSE_ST"); PartsPoses.Read(br); BoneNames = new EmptyParam(0, "MAPSTUDIO_BONE_NAME_STRING"); BoneNames.Read(br); if (br.Position != 0) { throw new InvalidDataException("The next param offset of the final param should be 0, but it wasn't."); } MSB.DisambiguateNames(entries.Models); MSB.DisambiguateNames(entries.Regions); MSB.DisambiguateNames(entries.Parts); foreach (Event evt in entries.Events) { evt.GetNames(this, entries); } foreach (Region region in entries.Regions) { region.GetNames(entries); } foreach (Part part in entries.Parts) { part.GetNames(this, entries); } }
internal static List <BinderFileHeader> ReadHeader(IBND3 bnd, BinaryReaderEx br) { br.AssertASCII("BND3"); bnd.Version = br.ReadFixStr(8); bnd.BitBigEndian = br.GetBoolean(0xE); bnd.Format = Binder.ReadFormat(br, bnd.BitBigEndian); bnd.BigEndian = br.ReadBoolean(); br.AssertBoolean(bnd.BitBigEndian); br.AssertByte(0); br.BigEndian = bnd.BigEndian || Binder.ForceBigEndian(bnd.Format); int fileCount = br.ReadInt32(); br.ReadInt32(); // End of file headers, not including padding before data bnd.Unk18 = br.AssertInt32(0, unchecked ((int)0x80000000)); br.AssertInt32(0); var fileHeaders = new List <BinderFileHeader>(fileCount); for (int i = 0; i < fileCount; i++) { fileHeaders.Add(BinderFileHeader.ReadBinder3FileHeader(br, bnd.Format, bnd.BitBigEndian)); } return(fileHeaders); }
internal static List <BinderFileHeader> ReadBHFHeader(IBXF3 bxf, BinaryReaderEx br) { br.AssertASCII("BHF3"); bxf.Version = br.ReadFixStr(8); bxf.BitBigEndian = br.GetBoolean(0xE); bxf.Format = Binder.ReadFormat(br, bxf.BitBigEndian); bxf.BigEndian = br.ReadBoolean(); br.AssertBoolean(bxf.BitBigEndian); br.AssertByte(0); br.BigEndian = bxf.BigEndian || Binder.ForceBigEndian(bxf.Format); int fileCount = br.ReadInt32(); br.AssertInt32(0); br.AssertInt32(0); br.AssertInt32(0); var fileHeaders = new List <BinderFileHeader>(fileCount); for (int i = 0; i < fileCount; i++) { fileHeaders.Add(BinderFileHeader.ReadBinder3FileHeader(br, bxf.Format, bxf.BitBigEndian)); } return(fileHeaders); }
internal override void Read(BinaryReaderEx br) { br.BigEndian = false; br.AssertASCII("MSB "); br.AssertInt32(1); br.AssertInt32(0x10); br.AssertBoolean(false); // isBigEndian br.AssertBoolean(false); // isBitBigEndian br.AssertByte(1); // textEncoding br.AssertSByte(-1); // is64BitOffset Entries entries; Models = new ModelParam(); entries.Models = Models.Read(br); Events = new EventParam(); entries.Events = Events.Read(br); Regions = new PointParam(); entries.Regions = Regions.Read(br); new RouteParam().Read(br); new LayerParam().Read(br); Parts = new PartsParam(); entries.Parts = Parts.Read(br); PartPoses = new MapstudioPartsPose().Read(br); entries.BoneNames = new MapstudioBoneName().Read(br); if (br.Position != 0) { throw new InvalidDataException($"The next param offset of the final param should be 0, but it was 0x{br.Position:X}."); } DisambiguateNames(entries.Models); DisambiguateNames(entries.Parts); DisambiguateNames(entries.BoneNames); foreach (Part part in entries.Parts) { part.GetNames(this, entries); } foreach (PartPose pose in PartPoses) { pose.GetNames(entries); } }
/// <summary> /// Deserializes file data from a stream. /// </summary> protected override void Read(BinaryReaderEx br) { bool bigEndian = br.BigEndian = br.GetBoolean(0x10); int unk00 = br.AssertInt32(2, 3); int unk04 = br.AssertInt32(0, 1); int groupCount = br.ReadInt32(); int dataLength = br.ReadInt32(); br.AssertBoolean(bigEndian); br.AssertPattern(3, 0x00); int groupSize = br.AssertInt32(0x40, 0x48, 0x98); int probeSize = br.AssertInt32(0x1C, 0x48); Unk1C = br.ReadVector3(); Unk28 = br.ReadVector3(); br.AssertInt64(0); if (!bigEndian && unk00 == 2 && unk04 == 1 && groupSize == 0x40 && probeSize == 0x1C) { Version = BTPBVersion.DarkSouls2LE; } else if (bigEndian && unk00 == 2 && unk04 == 1 && groupSize == 0x40 && probeSize == 0x1C) { Version = BTPBVersion.DarkSouls2BE; } else if (!bigEndian && unk00 == 2 && unk04 == 1 && groupSize == 0x48 && probeSize == 0x48) { Version = BTPBVersion.Bloodborne; } else if (!bigEndian && unk00 == 3 && unk04 == 0 && groupSize == 0x98 && probeSize == 0x48) { Version = BTPBVersion.DarkSouls3; } else { throw new InvalidDataException($"Unknown BTPB format. {nameof(bigEndian)}:{bigEndian} {nameof(unk00)}:0x{unk00:X}" + $" {nameof(unk04)}:0x{unk04:X} {nameof(groupSize)}:0x{groupSize:X} {nameof(probeSize)}:0x{probeSize:X}"); } br.VarintLong = Version >= BTPBVersion.Bloodborne; long dataStart = br.Position; br.Skip(dataLength); Groups = new List <Group>(groupCount); for (int i = 0; i < groupCount; i++) { Groups.Add(new Group(br, Version, dataStart)); } }
internal void AssertValue(BinaryReaderEx br) { switch (Type) { case ParamType.aob: var assertAob = (byte[])ValueToAssert; for (int i = 0; i < AobLength; i++) { br.AssertByte(assertAob[i]); } break; case ParamType.b: br.AssertBoolean((bool)ValueToAssert); break; case ParamType.u8: case ParamType.x8: br.AssertByte((byte)ValueToAssert); break; case ParamType.s8: br.AssertSByte((sbyte)ValueToAssert); break; case ParamType.u16: case ParamType.x16: br.AssertUInt16((ushort)ValueToAssert); break; case ParamType.s16: br.AssertInt16((short)ValueToAssert); break; case ParamType.u32: case ParamType.x32: br.AssertUInt32((uint)ValueToAssert); break; case ParamType.s32: br.AssertInt32((int)ValueToAssert); break; case ParamType.u64: case ParamType.x64: br.AssertUInt64((ulong)ValueToAssert); break; case ParamType.s64: br.AssertInt64((long)ValueToAssert); break; case ParamType.f32: br.AssertSingle((float)ValueToAssert); break; case ParamType.f64: br.AssertDouble((double)ValueToAssert); break; default: throw new Exception($"Invalid ParamTemplate ParamType: {Type.ToString()}"); } }