fix: Fixes infinite loop in BinaryFileWriter (#1792)
### Summary - Fixes infinite loop with binary file writer - Removes extra buffer copying with binary file writer - Removes storing type counts during world save file writing - Fixes display cache self-deletion warning during world load
This commit is contained in:
parent
0011db7f47
commit
9f1f314077
6 changed files with 50 additions and 25 deletions
|
|
@ -47,6 +47,32 @@ public class BinaryFileWriter : BufferWriter, IDisposable
|
|||
_file.Write(Buffer, 0, (int)Index);
|
||||
Index = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
base.Flush(); // Increase buffer size
|
||||
}
|
||||
}
|
||||
|
||||
public override void Write(byte[] bytes) => Write(bytes, 0, bytes.Length);
|
||||
|
||||
public override void Write(byte[] bytes, int offset, int count)
|
||||
{
|
||||
if (Index > 0)
|
||||
{
|
||||
Flush();
|
||||
}
|
||||
|
||||
_file.Write(bytes, offset, count);
|
||||
}
|
||||
|
||||
public override void Write(ReadOnlySpan<byte> bytes)
|
||||
{
|
||||
if (Index > 0)
|
||||
{
|
||||
Flush();
|
||||
}
|
||||
|
||||
_file.Write(bytes);
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
|
|
@ -61,7 +87,10 @@ public class BinaryFileWriter : BufferWriter, IDisposable
|
|||
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
Flush();
|
||||
if (Index > 0)
|
||||
{
|
||||
Flush();
|
||||
}
|
||||
|
||||
return _position = _file.Seek(offset, origin);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue