Fix crashing due to bug in BufferWriter.ToByteArray()

Renamed the serialisers and added CustomEvents to unit test to be more future-proof
This commit is contained in:
Sardelka9515
2023-02-03 13:37:20 +08:00
parent b4f86719ce
commit 718814c491
5 changed files with 48 additions and 30 deletions

View File

@ -27,11 +27,11 @@ namespace RageCoop.Core
m.Write(Hash);
if (Args != null)
{
lock (WriteBufferShared)
lock (SharedWriter)
{
WriteBufferShared.Reset();
CustomEvents.WriteObjects(WriteBufferShared, Args);
Payload = WriteBufferShared.ToByteArray(WriteBufferShared.Position);
SharedWriter.Reset();
CustomEvents.WriteObjects(SharedWriter, Args);
Payload = SharedWriter.ToByteArray(SharedWriter.Position);
}
}
m.Write(Payload);
@ -44,10 +44,10 @@ namespace RageCoop.Core
Payload = m.ReadBytes(m.LengthBytes - m.PositionInBytes);
fixed (byte* p = Payload)
{
lock (ReadBufferShared)
lock (SharedReader)
{
ReadBufferShared.Initialise(p,Payload.Length);
Args = CustomEvents.ReadObjects(ReadBufferShared);
SharedReader.Initialise(p, Payload.Length);
Args = CustomEvents.ReadObjects(SharedReader);
}
}
}