From 4c90dd317cf98bb788bbbb38f0aae47657612b6e Mon Sep 17 00:00:00 2001 From: morkt Date: Sun, 23 Dec 2018 14:33:27 +0400 Subject: [PATCH] (CAF): support "RP" entries compression. also support nested compression. --- ArcFormats/Tail/ArcCAF.cs | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/ArcFormats/Tail/ArcCAF.cs b/ArcFormats/Tail/ArcCAF.cs index 8152d66c..da45e234 100644 --- a/ArcFormats/Tail/ArcCAF.cs +++ b/ArcFormats/Tail/ArcCAF.cs @@ -86,23 +86,27 @@ namespace GameRes.Formats.Tail const uint PrenSignature = 0x4E455250; // "PREN" const uint Cfp0Signature = 0x30504643; // "CFP0" const uint HpSignature = 0x00005048; // "HP" + const uint RpSignature = 0x00005052; // "RP" public override Stream OpenEntry (ArcFile arc, Entry entry) { - var input = arc.File.CreateStream (entry.Offset, entry.Size, entry.Name); + IBinaryStream input = arc.File.CreateStream (entry.Offset, entry.Size, entry.Name); Func unpacker = null; - switch (input.Signature) + for (;;) { - case PrenSignature: unpacker = UnpackPren; break; - case Cfp0Signature: unpacker = UnpackCfp0; break; - case HpSignature: unpacker = UnpackHp; break; + switch (input.Signature) + { + case RpSignature: + case PrenSignature: unpacker = UnpackPren; break; + case Cfp0Signature: unpacker = UnpackCfp0; break; + case HpSignature: unpacker = UnpackHp; break; - default: return input; - } - using (input) - { - var data = unpacker (input); - return new BinMemoryStream (data, entry.Name); + default: return input.AsStream; + } + byte[] data; + using (input) + data = unpacker (input); + input = new BinMemoryStream (data, entry.Name); } }