private static byte[] GetPermData(byte[] Data, sound_cache_file_gestalt ugh, sound_cache_file_gestalt.SoundPermutation Perm) { List <byte[]> fragments = new List <byte[]>(); int totalSize = 0; var ms = new MemoryStream(Data); var br = new BinaryReader(ms); for (int i = 0; i < Perm.ChunkCount; i++) { var chunk = ugh.RawChunks[Perm.RawChunkIndex + i]; totalSize += chunk.Size; br.BaseStream.Position = chunk.FileOffset; fragments.Add(br.ReadBytes(chunk.Size)); } byte[] newData = new byte[totalSize]; int pos = 0; for (int i = 0; i < Perm.ChunkCount; i++) { Array.Copy(fragments[i], 0, newData, pos, fragments[i].Length); pos += fragments[i].Length; } return(newData); }
private static int GetTotalSize(sound_cache_file_gestalt ugh, sound_cache_file_gestalt.Playback snd) { int total = 0; for (int i = 0; i < snd.PermutationCount; i++) { var perm = ugh.SoundPermutations[snd.FirstPermutation + i]; for (int j = 0; j < perm.ChunkCount; j++) { var chunk = ugh.RawChunks[perm.RawChunkIndex + j]; total += chunk.Size; } } return(total); }