From 72452d664ac0b77a3b59e7b459b241da6a23a9fd Mon Sep 17 00:00:00 2001 From: morkt Date: Mon, 25 Feb 2019 12:57:23 +0400 Subject: [PATCH] (SCN): recongize zlib compression. --- ArcFormats/Seraphim/ArcSCN.cs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/ArcFormats/Seraphim/ArcSCN.cs b/ArcFormats/Seraphim/ArcSCN.cs index 37f62cf7..4a15f56e 100644 --- a/ArcFormats/Seraphim/ArcSCN.cs +++ b/ArcFormats/Seraphim/ArcSCN.cs @@ -80,25 +80,35 @@ namespace GameRes.Formats.Seraphim if (0 == entry.Size) return Stream.Null; uint signature = arc.File.View.ReadUInt32 (entry.Offset); - ArcViewStream input; + IBinaryStream input; if (1 == signature && 0x78 == arc.File.View.ReadByte (entry.Offset+4)) { input = arc.File.CreateStream (entry.Offset+4, entry.Size-4); - return new ZLibStream (input, CompressionMode.Decompress); + return new ZLibStream (input.AsStream, CompressionMode.Decompress); } input = arc.File.CreateStream (entry.Offset, entry.Size); if (signature < 4 || 0 != (signature & 0xFF000000)) - return input; + { + if (0x78 == (signature & 0xFF)) + { + var compr = new ZLibStream (input.AsStream, CompressionMode.Decompress); + input = new BinaryStream (compr, entry.Name); + } + else + return input.AsStream; + } try { var data = LzDecompress (input); - input.Dispose(); return new BinMemoryStream (data, entry.Name); } catch { - input.Position = 0; - return input; + return arc.File.CreateStream (entry.Offset, entry.Size); + } + finally + { + input.Dispose(); } }