(DET): look for "*.at2" indices.

This commit is contained in:
morkt 2018-12-20 15:08:04 +04:00
parent 2c3ddb6693
commit c18672f1d4

View File

@ -46,15 +46,23 @@ namespace GameRes.Formats.uGOS
if (!file.Name.HasExtension (".det")) if (!file.Name.HasExtension (".det"))
return null; return null;
var name_file = Path.ChangeExtension (file.Name, "nme"); var name_file = Path.ChangeExtension (file.Name, "nme");
var index_file = Path.ChangeExtension (file.Name, "atm"); if (!VFS.FileExists (name_file))
if (!VFS.FileExists (name_file) || !VFS.FileExists (index_file))
return null; return null;
uint entry_size = 0x10;
var index_file = Path.ChangeExtension (file.Name, "atm");
if (!VFS.FileExists (index_file))
{
index_file = Path.ChangeExtension (index_file, "at2");
if (!VFS.FileExists (index_file))
return null;
entry_size = 0x14;
}
using (var nme = VFS.OpenView (name_file)) using (var nme = VFS.OpenView (name_file))
using (var idx = VFS.OpenView (index_file)) using (var idx = VFS.OpenView (index_file))
{ {
var reader = new DetIndexReader (file, name_file: nme, index_file: idx); var reader = new DetIndexReader (file, name_file: nme, index_file: idx);
var dir = reader.ReadIndex (0x10); var dir = reader.ReadIndex (entry_size);
if (null == dir) if (null == dir && entry_size != 0x14)
dir = reader.ReadIndex (0x14); dir = reader.ReadIndex (0x14);
if (null == dir) if (null == dir)
return null; return null;
@ -70,39 +78,6 @@ namespace GameRes.Formats.uGOS
var input = arc.File.CreateStream (entry.Offset, entry.Size); var input = arc.File.CreateStream (entry.Offset, entry.Size);
return new PackedStream<RleDecompressor> (input); return new PackedStream<RleDecompressor> (input);
} }
bool Unpack (Stream input, byte[] output)
{
int dst = 0;
while (dst < output.Length)
{
int ctl = input.ReadByte();
if (-1 == ctl)
return false;
if (0xFF != ctl)
{
output[dst++] = (byte)ctl;
}
else
{
ctl = input.ReadByte();
if (-1 == ctl)
return false;
if (0xFF == ctl)
{
output[dst++] = 0xFF;
}
else
{
int offset = (ctl >> 2) + 1;
int count = (ctl & 3) + 3;
Binary.CopyOverlapped (output, dst-offset, dst, count);
dst += count;
}
}
}
return true;
}
} }
internal sealed class DetIndexReader internal sealed class DetIndexReader