(PAC): archive index variation.

This commit is contained in:
morkt
2018-04-20 21:17:16 +04:00
parent f3a7afab63
commit acaae80766

View File

@@ -130,11 +130,8 @@ namespace GameRes.Formats.NeXAS
index_packed[i] = (byte)~index_packed[i]; index_packed[i] = (byte)~index_packed[i];
var index = HuffmanDecode (index_packed, unpacked_size); var index = HuffmanDecode (index_packed, unpacked_size);
using (var input = new MemoryStream (index)) using (var input = new BinMemoryStream (index))
if (!ReadFromStream (input, 0x40)) return ReadFromStream (input, 0x40);
return false;
return true;
} }
bool ReadOld () bool ReadOld ()
@@ -142,24 +139,19 @@ namespace GameRes.Formats.NeXAS
using (var input = m_file.CreateStream()) using (var input = m_file.CreateStream())
{ {
input.Position = 0xC; input.Position = 0xC;
if (!ReadFromStream (input, 0x20)) if (ReadFromStream (input, 0x20))
return false;
}
return true; return true;
input.Position = 0xC;
return ReadFromStream (input, 0x40);
}
} }
byte[] m_name_buffer = new byte[MaxNameLength]; bool ReadFromStream (IBinaryStream index, int name_length)
bool ReadFromStream (Stream input, int name_length)
{ {
m_dir.Clear(); m_dir.Clear();
using (var index = new ArcView.Reader (input))
{
for (int i = 0; i < m_count; ++i) for (int i = 0; i < m_count; ++i)
{ {
if (name_length != index.Read (m_name_buffer, 0, name_length)) var name = index.ReadCString (name_length);
return false;
var name = Binary.GetCString (m_name_buffer, 0, name_length);
if (string.IsNullOrWhiteSpace (name)) if (string.IsNullOrWhiteSpace (name))
return false; return false;
var entry = FormatCatalog.Instance.Create<PackedEntry> (name); var entry = FormatCatalog.Instance.Create<PackedEntry> (name);
@@ -174,7 +166,6 @@ namespace GameRes.Formats.NeXAS
return true; return true;
} }
} }
}
public override Stream OpenEntry (ArcFile arc, Entry entry) public override Stream OpenEntry (ArcFile arc, Entry entry)
{ {