mirror of
https://github.com/crskycode/GARbro.git
synced 2026-07-08 01:30:18 +08:00
use AutoEntry to determine type of entries.
This commit is contained in:
@@ -27,6 +27,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.Composition;
|
using System.ComponentModel.Composition;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using GameRes.Utility;
|
using GameRes.Utility;
|
||||||
|
|
||||||
namespace GameRes.Formats.Marble
|
namespace GameRes.Formats.Marble
|
||||||
@@ -63,27 +64,21 @@ namespace GameRes.Formats.Marble
|
|||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
string name = file.View.ReadString (index_offset, filename_len);
|
string name = file.View.ReadString (index_offset, filename_len);
|
||||||
if (name.Length+1 < filename_len)
|
if (0 == name.Length)
|
||||||
{
|
return null;
|
||||||
uint ext_length = (uint)Math.Min (filename_len-name.Length-1, 3);
|
|
||||||
string ext = file.View.ReadString (index_offset+name.Length+1, ext_length);
|
|
||||||
if (!string.IsNullOrEmpty (ext))
|
|
||||||
{
|
|
||||||
if ("OG" == ext || "O" == ext)
|
|
||||||
ext = "OGG";
|
|
||||||
else if ("PR" == ext || "P" == ext)
|
|
||||||
ext = "PRS";
|
|
||||||
else if ("WA" == ext || "W" == ext)
|
|
||||||
ext = "WAY";
|
|
||||||
name = Path.ChangeExtension (name, ext);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
name = name.ToLowerInvariant();
|
name = name.ToLowerInvariant();
|
||||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
|
||||||
index_offset += (uint)filename_len;
|
index_offset += (uint)filename_len;
|
||||||
entry.Offset = file.View.ReadUInt32 (index_offset);
|
uint offset = file.View.ReadUInt32 (index_offset);
|
||||||
|
var entry = new AutoEntry (name, () => {
|
||||||
|
uint signature = file.View.ReadUInt32 (offset);
|
||||||
|
var res = FormatCatalog.Instance.LookupSignature (signature);
|
||||||
|
if (!res.Any() && 0x4259 == (0xffff & signature))
|
||||||
|
res = FormatCatalog.Instance.ImageFormats.Where (x => x.Tag == "PRS");
|
||||||
|
return res.FirstOrDefault();
|
||||||
|
});
|
||||||
|
entry.Offset = offset;
|
||||||
entry.Size = file.View.ReadUInt32 (index_offset+4);
|
entry.Size = file.View.ReadUInt32 (index_offset+4);
|
||||||
if (!entry.CheckPlacement (file.MaxOffset))
|
if (offset < index_size || !entry.CheckPlacement (file.MaxOffset))
|
||||||
return null;
|
return null;
|
||||||
dir.Add (entry);
|
dir.Add (entry);
|
||||||
index_offset += 8;
|
index_offset += 8;
|
||||||
|
|||||||
Reference in New Issue
Block a user