(GrpOpener): use AutoEntry.DetectFileType

This commit is contained in:
morkt 2018-08-31 04:34:24 +04:00
parent c5dd52bc2d
commit e89574e4ea

View File

@ -81,7 +81,7 @@ namespace GameRes.Formats.Ankh
return new ArcFile (file, this, dir); return new ArcFile (file, this, dir);
} }
void DetectFileTypes (ArcView file, List<Entry> dir) internal void DetectFileTypes (ArcView file, List<Entry> dir)
{ {
var header = new byte[16]; var header = new byte[16];
foreach (PackedEntry entry in dir) foreach (PackedEntry entry in dir)
@ -128,29 +128,22 @@ namespace GameRes.Formats.Ankh
entry.UnpackedSize = header.ToUInt32 (0); entry.UnpackedSize = header.ToUInt32 (0);
entry.IsPacked = true; entry.IsPacked = true;
} }
else if (header.AsciiEqual ("BM")) else
{ {
entry.ChangeType (ImageFormat.Bmp); uint signature = header.ToUInt32 (0);
} var res = AutoEntry.DetectFileType (signature);
else if (header.AsciiEqual ("RIFF")) if (res != null)
{ {
entry.ChangeType (AudioFormat.Wav); entry.ChangeType (res);
} }
else if (header.AsciiEqual ("\x89PNG")) else if ((signature & 0xFFFF) == 0xFBFF)
{ {
entry.ChangeType (ImageFormat.Png); entry.ChangeType (Mp3Format.Value);
} }
else if (header.ToUInt32 (0) == 0xE0FFD8FF) else if (entry.Size > 0x16 && IsAudioEntry (file, entry))
{ {
entry.ChangeType (ImageFormat.Jpeg); entry.Type = "audio";
} }
else if (header.ToUInt16 (0) == 0xFBFF)
{
entry.ChangeType (Mp3Format.Value);
}
else if (entry.Size > 0x16 && IsAudioEntry (file, entry))
{
entry.Type = "audio";
} }
} }
} }