diff --git a/ArcFormats/NonColor/ArcACV.cs b/ArcFormats/NonColor/ArcACV.cs index c7440c90..c724300a 100644 --- a/ArcFormats/NonColor/ArcACV.cs +++ b/ArcFormats/NonColor/ArcACV.cs @@ -53,13 +53,7 @@ namespace GameRes.Formats.NonColor return null; using (var index = new NcIndexReader (file, count, key) { IndexPosition = 8 }) - { - var file_map = ReadFilenameMap (scheme); - var dir = index.Read (file_map); - if (null == dir) - return null; - return new ArcDatArchive (file, this, dir, scheme.Hash); - } + return index.Read (this, scheme); } } } diff --git a/ArcFormats/NonColor/ArcDAT.cs b/ArcFormats/NonColor/ArcDAT.cs index 56d5c295..f0c91006 100644 --- a/ArcFormats/NonColor/ArcDAT.cs +++ b/ArcFormats/NonColor/ArcDAT.cs @@ -59,6 +59,7 @@ namespace GameRes.Formats.NonColor public ulong Hash; public string FileListName; public bool LowCaseNames; + public bool IgnoreScriptKey; public Scheme(string title) { @@ -129,13 +130,7 @@ namespace GameRes.Formats.NonColor return null; using (var index = new NcIndexReader (file, count)) - { - var file_map = ReadFilenameMap (scheme); - var dir = index.Read (file_map); - if (null == dir) - return null; - return new ArcDatArchive (file, this, dir, scheme.Hash); - } + return index.Read (this, scheme); } public override Stream OpenEntry (ArcFile arc, Entry entry) @@ -147,10 +142,10 @@ namespace GameRes.Formats.NonColor var data = arc.File.View.ReadBytes (entry.Offset, entry.Size); if (dent.IsPacked) { - if (6 == dent.Flags) - DecryptData (data, (uint)dent.Hash); - else if (darc.MasterKey != 0) + if (darc.MasterKey != 0) DecryptData (data, (uint)(dent.Hash ^ darc.MasterKey)); + else if (6 == dent.Flags) + DecryptData (data, (uint)dent.Hash); return new ZLibStream (new MemoryStream (data), CompressionMode.Decompress); } // 1 == dent.Flags @@ -284,10 +279,10 @@ namespace GameRes.Formats.NonColor protected IBinaryStream m_input; private List m_dir; private int m_count; - private long m_max_offset; + private ArcView m_file; public long IndexPosition { get; set; } - public long MaxOffset { get { return m_max_offset; } } + public long MaxOffset { get { return m_file.MaxOffset; } } public bool ExtendByteSign { get; protected set; } protected NcIndexReaderBase (ArcView file, int count) @@ -295,10 +290,20 @@ namespace GameRes.Formats.NonColor m_input = file.CreateStream(); m_dir = new List (count); m_count = count; - m_max_offset = file.MaxOffset; + m_file = file; IndexPosition = 4; } + public ArcFile Read (DatOpener format, Scheme scheme) + { + var file_map = format.ReadFilenameMap (scheme); + var dir = Read (file_map); + if (null == dir) + return null; + var master_key = scheme.IgnoreScriptKey ? 0ul : scheme.Hash; + return new ArcDatArchive (m_file, format, dir, master_key); + } + public List Read (IDictionary file_map) { int skipped = 0, last_reported = -1; diff --git a/ArcFormats/NonColor/ArcMinato.cs b/ArcFormats/NonColor/ArcMinato.cs index e02bd34f..845ff74e 100644 --- a/ArcFormats/NonColor/ArcMinato.cs +++ b/ArcFormats/NonColor/ArcMinato.cs @@ -70,13 +70,7 @@ namespace GameRes.Formats.Minato return null; using (var index = new MinatoIndexReader (file, count)) - { - var file_map = ReadFilenameMap (scheme); - var dir = index.Read (file_map); - if (null == dir) - return null; - return new ArcDatArchive (file, this, dir, scheme.Hash); - } + return index.Read (this, scheme); } }