mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-24 20:04:13 +08:00
(KCAP): recognize older archive version.
This commit is contained in:
parent
aa7bfca83f
commit
da057b4326
@ -41,27 +41,33 @@ namespace GameRes.Formats.Leaf
|
|||||||
|
|
||||||
public KcapOpener ()
|
public KcapOpener ()
|
||||||
{
|
{
|
||||||
ContainedFormats = new[] { "TGA", "BJR", "BMP", "OGG", "WAV", "AMP/LEAF" };
|
ContainedFormats = new[] { "TGA", "BJR", "BMP", "OGG", "WAV", "AMP/LEAF", "SCR" };
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ArcFile TryOpen (ArcView file)
|
public override ArcFile TryOpen (ArcView file)
|
||||||
{
|
{
|
||||||
int version = 1;
|
int version = 0;
|
||||||
int count = file.View.ReadInt32 (8);
|
int count = file.View.ReadInt32 (4);
|
||||||
uint first_offset = file.View.ReadUInt32 (0x28);
|
uint first_offset = file.View.ReadUInt32 (0x24);
|
||||||
|
if (!IsSaneCount (count) || count * 0x24 + 8 != first_offset)
|
||||||
|
{
|
||||||
|
version = 1;
|
||||||
|
count = file.View.ReadInt32 (8);
|
||||||
|
first_offset = file.View.ReadUInt32 (0x28);
|
||||||
if (!IsSaneCount (count) || count * 0x24 + 0xC != first_offset)
|
if (!IsSaneCount (count) || count * 0x24 + 0xC != first_offset)
|
||||||
{
|
{
|
||||||
count = file.View.ReadInt32 (12);
|
count = file.View.ReadInt32 (12);
|
||||||
if (!IsSaneCount (count))
|
|
||||||
return null;
|
|
||||||
first_offset = file.View.ReadUInt32 (0x34);
|
first_offset = file.View.ReadUInt32 (0x34);
|
||||||
if (count * 0x2C + 0x10 != first_offset)
|
if (!IsSaneCount (count) || count * 0x2C + 0x10 != first_offset)
|
||||||
return null;
|
return null;
|
||||||
version = 2;
|
version = 2;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
List<Entry> dir;
|
List<Entry> dir;
|
||||||
if (1 == version)
|
if (0 == version)
|
||||||
dir = ReadIndexV1 (file, count);
|
dir = ReadIndexV1 (file, count, 8);
|
||||||
|
else if (1 == version)
|
||||||
|
dir = ReadIndexV1 (file, count, 0xC);
|
||||||
else
|
else
|
||||||
dir = ReadIndexV2 (file, count);
|
dir = ReadIndexV2 (file, count);
|
||||||
if (null == dir)
|
if (null == dir)
|
||||||
@ -69,10 +75,9 @@ namespace GameRes.Formats.Leaf
|
|||||||
return new ArcFile (file, this, dir);
|
return new ArcFile (file, this, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Entry> ReadIndexV1 (ArcView file, int count)
|
List<Entry> ReadIndexV1 (ArcView file, int count, uint index_offset)
|
||||||
{
|
{
|
||||||
const uint index_entry_size = 0x24;
|
const uint index_entry_size = 0x24;
|
||||||
uint index_offset = 0xC;
|
|
||||||
uint index_size = (uint)count * index_entry_size;
|
uint index_size = (uint)count * index_entry_size;
|
||||||
if (file.View.Reserve (index_offset, index_size) < index_size)
|
if (file.View.Reserve (index_offset, index_size) < index_size)
|
||||||
return null;
|
return null;
|
||||||
@ -170,4 +175,9 @@ namespace GameRes.Formats.Leaf
|
|||||||
public override string Description { get { return "Leaf engine internal file"; } }
|
public override string Description { get { return "Leaf engine internal file"; } }
|
||||||
public override uint Signature { get { return 0; } }
|
public override uint Signature { get { return 0; } }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Export(typeof(ResourceAlias))]
|
||||||
|
[ExportMetadata("Extension", "SDT")]
|
||||||
|
[ExportMetadata("Target", "SCR")]
|
||||||
|
public class SdtFormat : ResourceAlias { }
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user