mirror of
https://github.com/crskycode/GARbro.git
synced 2026-06-06 05:38:48 +08:00
(TTD): detect index entry size.
This commit is contained in:
@@ -28,6 +28,7 @@ using System.ComponentModel.Composition;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using GameRes.Compression;
|
using GameRes.Compression;
|
||||||
|
|
||||||
|
// [021220][Aias] Stitch -Kakechigaeta Button-
|
||||||
// [030829][Melonpan] Himawari no Natsu ~Boku ga Eranda Ashita~
|
// [030829][Melonpan] Himawari no Natsu ~Boku ga Eranda Ashita~
|
||||||
|
|
||||||
namespace GameRes.Formats.Melonpan
|
namespace GameRes.Formats.Melonpan
|
||||||
@@ -46,20 +47,25 @@ namespace GameRes.Formats.Melonpan
|
|||||||
int count = file.View.ReadInt32 (4);
|
int count = file.View.ReadInt32 (4);
|
||||||
if (!IsSaneCount (count))
|
if (!IsSaneCount (count))
|
||||||
return null;
|
return null;
|
||||||
uint index_offset = 12;
|
int index_offset = 12;
|
||||||
|
int first_offset = file.View.ReadInt32 (index_offset+4);
|
||||||
|
int name_length = (first_offset - index_offset) / count - 0xC;
|
||||||
|
if (name_length < 8)
|
||||||
|
return null;
|
||||||
var dir = new List<Entry> (count);
|
var dir = new List<Entry> (count);
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
uint size = file.View.ReadUInt32 (index_offset);
|
uint size = file.View.ReadUInt32 (index_offset);
|
||||||
uint offset = file.View.ReadUInt32 (index_offset+4);
|
uint offset = file.View.ReadUInt32 (index_offset+4);
|
||||||
var name = file.View.ReadString (index_offset+0xC, 0x20);
|
index_offset += 0xC;
|
||||||
var entry = FormatCatalog.Instance.Create<PackedEntry> (name);
|
var name = file.View.ReadString (index_offset, (uint)name_length);
|
||||||
|
var entry = Create<PackedEntry> (name);
|
||||||
entry.Offset = offset;
|
entry.Offset = offset;
|
||||||
entry.Size = size;
|
entry.Size = size;
|
||||||
if (!entry.CheckPlacement (file.MaxOffset))
|
if (!entry.CheckPlacement (file.MaxOffset))
|
||||||
return null;
|
return null;
|
||||||
dir.Add (entry);
|
dir.Add (entry);
|
||||||
index_offset += 0x2C;
|
index_offset += name_length;
|
||||||
}
|
}
|
||||||
return new ArcFile (file, this, dir);
|
return new ArcFile (file, this, dir);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user