mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-23 19:34:15 +08:00
(VPK): added VPK0 archives implementation.
This commit is contained in:
parent
8fbc8d4723
commit
1860077251
@ -42,6 +42,7 @@ namespace GameRes.Formats.Will
|
||||
public VpkOpener ()
|
||||
{
|
||||
Extensions = new string[] { "vpk" };
|
||||
Signatures = new uint[] { 0x314B5056, 0x304B5056 };
|
||||
}
|
||||
|
||||
public override ArcFile TryOpen (ArcView file)
|
||||
@ -58,25 +59,37 @@ namespace GameRes.Formats.Will
|
||||
long data_offset = index_offset + index_size;
|
||||
if (data_offset >= file.MaxOffset || data_offset <= index_offset)
|
||||
return null;
|
||||
var dir = new List<Entry> (count);
|
||||
for (int i = 0; i < count; ++i)
|
||||
int version = file.View.ReadByte (3) - '0';
|
||||
int name_length = version > 0 ? 4 : 2;
|
||||
using (var index = file.CreateStream (index_offset, index_size))
|
||||
{
|
||||
var name = file.View.ReadString (index_offset, 4);
|
||||
if (0 == name.Length)
|
||||
return null;
|
||||
uint n1 = file.View.ReadUInt16 (index_offset+4);
|
||||
uint n2 = file.View.ReadUInt16 (index_offset+6);
|
||||
uint n3 = file.View.ReadUInt32 (index_offset+8);
|
||||
name = string.Format ("{0}_{1:D2}_{2}_{3:D3}.wav", name, n1, n2, n3);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = file.View.ReadUInt32 (index_offset+0x0C);
|
||||
entry.Size = file.View.ReadUInt32 (index_offset+0x10);
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
return null;
|
||||
dir.Add (entry);
|
||||
index_offset += 0x14;
|
||||
var dir = new List<Entry> (count);
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
var name = index.ReadCString (name_length);
|
||||
if (0 == name.Length)
|
||||
return null;
|
||||
uint n1 = index.ReadUInt16();
|
||||
if (version > 0)
|
||||
{
|
||||
uint n2 = index.ReadUInt16();
|
||||
uint n3 = index.ReadUInt32();
|
||||
name = string.Format ("{0}_{1:D2}_{2}_{3:D3}.wav", name, n1, n2, n3);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint n2 = index.ReadUInt32();
|
||||
name = string.Format ("{0}_{1:D2}_{2:D3}.wav", name, n1, n2);
|
||||
}
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = index.ReadUInt32();
|
||||
entry.Size = index.ReadUInt32();
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
return null;
|
||||
dir.Add (entry);
|
||||
}
|
||||
return new ArcFile (file, this, dir);
|
||||
}
|
||||
return new ArcFile (file, this, dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user