bunch of stuff.

This commit is contained in:
morkt
2023-08-24 01:33:50 +04:00
parent ea096c52ef
commit 77fde27d26
119 changed files with 11078 additions and 619 deletions

View File

@@ -37,6 +37,11 @@ namespace GameRes.Formats.Will
public override bool IsHierarchic { get { return false; } }
public override bool CanWrite { get { return false; } }
public BmxOpener ()
{
ContainedFormats = new[] { "BC" };
}
public override ArcFile TryOpen (ArcView file)
{
uint total_size = file.View.ReadUInt32 (0);
@@ -48,34 +53,29 @@ namespace GameRes.Formats.Will
var dir = new List<Entry> (count);
uint index_offset = 0x10;
uint next_offset = file.View.ReadUInt32 (index_offset+0x1C);
for (int i = 0; i < count; ++i)
{
var name = file.View.ReadString (index_offset, 0x1C);
if (0 == name.Length)
break;
index_offset += 0x20;
var entry = FormatCatalog.Instance.Create<Entry> (name);
entry.Offset = next_offset;
if (i+1 < count)
{
next_offset = file.View.ReadUInt32 (index_offset+0x1C);
if (0 == next_offset)
next_offset = (uint)file.MaxOffset;
}
else
{
next_offset = (uint)file.MaxOffset;
}
entry.Size = (uint)(next_offset - entry.Offset);
if (!entry.CheckPlacement (file.MaxOffset))
return null;
entry.Offset = file.View.ReadUInt32 (index_offset+0x1C);
if (string.IsNullOrEmpty (entry.Type))
entry.Type = "image";
dir.Add (entry);
index_offset += 0x20;
}
if (0 == dir.Count)
return null;
long last_offset = file.MaxOffset;
for (int i = dir.Count - 1; i >= 0; --i)
{
var entry = dir[i];
entry.Size = (uint)(last_offset - entry.Offset);
last_offset = entry.Offset;
if (!entry.CheckPlacement (file.MaxOffset))
return null;
}
return new ArcFile (file, this, dir);
}
}

View File

@@ -40,6 +40,7 @@ namespace GameRes.Formats.Will
public MbfOpener ()
{
Signatures = new uint[] { 0x3046424D, 0x3146424D };
ContainedFormats = new[] { "BC" };
}
public override ArcFile TryOpen (ArcView file)

View File

@@ -43,6 +43,7 @@ namespace GameRes.Formats.Will
{
Extensions = new string[] { "vpk" };
Signatures = new uint[] { 0x314B5056, 0x304B5056 };
ContainedFormats = new[] { "WAV" };
}
public override ArcFile TryOpen (ArcView file)

View File

@@ -43,6 +43,7 @@ namespace GameRes.Formats.Will
{
Extensions = new string[] { "wsm" };
Signatures = new uint[] { 0x324D5357, 0x334D5357 };
ContainedFormats = new[] { "WAV" };
}
public override ArcFile TryOpen (ArcView file)
@@ -71,6 +72,7 @@ namespace GameRes.Formats.Will
dir.Add (entry);
}
int index_offset = 0;
var names = new HashSet<string>();
for (int i = 0; i < count; ++i)
{
int entry_pos = index.ToInt32 (index_offset);
@@ -83,8 +85,20 @@ namespace GameRes.Formats.Will
int entry_idx = index[entry_pos+3];
if (entry_idx >= dir.Count)
return null;
if (0 == entry_idx)
entry_idx = i;
var entry = dir[entry_idx];
entry.Name = string.Format ("{0:D2}_{1}.wav", entry_idx, name);
entry.Name = name + ".wav";
names.Add (entry.Name);
}
if (names.Count != dir.Count)
{
// make filenames unique by prepending index number
for (int i = 0; i < dir.Count; ++i)
{
var entry = dir[i];
entry.Name = string.Format("{0:D2}_{1}", i, entry.Name);
}
}
return new ArcFile (file, this, dir);
}