mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-30 17:05:37 +08:00
GameRes refactoring.
(FormatCatalog.CreateEntry): method renamed to 'Create' and made generic towards Entry type.
This commit is contained in:
parent
4bfdc502e4
commit
46dbf2b142
@ -113,7 +113,7 @@ namespace GARbro.GUI
|
||||
{
|
||||
if (0 != (file.Attributes & (FileAttributes.System)))
|
||||
continue;
|
||||
var entry = FormatCatalog.Instance.CreateEntry (file.Name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (file.Name);
|
||||
entry.Size = (uint)Math.Min (file.Length, uint.MaxValue);
|
||||
list.Add (entry);
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ namespace GameRes.Formats.AZSys
|
||||
var name = Binary.GetCString (index, index_offset + 0x10, 0x30);
|
||||
if (name.Length > 0)
|
||||
{
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = base_offset + LittleEndian.ToUInt32 (index, index_offset);
|
||||
entry.Size = LittleEndian.ToUInt32 (index, index_offset + 4);
|
||||
if (entry.CheckPlacement (file.MaxOffset))
|
||||
|
@ -64,7 +64,7 @@ namespace GameRes.Formats.AdPack
|
||||
string ext = file.View.ReadString (index_offset+8, 4).TrimEnd (null);
|
||||
if (0 != ext.Length)
|
||||
name += '.'+ext;
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
uint offset = file.View.ReadUInt32 (index_offset+12);
|
||||
uint next_offset = file.View.ReadUInt32 (index_offset+0x10+12);
|
||||
entry.Size = next_offset - offset;
|
||||
@ -107,7 +107,7 @@ namespace GameRes.Formats.AdPack
|
||||
for (uint i = 0; i < count; ++i)
|
||||
{
|
||||
string name = file.View.ReadString (index_offset, 0x18);
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
uint offset = file.View.ReadUInt32 (index_offset+0x1c);
|
||||
uint next_offset = file.View.ReadUInt32 (index_offset+0x20+0x1c);
|
||||
entry.Size = next_offset - offset;
|
||||
|
@ -60,7 +60,7 @@ namespace GameRes.Formats.AdvSys
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
var name = file.View.ReadString (index_offset, 0x18);
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Size = file.View.ReadUInt32 (index_offset+0x18);
|
||||
entry.Offset = file.View.ReadUInt32 (index_offset+0x1C);
|
||||
if (entry.Offset < data_offset || !entry.CheckPlacement (file.MaxOffset))
|
||||
|
@ -167,7 +167,7 @@ namespace GameRes.Formats.AVC
|
||||
continue;
|
||||
}
|
||||
var name = Encodings.cp932.GetString (m_index, index_offset, name_length);
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
index_offset += 0x107;
|
||||
entry.Offset = m_header_offset + LittleEndian.ToUInt32 (m_index, index_offset);
|
||||
entry.Size = LittleEndian.ToUInt32 (m_index, index_offset+4);
|
||||
|
@ -60,7 +60,7 @@ namespace GameRes.Formats.Ego
|
||||
if (entry_len <= 0x10 || entry_len > 0x100 || index_offset + entry_len > data_offset)
|
||||
return null;
|
||||
var name = file.View.ReadString (index_offset+0x10, entry_len-0x10);
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = file.View.ReadUInt32 (index_offset+8);
|
||||
entry.Size = file.View.ReadUInt32 (index_offset+12);
|
||||
if (entry.Offset < data_offset || !entry.CheckPlacement (file.MaxOffset))
|
||||
|
@ -60,7 +60,7 @@ namespace GameRes.Formats.FVP
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
string name = file.View.ReadString (index_offset, 0x20);
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = file.View.ReadUInt32 (index_offset+0x20);
|
||||
entry.Size = file.View.ReadUInt32 (index_offset+0x24);
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
|
@ -65,7 +65,7 @@ namespace GameRes.Formats.X
|
||||
return null;
|
||||
file.View.Read (index_offset+1, name_buffer, 0, name_length);
|
||||
string name = Encodings.cp932.GetString (name_buffer, 0, name_length);
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = file.View.ReadUInt32 (index_offset+0x20);
|
||||
entry.Size = file.View.ReadUInt32 (index_offset+0x1C);
|
||||
if (entry.Offset < data_offset || !entry.CheckPlacement (file.MaxOffset))
|
||||
|
@ -53,7 +53,7 @@ namespace GameRes.Formats.ISM
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
var name = file.View.ReadString (index_offset, 0x0c);
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = file.View.ReadUInt32 (index_offset+0x10);
|
||||
entry.Size = file.View.ReadUInt32 (index_offset+0x14);
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
|
@ -64,8 +64,7 @@ namespace GameRes.Formats.SystemEpsylon
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
string name = file.View.ReadString (index_offset, 0x20);
|
||||
var entry = new PackDatEntry { Name = name };
|
||||
entry.Type = FormatCatalog.Instance.GetTypeFromName (name);
|
||||
var entry = FormatCatalog.Instance.Create<PackDatEntry> (name);
|
||||
entry.Offset = file.View.ReadUInt32 (index_offset+0x20);
|
||||
entry.Flags = file.View.ReadUInt32 (index_offset+0x24);
|
||||
entry.Size = file.View.ReadUInt32 (index_offset+0x28);
|
||||
|
@ -96,8 +96,7 @@ namespace GameRes.Formats.Kogado
|
||||
name = i.ToString ("D5");
|
||||
if (0 != ext.Length)
|
||||
name += '.'+ext;
|
||||
var entry = new KogadoEntry { Name = name };
|
||||
entry.Type = FormatCatalog.Instance.GetTypeFromName (entry.Name);
|
||||
var entry = FormatCatalog.Instance.Create<KogadoEntry> (name);
|
||||
entry.Offset = data_offset + file.View.ReadUInt32 (index_offset + 0x18);
|
||||
if (version >= 0x200)
|
||||
{
|
||||
|
@ -84,7 +84,7 @@ namespace GameRes.Formats.Nexton
|
||||
string name = ReadName (lst, index_offset+8, 0x24, 0xcccccccc, cp932);
|
||||
if (0 == name.Length)
|
||||
return null;
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = lst.View.ReadUInt32 (index_offset) ^ 0xcccccccc;
|
||||
entry.Size = lst.View.ReadUInt32 (index_offset+4) ^ 0xcccccccc;
|
||||
if (!entry.CheckPlacement (max_offset))
|
||||
|
@ -51,7 +51,7 @@ namespace GameRes.Formats.Mg
|
||||
{
|
||||
uint name_length = file.View.ReadByte (cur_offset);
|
||||
string name = file.View.ReadString (cur_offset+1, name_length, Encoding.UTF8);
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = file.View.ReadUInt32 (cur_offset+0x20);
|
||||
entry.Size = file.View.ReadUInt32 (cur_offset+0x24);
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
|
@ -87,8 +87,7 @@ namespace GameRes.Formats.Qlie
|
||||
name_buffer[k] ^= (byte)(((k + 1) ^ key) + k + 1);
|
||||
|
||||
string name = Encodings.cp932.GetString (name_buffer, 0, name_length);
|
||||
var entry = new QlieEntry { Name = name };
|
||||
entry.Type = FormatCatalog.Instance.GetTypeFromName (name);
|
||||
var entry = FormatCatalog.Instance.Create<QlieEntry> (name);
|
||||
|
||||
index_offset += 2 + name_length;
|
||||
entry.Offset = file.View.ReadInt64 (index_offset);
|
||||
|
@ -71,7 +71,7 @@ namespace GameRes.Formats.BlackCyc
|
||||
return null;
|
||||
string name = gtb.View.ReadString (name_offset, (uint)(gtb.MaxOffset-name_offset));
|
||||
name += ".dwq";
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = next_offset;
|
||||
if (i + 1 == count)
|
||||
next_offset = (uint)file.MaxOffset;
|
||||
|
@ -61,7 +61,7 @@ namespace GameRes.Formats.BlackCyc
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
string name = vtb.View.ReadString (index_offset, 8) + ".vaw";
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = next_offset;
|
||||
index_offset += 0xC;
|
||||
next_offset = vtb.View.ReadUInt32 (index_offset+8);
|
||||
|
@ -109,7 +109,7 @@ namespace GameRes.Formats.CatSystem
|
||||
for (uint i = 0; i < entry_count; ++i)
|
||||
{
|
||||
string name = file.View.ReadString (current_offset, 0x40);
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = file.View.ReadUInt32 (current_offset+0x40);
|
||||
entry.Size = file.View.ReadUInt32 (current_offset+0x44);
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
@ -150,7 +150,7 @@ namespace GameRes.Formats.CatSystem
|
||||
uint key = twister.Twist (main_key + i);
|
||||
string name = DecipherName (name_info, key);
|
||||
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = eax;
|
||||
entry.Size = edx;
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
|
@ -70,7 +70,7 @@ namespace GameRes.Formats.Circus
|
||||
if (0 == file.View.ReadByte (index_offset))
|
||||
return null;
|
||||
string name = file.View.ReadString (index_offset, (uint)name_length);
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
index_offset += name_length;
|
||||
uint offset = next_offset;
|
||||
if (i+1 == count)
|
||||
|
@ -45,7 +45,7 @@ namespace GameRes.Formats.??????
|
||||
var dir = new List<Entry> (count);
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
return null;
|
||||
dir.Add (entry);
|
||||
|
@ -70,7 +70,7 @@ namespace GameRes.Formats.Eagls
|
||||
break;
|
||||
var name = Binary.GetCString (index, index_offset, name_size);
|
||||
index_offset += name_size;
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
if (name.EndsWith (".dat", StringComparison.InvariantCultureIgnoreCase))
|
||||
entry.Type = "script";
|
||||
if (long_offsets)
|
||||
|
@ -119,7 +119,7 @@ namespace GameRes.Formats.Emic
|
||||
index_offset += 4;
|
||||
Read (index_offset, index_buf, 0, name_len+8);
|
||||
string name = Binary.GetCString (index_buf, 0, name_len);
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = LittleEndian.ToUInt32 (index_buf, name_len+4);
|
||||
entry.Size = LittleEndian.ToUInt32 (index_buf, name_len);
|
||||
if (!entry.CheckPlacement (m_file.MaxOffset))
|
||||
|
@ -61,7 +61,7 @@ namespace GameRes.Formats.BGI
|
||||
for (uint i = 0; i < count; ++i)
|
||||
{
|
||||
string name = file.View.ReadString (index_offset, 0x10);
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = base_offset + file.View.ReadUInt32 (index_offset+0x10);
|
||||
entry.Size = file.View.ReadUInt32 (index_offset+0x14);
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
@ -121,7 +121,7 @@ namespace GameRes.Formats.BGI
|
||||
for (uint i = 0; i < count; ++i)
|
||||
{
|
||||
string name = file.View.ReadString (index_offset, 0x60);
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = base_offset + file.View.ReadUInt32 (index_offset+0x60);
|
||||
entry.Size = file.View.ReadUInt32 (index_offset+0x64);
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
|
@ -64,7 +64,7 @@ namespace GameRes.Formats.Ffa
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
string name = lst.View.ReadString (index_offset, 14);
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = lst.View.ReadUInt32 (index_offset+14);
|
||||
entry.Size = lst.View.ReadUInt32 (index_offset+18);
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
|
@ -70,7 +70,7 @@ namespace GameRes.Formats.Ffa
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
var name = file.View.ReadString (index_offset, 0x10);
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = file.View.ReadUInt32 (index_offset+0x10);
|
||||
entry.Size = file.View.ReadUInt32 (index_offset+0x14);
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
|
@ -71,7 +71,7 @@ namespace GameRes.Formats.Fs
|
||||
for (uint i = 0; i < count; ++i)
|
||||
{
|
||||
string name = file.View.ReadString (cur_offset, 0x80);
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = file.View.ReadInt64 (cur_offset+0x80);
|
||||
entry.Size = file.View.ReadUInt32 (cur_offset+0x88);
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
@ -258,7 +258,7 @@ namespace GameRes.Formats.Fs
|
||||
if (len <= 0 || len >= 0x24)
|
||||
return null;
|
||||
string name = enc.GetString (buf, 0, len);
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
uint shift = LittleEndian.ToUInt32 (buf, 0x24);
|
||||
entry.Offset = LittleEndian.ToUInt32 (buf, 0x28) - shift;
|
||||
entry.Size = LittleEndian.ToUInt32 (buf, 0x2c) - shift;
|
||||
|
@ -54,7 +54,7 @@ namespace GameRes.Formats.BlackRainbow
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
string name = file.View.ReadString (index_offset+8, 0x38);
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = file.View.ReadUInt32 (index_offset);
|
||||
entry.Size = file.View.ReadUInt32 (index_offset+4);
|
||||
if (entry.Offset < data_offset || !entry.CheckPlacement (file.MaxOffset))
|
||||
@ -104,7 +104,7 @@ namespace GameRes.Formats.BlackRainbow
|
||||
{
|
||||
long offset = index[i];
|
||||
string name = file.View.ReadString (offset, 0x20);
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = offset + 0x24;
|
||||
entry.Size = file.View.ReadUInt32 (offset+0x20);
|
||||
dir.Add (entry);
|
||||
|
@ -84,7 +84,7 @@ namespace GameRes.Formats.Ikura
|
||||
if (next_offset > file.MaxOffset || next_offset < offset)
|
||||
return null;
|
||||
string name = encoding.GetString (name_raw, 0, name_length).ToLowerInvariant();
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = offset;
|
||||
entry.Size = next_offset - offset;
|
||||
dir.Add (entry);
|
||||
@ -155,7 +155,7 @@ namespace GameRes.Formats.Ikura
|
||||
has_scripts = true;
|
||||
}
|
||||
else
|
||||
entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = file.View.ReadUInt32 (dir_offset+12);
|
||||
entry.Size = file.View.ReadUInt32 (dir_offset+16);
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
|
@ -68,7 +68,7 @@ namespace GameRes.Formats.CandySoft
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
string name = file.View.ReadString (index_offset+8, (uint)name_size);
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = file.View.ReadUInt32 (index_offset);
|
||||
entry.Size = file.View.ReadUInt32 (index_offset+4);
|
||||
if (entry.Offset < index_size || !entry.CheckPlacement (file.MaxOffset))
|
||||
|
@ -63,7 +63,7 @@ namespace GameRes.Formats.Liar
|
||||
if (cur_offset+40 > base_offset)
|
||||
return null;
|
||||
string name = file.View.ReadString (cur_offset, 32);
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = base_offset + file.View.ReadUInt32 (cur_offset+32);
|
||||
entry.Size = file.View.ReadUInt32 (cur_offset+36);
|
||||
if (!entry.CheckPlacement (max_offset))
|
||||
|
@ -78,7 +78,7 @@ namespace GameRes.Formats.Lilim
|
||||
if (-1 == name_length)
|
||||
name_length = name_buf.Length;
|
||||
var name = Encodings.cp932.GetString (name_buf, 0, name_length);
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = file.View.ReadUInt32 (current_offset+0x10);
|
||||
entry.Size = file.View.ReadUInt32 (current_offset+0x14);
|
||||
current_offset += 0x20;
|
||||
|
@ -93,7 +93,7 @@ namespace GameRes.Formats.Majiro
|
||||
names_pos = zero+1;
|
||||
uint offset = offset_next;
|
||||
offset_next = file.View.ReadUInt32 (table_pos + entry_size + hash_size);
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = offset;
|
||||
if (1 == version)
|
||||
entry.Size = offset_next >= offset ? offset_next - offset : 0;
|
||||
|
@ -96,7 +96,7 @@ namespace GameRes.Formats.Malie
|
||||
if (offset < data_offset || offset + entry_size > base_offset + size)
|
||||
return false;
|
||||
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = offset;
|
||||
entry.Size = entry_size;
|
||||
m_dir.Add (entry);
|
||||
@ -226,7 +226,7 @@ namespace GameRes.Formats.Malie
|
||||
continue;
|
||||
}
|
||||
long entry_offset = m_base_offset + ((long)m_offset_table[offset] << 10);
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
if (entry.CheckPlacement (m_max_offset))
|
||||
{
|
||||
entry.Offset = entry_offset;
|
||||
|
@ -87,7 +87,7 @@ namespace GameRes.Formats.ONScripter
|
||||
return null;
|
||||
|
||||
string name = Encodings.cp932.GetString (name_buffer, 0, name_len);
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = Binary.BigEndian (file.View.ReadUInt32 (cur_offset)) + (long)base_offset;
|
||||
entry.Size = Binary.BigEndian (file.View.ReadUInt32 (cur_offset+4));
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
@ -222,12 +222,9 @@ namespace GameRes.Formats.ONScripter
|
||||
if (base_offset - cur_offset < 13)
|
||||
return null;
|
||||
|
||||
var entry = new NsaEntry
|
||||
{
|
||||
Name = Encodings.cp932.GetString (name_buffer, 0, name_len),
|
||||
};
|
||||
var name = Encodings.cp932.GetString (name_buffer, 0, name_len);
|
||||
var entry = FormatCatalog.Instance.Create<NsaEntry> (name);
|
||||
byte compression_type = file.View.ReadByte (cur_offset);
|
||||
entry.Type = FormatCatalog.Instance.GetTypeFromName (entry.Name);
|
||||
entry.Offset = Binary.BigEndian (file.View.ReadUInt32 (cur_offset+1)) + (long)base_offset;
|
||||
entry.Size = Binary.BigEndian (file.View.ReadUInt32 (cur_offset+5));
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
|
@ -101,8 +101,7 @@ namespace GameRes.Formats.NitroPlus
|
||||
if (name_length != header.Read (name_buf, 0, name_length))
|
||||
return null;
|
||||
var name = Encodings.cp932.GetString (name_buf, 0, name_length);
|
||||
var entry = new PackedEntry { Name = name };
|
||||
entry.Type = FormatCatalog.Instance.GetTypeFromName (name);
|
||||
var entry = FormatCatalog.Instance.Create<PackedEntry> (name);
|
||||
entry.Offset = base_offset + header.ReadUInt32();
|
||||
entry.UnpackedSize = header.ReadUInt32();
|
||||
entry.Size = header.ReadUInt32();
|
||||
|
@ -85,7 +85,7 @@ namespace GameRes.Formats
|
||||
Encoding enc = GuessEncoding (name_raw);
|
||||
string filename = enc.GetString (name_raw);
|
||||
|
||||
var entry = FormatCatalog.Instance.CreateEntry (filename);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (filename);
|
||||
entry.Size = header.ReadUInt32();
|
||||
entry.Offset = header.ReadInt64();
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
|
@ -70,7 +70,7 @@ namespace GameRes.Formats.Pajamas
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
var name = file.View.ReadString (name_offset, (uint)name_length);
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = base_offset + file.View.ReadUInt32 (index_offset);
|
||||
entry.Size = file.View.ReadUInt32 (index_offset+4);
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion ("1.1.9.418")]
|
||||
[assembly: AssemblyFileVersion ("1.1.9.418")]
|
||||
[assembly: AssemblyVersion ("1.1.9.419")]
|
||||
[assembly: AssemblyFileVersion ("1.1.9.419")]
|
||||
|
@ -98,14 +98,10 @@ namespace GameRes.Formats.RenPy
|
||||
Trace.WriteLine ("invalid index tuple", "RpaOpener.TryOpen");
|
||||
return null;
|
||||
}
|
||||
var entry = new RpaEntry
|
||||
{
|
||||
Name = name,
|
||||
Type = FormatCatalog.Instance.GetTypeFromName (name),
|
||||
Offset = (uint)((int)tuple[0] ^ key),
|
||||
UnpackedSize = (uint)((int)tuple[1] ^ key),
|
||||
};
|
||||
entry.Size = entry.UnpackedSize;
|
||||
var entry = FormatCatalog.Instance.Create<RpaEntry> (name);
|
||||
entry.Offset = (uint)((int)tuple[0] ^ key);
|
||||
entry.UnpackedSize = (uint)((int)tuple[1] ^ key);
|
||||
entry.Size = entry.UnpackedSize;
|
||||
if (tuple.Count > 2)
|
||||
{
|
||||
entry.Header = tuple[2] as byte[];
|
||||
|
@ -117,10 +117,7 @@ namespace GameRes.Formats.ShiinaRio // 椎名里緒
|
||||
while (name_buf.Length == header.Read (name_buf, 0, name_buf.Length))
|
||||
{
|
||||
var name = Binary.GetCString (name_buf, 0, name_buf.Length);
|
||||
var entry = new WarcEntry {
|
||||
Name = name,
|
||||
Type = FormatCatalog.Instance.GetTypeFromName (name)
|
||||
};
|
||||
var entry = FormatCatalog.Instance.Create<WarcEntry> (name);
|
||||
entry.Offset = header.ReadUInt32();
|
||||
entry.Size = header.ReadUInt32();
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
|
@ -55,7 +55,7 @@ namespace GameRes.Formats.Silky
|
||||
string name = file.View.ReadString (index_offset, 0x10);
|
||||
if (0 == name.Length)
|
||||
return null;
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = file.View.ReadUInt32 (index_offset+0x10);
|
||||
entry.Size = file.View.ReadUInt32 (index_offset+0x14);
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
|
@ -66,7 +66,7 @@ namespace GameRes.Formats.UMeSoft
|
||||
return null;
|
||||
string name = file.View.ReadString (index_offset, name_len);
|
||||
index_offset += name_len+6;
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Size = file.View.ReadUInt32 (index_offset);
|
||||
entry.Offset = file.View.ReadUInt32 (index_offset+4);
|
||||
if (!entry.CheckPlacement (index_offset))
|
||||
|
@ -60,7 +60,7 @@ namespace GameRes.Formats.WildBug
|
||||
string name = file.View.ReadString (index_offset+0x14, name_length);
|
||||
if (0 == name.Length)
|
||||
return null;
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = file.View.ReadUInt32 (index_offset);
|
||||
entry.Size = file.View.ReadUInt32 (index_offset+4);
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
|
@ -97,7 +97,7 @@ namespace GameRes.Formats.Will
|
||||
if (string.IsNullOrEmpty (name))
|
||||
return null;
|
||||
name = name.ToLowerInvariant()+'.'+ext.Extension;
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Size = file.View.ReadUInt32 (dir_offset+name_size);
|
||||
entry.Offset = file.View.ReadUInt32 (dir_offset+name_size+4);
|
||||
if (!entry.CheckPlacement (file.MaxOffset))
|
||||
|
@ -163,7 +163,7 @@ namespace GameRes.Formats.Xuse
|
||||
if (!string.IsNullOrEmpty (filename))
|
||||
{
|
||||
filename = DriveRe.Replace (filename, "");
|
||||
entry = FormatCatalog.Instance.CreateEntry (filename);
|
||||
entry = FormatCatalog.Instance.Create<Entry> (filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -97,7 +97,7 @@ namespace GameRes.Formats.Xuse
|
||||
name_buf[n] ^= 0x56;
|
||||
|
||||
var name = Encodings.cp932.GetString (name_buf, 0, name_length);
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = cadr_view.ReadInt64 (cadr_offset);
|
||||
if (entry.Offset >= file.MaxOffset)
|
||||
return null;
|
||||
|
@ -84,7 +84,7 @@ namespace GameRes.Formats.Elf
|
||||
if (0 == name.Length)
|
||||
return null;
|
||||
index_offset += scheme.NameLength;
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Size = file.View.ReadUInt32 (index_offset) ^ scheme.SizeKey;
|
||||
entry.Offset = file.View.ReadUInt32 (index_offset+4) ^ scheme.OffsetKey;
|
||||
if (entry.Offset < index_size+4 || !entry.CheckPlacement (file.MaxOffset))
|
||||
|
@ -84,7 +84,7 @@ namespace GameRes.Formats.Elf
|
||||
var dir = new List<Entry> (file_map.Count);
|
||||
for (int i = 0; i < file_map.Count; ++i)
|
||||
{
|
||||
var entry = FormatCatalog.Instance.CreateEntry (file_map[i]);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (file_map[i]);
|
||||
entry.Offset = pak.View.ReadUInt32 (index_offset);
|
||||
entry.Size = pak.View.ReadUInt32 (index_offset + 4);
|
||||
if (!entry.CheckPlacement (bin.MaxOffset))
|
||||
@ -104,7 +104,7 @@ namespace GameRes.Formats.Elf
|
||||
var dir = new List<Entry> (file_map.Count);
|
||||
for (int i = 0; i < file_map.Count; ++i)
|
||||
{
|
||||
var entry = FormatCatalog.Instance.CreateEntry (file_map[i]);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (file_map[i]);
|
||||
entry.Offset = pak.View.ReadUInt32 (index_offset);
|
||||
entry.Size = pak.View.ReadUInt32 (index_offset + 4);
|
||||
if (!entry.CheckPlacement (bin.MaxOffset))
|
||||
|
@ -103,7 +103,7 @@ namespace GameRes
|
||||
|
||||
private Entry EntryFromFileInfo (FileInfo file)
|
||||
{
|
||||
var entry = FormatCatalog.Instance.CreateEntry (file.FullName);
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (file.FullName);
|
||||
entry.Size = (uint)Math.Min (file.Length, uint.MaxValue);
|
||||
return entry;
|
||||
}
|
||||
|
@ -91,9 +91,9 @@ namespace GameRes
|
||||
/// <summary>
|
||||
/// Create empty Entry that corresponds to implemented resource.
|
||||
/// </summary>
|
||||
public virtual Entry CreateEntry ()
|
||||
public EntryType Create<EntryType> () where EntryType : Entry, new()
|
||||
{
|
||||
return new Entry { Type = this.Type };
|
||||
return new EntryType { Type = this.Type };
|
||||
}
|
||||
|
||||
protected IResource ()
|
||||
@ -363,19 +363,14 @@ namespace GameRes
|
||||
/// <exception cref="System.ArgumentException">May be thrown if filename contains invalid
|
||||
/// characters.</exception>
|
||||
/// </summary>
|
||||
public Entry CreateEntry (string filename)
|
||||
public EntryType Create<EntryType> (string filename) where EntryType : Entry, new()
|
||||
{
|
||||
Entry entry = null;
|
||||
string ext = Path.GetExtension (filename);
|
||||
if (!string.IsNullOrEmpty (ext))
|
||||
{
|
||||
ext = ext.TrimStart ('.').ToUpperInvariant();
|
||||
var range = m_extension_map.GetValues (ext, false);
|
||||
if (null != range)
|
||||
entry = range.First().CreateEntry();
|
||||
}
|
||||
EntryType entry = null;
|
||||
var formats = LookupFileName (filename);
|
||||
if (formats.Any())
|
||||
entry = formats.First().Create<EntryType>();
|
||||
if (null == entry)
|
||||
entry = new Entry();
|
||||
entry = new EntryType();
|
||||
entry.Name = filename;
|
||||
return entry;
|
||||
}
|
||||
|
@ -173,11 +173,6 @@ namespace GameRes
|
||||
return null;
|
||||
}
|
||||
|
||||
public override Entry CreateEntry ()
|
||||
{
|
||||
return new ImageEntry();
|
||||
}
|
||||
|
||||
public bool IsBuiltin
|
||||
{
|
||||
get { return this.GetType().Assembly == typeof(ImageFormat).Assembly; }
|
||||
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion ("1.1.6.8")]
|
||||
[assembly: AssemblyFileVersion ("1.1.6.8")]
|
||||
[assembly: AssemblyVersion ("1.1.7.89")]
|
||||
[assembly: AssemblyFileVersion ("1.1.7.89")]
|
||||
|
@ -231,7 +231,7 @@ namespace GARbro.GUI
|
||||
if (file.Length >= uint.MaxValue)
|
||||
continue;
|
||||
string name = Path.Combine (path, file.Name);
|
||||
var e = FormatCatalog.Instance.CreateEntry (name);
|
||||
var e = FormatCatalog.Instance.Create<Entry> (name);
|
||||
e.Size = (uint)file.Length;
|
||||
list.Add (e);
|
||||
}
|
||||
|
@ -51,5 +51,5 @@ using System.Windows;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion ("1.1.5.642")]
|
||||
[assembly: AssemblyFileVersion ("1.1.5.642")]
|
||||
[assembly: AssemblyVersion ("1.1.5.656")]
|
||||
[assembly: AssemblyFileVersion ("1.1.5.656")]
|
||||
|
Loading…
Reference in New Issue
Block a user