private static bool ShouldStopReadingCommands(SoundEntry sndEntry, SequenceCommand command) { if (command.Type <= 0 || command.Type >= (byte)SequenceCommandType.Count) { return(true); } //named entries typically only have 1 command if (sndEntry.NameOffset > 0) { return(true); } return(false); }
public SequenceEntry(SoundAudioBinaryFile file, BinaryReader binaryReader, SoundEntry soundEntry, long offset) { DeclarationVersion = binaryReader.ReadByteAt(offset); //1 reserved DeclarationSize = binaryReader.ReadUInt16At(offset + 0x02); DeclarationIndex = binaryReader.ReadUInt16At(offset + 0x04); Offset = file.SequenceSectionOffset + binaryReader.ReadUInt32At(file.SequenceSectionOffset + 0x10 + DeclarationIndex * 0x04); Version = binaryReader.ReadByteAt(Offset); //1 reserved //2 size? ReadCommands(file, binaryReader, soundEntry); }
private void AddMaterialUser(SequenceCommand command, SoundEntry entry) { var trackIndex = command.Body?.TrackIndex ?? null; if (trackIndex == null) { return; } if (trackIndex < 0 || trackIndex >= Tracks.Count) { return; } var track = Tracks[(int)trackIndex.Value]; if (track.HasMaterial) { MaterialSection.AddUser(entry, track.MaterialIndex); } }
protected override void ParseSections(BinaryReader reader) { SoundSectionOffset = InnerFileStartOffset + GetSectionDeclaration(Magic_Snd).OffsetInInnerFile; SequenceSectionOffset = InnerFileStartOffset + GetSectionDeclaration(Magic_Seq).OffsetInInnerFile; TrackSectionOffset = InnerFileStartOffset + GetSectionDeclaration(Magic_Trk).OffsetInInnerFile; var entryCount = reader.ReadUInt16At(SoundSectionOffset + 0x04); for (int entryIndex = 0; entryIndex < entryCount; entryIndex++) { var entry = new SoundEntry(this, reader, entryIndex); SoundEntries.Add(entry); } var trackCount = reader.ReadUInt16At(TrackSectionOffset + 0x04); for (int trackIndex = 0; trackIndex < trackCount; trackIndex++) { var track = new TrackEntry(this, reader, trackIndex); Tracks.Add(track); } AddMaterialUsers(); }
private void ReadCommands(SoundAudioBinaryFile file, BinaryReader binaryReader, SoundEntry soundEntry) { uint commandsOffsetInEntry; if (Version <= 2) { commandsOffsetInEntry = binaryReader.ReadUInt16At(Offset + 0x16); } else { commandsOffsetInEntry = binaryReader.ReadUInt16At(Offset + 0x06); } var currentCommandsOffset = Offset + commandsOffsetInEntry; while (currentCommandsOffset < file.TrackSectionOffset) { var command = new SequenceCommand(binaryReader, currentCommandsOffset); Commands.Add(command); currentCommandsOffset += (uint)(command.Size + command.BodySize); if (ShouldStopReadingCommands(soundEntry, command)) { break; } } }