Skip to content

Commit

Permalink
U8 processes directorys reliably
Browse files Browse the repository at this point in the history
  • Loading branch information
Venomalia committed Dec 15, 2023
1 parent 01a924a commit 53811a2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/AuroraLip/Archives/Formats/U8.cs
Expand Up @@ -44,15 +44,15 @@ protected override void Read(Stream stream)
//Read Nods
stream.Seek(nodeTableOffset, SeekOrigin.Begin);
U8Node rootNode = stream.Read<U8Node>(Endian.Big);
using SpanBuffer<U8Node> nodes = new(rootNode.Size - 1);
stream.Read(nodes.Span, Endian.Big);
using SpanBuffer<U8Node> nodes = new(rootNode.Size);
stream.Read(nodes.Span[1..], Endian.Big);

long StringTableOffset = nodeTableOffset + (rootNode.Size * 0x0C);
Root = new ArchiveDirectory() { Name = "root", OwnerArchive = this };
List<ArchiveDirectory> directorys = new() { Root };
Dictionary<int, ArchiveDirectory> directorys = new() { { 0, Root } };
Stack<Tuple<ArchiveDirectory, int>> stack = new();
stack.Push(new(Root, nodes.Length));
for (int i = 0; i < nodes.Length; i++)
for (int i = 1; i < nodes.Length; i++)
{
U8Node node = nodes[i];
stream.Seek(StringTableOffset + node.NameOffset, SeekOrigin.Begin);
Expand All @@ -63,12 +63,11 @@ protected override void Read(Stream stream)
{
name = $"{Path.GetFileNameWithoutExtension(name.AsSpan())}_{i}{Path.GetExtension(name.AsSpan())}";
}

if (node.IsDirectory)
{
ArchiveDirectory dir = new() { OwnerArchive = this, Parent = directorys[node.Offset], Name = name };
directorys[node.Offset].Items.Add(name, dir);
directorys.Add(dir);
directorys.Add(i, dir);
stack.Push(new(dir, node.Size));
}
else
Expand Down

0 comments on commit 53811a2

Please sign in to comment.