From b0665d4dbf436cca4e9f1b8743df982635d08edf Mon Sep 17 00:00:00 2001 From: morkt Date: Wed, 1 Mar 2017 14:34:53 +0400 Subject: [PATCH] (ADS): workaround empty entry names. --- ArcFormats/BlackRainbow/ArcADS.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ArcFormats/BlackRainbow/ArcADS.cs b/ArcFormats/BlackRainbow/ArcADS.cs index 875687a5..8cf479ea 100644 --- a/ArcFormats/BlackRainbow/ArcADS.cs +++ b/ArcFormats/BlackRainbow/ArcADS.cs @@ -48,6 +48,11 @@ namespace GameRes.Formats.BlackRainbow public override bool IsHierarchic { get { return false; } } public override bool CanWrite { get { return false; } } + public AdsOpener () + { + Signatures = new uint[] { 0x84D9514E, 0 }; + } + public static Dictionary KnownKeys = new Dictionary(); public override ResourceScheme Scheme @@ -60,6 +65,7 @@ namespace GameRes.Formats.BlackRainbow { if (!file.Name.EndsWith (".ads", StringComparison.InvariantCultureIgnoreCase)) return null; + var arc_name = Path.GetFileNameWithoutExtension (file.Name); foreach (var key in KnownKeys.Values) { using (var arc = new EncryptedViewStream (file, key)) @@ -67,7 +73,7 @@ namespace GameRes.Formats.BlackRainbow uint signature = FormatCatalog.ReadSignature (arc); if (2 == signature || 4 == signature || 5 == signature) { - var dir = ReadIndex (arc, key); + var dir = ReadIndex (arc, key, arc_name); if (dir != null) return new AdsArchive (file, this, dir, key); } @@ -76,7 +82,7 @@ namespace GameRes.Formats.BlackRainbow return null; } - List ReadIndex (Stream arc, byte[] key) + List ReadIndex (Stream arc, byte[] key, string arc_name) { arc.Position = 8; using (var reader = new ArcView.Reader (arc)) @@ -108,7 +114,11 @@ namespace GameRes.Formats.BlackRainbow reader.BaseStream.Position = offset; reader.Read (name_buffer, 0, 0x20); string name = Binary.GetCString (name_buffer, 0, 0x20); - var entry = FormatCatalog.Instance.Create (name); + Entry entry; + if (0 == name.Length) + entry = new Entry { Name = string.Format ("{0}#{1:D5}", arc_name, i), Type = "image" }; + else + entry = FormatCatalog.Instance.Create (name); entry.Offset = offset + 0x24; entry.Size = reader.ReadUInt32(); dir.Add (entry);