Fixed saving bug

Yaz0Stream was the culprit (was the only thing that wasn't flushing as expected)
This commit is contained in:
Denis
2023-10-28 23:05:06 +02:00
parent e4fdaa4c69
commit 542bf405fe
4 changed files with 18 additions and 7 deletions

View File

@@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework> <TargetFramework>net7.0-windows</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms> <UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>disable</ImplicitUsings> <ImplicitUsings>disable</ImplicitUsings>

View File

@@ -69,11 +69,8 @@ namespace BMGEditor
private void InitRW() private void InitRW()
{ {
//Original code //Original code
//Reader = m_BigEndian ? new BinaryReaderBE(m_Stream, m_Encoding) : new BinaryReader(m_Stream, m_Encoding); Reader = m_BigEndian ? new BinaryReaderBE(m_Stream, m_Encoding) : new BinaryReader(m_Stream, m_Encoding);
//Writer = m_BigEndian ? new BinaryWriterBE(m_Stream, m_Encoding) : new BinaryWriter(m_Stream, m_Encoding); Writer = m_BigEndian ? new BinaryWriterBE(m_Stream, m_Encoding) : new BinaryWriter(m_Stream, m_Encoding);
Reader = Tests.isBE ? new BinaryReaderBE(m_Stream, m_Encoding) : new BinaryReader(m_Stream, m_Encoding);
Writer = Tests.isBE ? new BinaryWriterBE(m_Stream, m_Encoding) : new BinaryWriter(m_Stream, m_Encoding);
} }

View File

@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.IO; using System.IO;
using System.Drawing.Text;
namespace BMGEditor namespace BMGEditor
{ {
@@ -107,7 +108,7 @@ namespace BMGEditor
public void Flush() public void Flush()
{ {
m_File.Flush(); m_File.Stream.Flush();
} }

View File

@@ -21,6 +21,19 @@ namespace BMGEditor
Write(buffer, 0, buffer.Length); Write(buffer, 0, buffer.Length);
} }
override public void Flush()
{
m_Backend.SetLength(Length);
Position = 0x00;
m_Backend.Position = 0x00;
while (Position < Length)
{
m_Backend.WriteByte((byte)ReadByte());
}
m_Backend.Flush();
}
private Stream m_Backend; private Stream m_Backend;
} }