- [Core] Fix bug with assets parsing.

This commit is contained in:
Razmoth
2023-11-24 21:17:13 +04:00
parent 2568e4be08
commit 4c0f1ec44b
45 changed files with 725 additions and 672 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -8,11 +9,11 @@ namespace AssetStudio
{
private const uint DefaultUncompressedSize = 0x20000;
private BundleFile.StorageBlock[] m_BlocksInfo;
private BundleFile.Node[] m_DirectoryInfo;
private List<BundleFile.StorageBlock> m_BlocksInfo;
private List<BundleFile.Node> m_DirectoryInfo;
public BundleFile.Header m_Header;
public StreamFile[] fileList;
public List<StreamFile> fileList;
public long Offset;
@@ -68,30 +69,30 @@ namespace AssetStudio
var bundleInfoOffset = reader.Position + reader.ReadInt64();
reader.Position = blocksInfoOffset;
m_BlocksInfo = new BundleFile.StorageBlock[blocksInfoCount];
m_BlocksInfo = new List<BundleFile.StorageBlock>();
Logger.Verbose($"Blocks count: {blocksInfoCount}");
for (int i = 0; i < blocksInfoCount; i++)
{
m_BlocksInfo[i] = new BundleFile.StorageBlock
m_BlocksInfo.Add(new BundleFile.StorageBlock
{
compressedSize = reader.ReadUInt32(),
uncompressedSize = i == blocksInfoCount - 1 ? lastUncompressedSize : DefaultUncompressedSize,
flags = (StorageBlockFlags)0x43
};
});
Logger.Verbose($"Block {i} Info: {m_BlocksInfo[i]}");
}
reader.Position = nodesInfoOffset;
m_DirectoryInfo = new BundleFile.Node[nodesCount];
m_DirectoryInfo = new List<BundleFile.Node>();
Logger.Verbose($"Directory count: {nodesCount}");
for (int i = 0; i < nodesCount; i++)
{
m_DirectoryInfo[i] = new BundleFile.Node
m_DirectoryInfo.Add(new BundleFile.Node
{
offset = reader.ReadInt32(),
size = reader.ReadInt32()
};
});
var pathOffset = reader.Position + reader.ReadInt64();
@@ -146,12 +147,12 @@ namespace AssetStudio
{
Logger.Verbose($"Writing files from blocks stream...");
fileList = new StreamFile[m_DirectoryInfo.Length];
for (int i = 0; i < m_DirectoryInfo.Length; i++)
fileList = new List<StreamFile>();
for (int i = 0; i < m_DirectoryInfo.Count; i++)
{
var node = m_DirectoryInfo[i];
var file = new StreamFile();
fileList[i] = file;
fileList.Add(file);
file.path = node.path;
file.fileName = Path.GetFileName(node.path);
if (node.size >= int.MaxValue)