改了一亿个东西,修了一亿个 BUG
This commit is contained in:
37
ReplayFile/ReplayChunk.cs
Normal file
37
ReplayFile/ReplayChunk.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user