(BGI): detect file types manually instead of relying on AutoEntry.

This commit is contained in:
morkt 2017-03-03 17:45:00 +04:00
parent 01cd7d7675
commit 1e14ff627a

View File

@ -122,13 +122,22 @@ namespace GameRes.Formats.BGI
{ {
string name = file.View.ReadString (index_offset, 0x60); string name = file.View.ReadString (index_offset, 0x60);
var offset = base_offset + file.View.ReadUInt32 (index_offset+0x60); var offset = base_offset + file.View.ReadUInt32 (index_offset+0x60);
var entry = AutoEntry.Create (file, offset, name); var entry = new Entry { Name = name, Offset = offset };
entry.Size = file.View.ReadUInt32 (index_offset+0x64); entry.Size = file.View.ReadUInt32 (index_offset+0x64);
if (!entry.CheckPlacement (file.MaxOffset)) if (!entry.CheckPlacement (file.MaxOffset))
return null; return null;
dir.Add (entry); dir.Add (entry);
index_offset += 0x80; index_offset += 0x80;
} }
foreach (var entry in dir)
{
uint signature = file.View.ReadUInt32 (entry.Offset);
var res = AutoEntry.DetectFileType (signature);
if (res != null)
entry.Type = res.Type;
else if (file.View.AsciiEqual (entry.Offset+4, "bw "))
entry.Type = "audio";
}
return new ArcFile (file, this, dir); return new ArcFile (file, this, dir);
} }
} }