Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. [StructLayout(LayoutKind.Sequential)]
  2. public partial class ChunkIdx1 : ChunkBase
  3. {
  4. public uint EntryCount { get; set; } = 0;
  5. public uint EntryMax { get; set; } = 0;
  6. public Idx1Entry[] Entry { get; set; } = null;
  7. }
  8.  
  9. public partial class ChunkIdx1
  10. {
  11. public override ReadResult Read(Stream stream)
  12. {
  13. ReadResult result = BeginRead();
  14. if (result != ReadResult.Ok)
  15. {
  16. return result;
  17. }
  18.  
  19. _ = stream.Read<byte>(8); // skip 8 bytes, fcc and size
  20.  
  21. uint count = (uint) Math.Min(Size, Size.Even() - 8);
  22.  
  23. EntryCount = EntryMax = count;
  24.  
  25. if (count > 0)
  26. {
  27. Entry = new Idx1Entry[count];
  28.  
  29. foreach (Idx1Entry t in Entry)
  30. {
  31. t.Fcc = stream.Read<uint>();
  32. t.Flags = stream.Read<uint>();
  33. t.Position = stream.Read<uint>();
  34. t.Length = stream.Read<uint>();
  35. }
  36. }
  37. else
  38. {
  39. Entry = null;
  40. }
  41.  
  42. Debug.WriteLine($"idx1: index entry: {count}", "INFO");
  43.  
  44. return ReadResult.Ok;
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement