mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-24 03:44:13 +08:00
(GetSerializedSchemeVersion): moved header reading to separate method.
This commit is contained in:
parent
653ee4685d
commit
526485c720
@ -254,15 +254,9 @@ namespace GameRes
|
||||
|
||||
public void DeserializeScheme (Stream input)
|
||||
{
|
||||
using (var reader = new BinaryReader (input, System.Text.Encoding.UTF8, true))
|
||||
{
|
||||
var header = reader.ReadChars (SchemeID.Length);
|
||||
if (!header.SequenceEqual (SchemeID))
|
||||
throw new FormatException ("Invalid serialization file");
|
||||
int version = reader.ReadInt32();
|
||||
if (version <= CurrentSchemeVersion)
|
||||
return;
|
||||
}
|
||||
int version = GetSerializedSchemeVersion (input);
|
||||
if (version <= CurrentSchemeVersion)
|
||||
return;
|
||||
using (var zs = new ZLibStream (input, CompressionMode.Decompress, true))
|
||||
{
|
||||
var bin = new BinaryFormatter();
|
||||
@ -307,6 +301,17 @@ namespace GameRes
|
||||
using (var zs = new ZLibStream (output, CompressionMode.Compress, true))
|
||||
bin.Serialize (zs, db);
|
||||
}
|
||||
|
||||
public int GetSerializedSchemeVersion (Stream input)
|
||||
{
|
||||
using (var reader = new BinaryReader (input, System.Text.Encoding.UTF8, true))
|
||||
{
|
||||
var header = reader.ReadChars (SchemeID.Length);
|
||||
if (!header.SequenceEqual (SchemeID))
|
||||
throw new FormatException ("Invalid serialization file");
|
||||
return reader.ReadInt32();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
|
Loading…
x
Reference in New Issue
Block a user