From a547f0282b5225c000197b5fb3881e7bcb08a2f1 Mon Sep 17 00:00:00 2001 From: Crsky Date: Sun, 11 Sep 2022 04:54:01 +0800 Subject: [PATCH] Guess entry type by signature. --- ArcFormats/KiriKiri/CryptAlgorithms.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ArcFormats/KiriKiri/CryptAlgorithms.cs b/ArcFormats/KiriKiri/CryptAlgorithms.cs index a94e8262..139756bd 100644 --- a/ArcFormats/KiriKiri/CryptAlgorithms.cs +++ b/ArcFormats/KiriKiri/CryptAlgorithms.cs @@ -103,6 +103,7 @@ namespace GameRes.Formats.KiriKiri var header = new byte[5]; input.Read (header, 0, 5); uint signature = header.ToUInt32 (0); + GuessEntryTypeBySignature (entry, signature); if (0x184D2204 == signature) // LZ4 magic { // assume no scripts are compressed using LZ4, return decompressed stream right away @@ -197,6 +198,25 @@ namespace GameRes.Formats.KiriKiri return output; } } + + static readonly Dictionary FileTypesMap = new Dictionary + { + { 0x5367674f, "audio" }, // OGG + { 0x46464952, "audio" }, // WAV + { 0x474e5089, "image" }, // PNG + { 0xe0ffd8ff, "image" }, // JPG + { 0x30474c54, "image" }, // TLG + { 0x35474c54, "image" }, // TLG + { 0x36474c54, "image" }, // TLG + { 0x35474cab, "image" }, // TLG + { 0x584d4b4a, "image" }, // TLG + }; + + internal void GuessEntryTypeBySignature(Entry entry, uint signature) + { + if (FileTypesMap.TryGetValue (signature, out var type)) + entry.Type = type; + } } [Serializable]