改了一亿个东西,修了一亿个 BUG

This commit is contained in:
2021-10-19 17:42:18 +02:00
parent 5b907309e0
commit 888ddce4ef
40 changed files with 1870 additions and 1715 deletions

37
ReplayFile/ReplayChunk.cs Normal file
View File

@@ -0,0 +1,37 @@
using System.IO;
namespace AnotherReplayReader.ReplayFile
{
internal sealed class ReplayChunk
{
private readonly byte[] _data;
public uint TimeCode { get; }
public byte Type { get; }
public ReplayChunk(uint timeCode, BinaryReader reader)
{
TimeCode = timeCode; // reader.ReadUInt32();
Type = reader.ReadByte();
var chunkSize = reader.ReadInt32();
_data = reader.ReadBytes(chunkSize);
if (reader.ReadInt32() != 0)
{
throw new InvalidDataException("Replay Chunk not ended with zero");
}
}
public BinaryReader GetReader() => new(new MemoryStream(_data, false));
public void WriteTo(BinaryWriter writer)
{
writer.Write(TimeCode);
writer.Write(Type);
writer.Write(_data.Length);
writer.Write(_data);
writer.Write(0);
}
}
}