(ArcFile.TryOpen): don't try same format twice.

This commit is contained in:
morkt 2016-06-18 10:10:19 +04:00
parent 9cf0c88b59
commit 394a7949dd

View File

@ -72,6 +72,7 @@ namespace GameRes
try try
{ {
uint signature = file.View.ReadUInt32 (0); uint signature = file.View.ReadUInt32 (0);
var tried = new HashSet<ArchiveFormat>();
for (;;) for (;;)
{ {
var range = FormatCatalog.Instance.LookupSignature<ArchiveFormat> (signature); var range = FormatCatalog.Instance.LookupSignature<ArchiveFormat> (signature);
@ -80,6 +81,8 @@ namespace GameRes
range = range.OrderByDescending (f => f.Extensions.Any (e => e == ext.Value)); range = range.OrderByDescending (f => f.Extensions.Any (e => e == ext.Value));
foreach (var impl in range) foreach (var impl in range)
{ {
if (!tried.Add (impl))
continue;
try try
{ {
var arc = impl.TryOpen (file); var arc = impl.TryOpen (file);