diff --git a/ArcFormats/Entis/ArcNOA.cs b/ArcFormats/Entis/ArcNOA.cs index 4391a938..5ac1c5fc 100644 --- a/ArcFormats/Entis/ArcNOA.cs +++ b/ArcFormats/Entis/ArcNOA.cs @@ -2,7 +2,7 @@ //! \date Thu Apr 23 15:57:17 2015 //! \brief Entis GLS engine archives implementation. // -// Copyright (C) 2015 by morkt +// Copyright (C) 2015-2016 by morkt // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to @@ -95,21 +95,7 @@ namespace GameRes.Formats.Entis if (!reader.HasEncrypted) return new ArcFile (file, this, reader.Dir); - var options = Query (arcStrings.ArcEncryptedNotice); - string password = null; - if (!string.IsNullOrEmpty (options.PassPhrase)) - { - password = options.PassPhrase; - } - else if (!string.IsNullOrEmpty (options.Scheme)) - { - Dictionary filemap; - if (KnownKeys.TryGetValue (options.Scheme, out filemap)) - { - var filename = Path.GetFileName (file.Name).ToLowerInvariant(); - filemap.TryGetValue (filename, out password); - } - } + var password = GetArcPassword (file.Name); if (string.IsNullOrEmpty (password)) return new ArcFile (file, this, reader.Dir); return new NoaArchive (file, this, reader.Dir, password); @@ -147,6 +133,31 @@ namespace GameRes.Formats.Entis return input; } + string GetArcPassword (string arc_name) + { + var title = FormatCatalog.Instance.LookupGame (arc_name, @"..\*.exe"); + if (string.IsNullOrEmpty (title) || !KnownKeys.ContainsKey (title)) + { + var options = Query (arcStrings.ArcEncryptedNotice); + if (!string.IsNullOrEmpty (options.PassPhrase)) + { + return options.PassPhrase; + } + title = options.Scheme; + } + string password = null; + if (!string.IsNullOrEmpty (title)) + { + Dictionary filemap; + if (KnownKeys.TryGetValue (title, out filemap)) + { + var filename = Path.GetFileName (arc_name).ToLowerInvariant(); + filemap.TryGetValue (filename, out password); + } + } + return password; + } + Stream DecodeNemesis (Stream input) { var decoder = new NemesisDecodeContext();