Merge pull request #1 from Escartem/main

Fixes
This commit is contained in:
yarik0chka
2024-05-01 19:33:35 +05:00
committed by GitHub
3 changed files with 61 additions and 28 deletions

View File

@@ -85,7 +85,7 @@ namespace AssetStudio.GUI
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
InitializeComponent();
Text = $"YarikStudio v{Application.ProductVersion}";
Text = $"Studio v{Application.ProductVersion}";
InitializeExportOptions();
InitializeProgressBar();
InitializeLogger();
@@ -308,7 +308,7 @@ namespace AssetStudio.GUI
}
}
Text = $"YarikStudio v{Application.ProductVersion} - {productName} - {assetsManager.assetsFileList[0].unityVersion} - {assetsManager.assetsFileList[0].m_TargetPlatform}";
Text = $"Studio v{Application.ProductVersion} - {productName} - {assetsManager.assetsFileList[0].unityVersion} - {assetsManager.assetsFileList[0].m_TargetPlatform}";
assetListView.VirtualListSize = visibleAssets.Count;
@@ -1484,7 +1484,7 @@ namespace AssetStudio.GUI
public void ResetForm()
{
Text = $"YarikStudio v{Application.ProductVersion}";
Text = $"Studio v{Application.ProductVersion}";
assetsManager.Clear();
assemblyLoader.Clear();
exportableAssets.Clear();

View File

@@ -304,9 +304,18 @@ namespace AssetStudio.GUI
var preloadIndex = m_Container.Value.preloadIndex;
var preloadSize = m_Container.Value.preloadSize;
var preloadEnd = preloadIndex + preloadSize;
for (int k = preloadIndex; k < preloadEnd; k++)
switch(preloadIndex)
{
containers.Add((m_AssetBundle.m_PreloadTable[k], m_Container.Key));
case int n when n < 0:
Logger.Warning($"preloadIndex {preloadIndex} is out of preloadTable range");
break;
default:
for (int k = preloadIndex; k < preloadEnd; k++)
{
containers.Add((m_AssetBundle.m_PreloadTable[k], m_Container.Key));
}
break;
}
}
}

View File

@@ -8,7 +8,6 @@ namespace AssetStudio
{
public class OffsetStream : Stream
{
private readonly Stream _baseStream;
private long _offset;
@@ -81,34 +80,59 @@ namespace AssetStudio
else
{
using var reader = new FileReader(path, this, true);
var signature = reader.FileType switch
{
FileType.BundleFile => "UnityFS\x00",
FileType.MhyFile => "mhy",
FileType.Blb3File => "Blb\x03",
_ => throw new InvalidOperationException()
};
Logger.Verbose($"Parsed signature: {signature}");
var readSignature = reader.FileType;
var signature = "";
var signatureBytes = Encoding.UTF8.GetBytes(signature);
var buffer = ArrayPool<byte>.Shared.Rent((int)reader.Length);
while (Remaining > 0)
if (readSignature == FileType.BundleFile ||
readSignature == FileType.MhyFile ||
readSignature == FileType.Blb3File)
{
var index = 0;
var absOffset = AbsolutePosition;
var read = Read(buffer);
while (index < read)
switch (reader.FileType)
{
index = buffer.AsSpan(0, read).Search(signatureBytes, index);
if (index == -1) break;
var offset = absOffset + index;
Offset = offset;
yield return offset;
index++;
case FileType.BundleFile:
signature = "UnityFS\x00";
break;
case FileType.MhyFile:
signature = "mhy";
break;
case FileType.Blb3File:
signature = "Blb\x03";
break;
}
Logger.Verbose($"Parsed signature: {signature}");
var signatureBytes = Encoding.UTF8.GetBytes(signature);
var buffer = ArrayPool<byte>.Shared.Rent((int)reader.Length);
while (Remaining > 0)
{
var index = 0;
var absOffset = AbsolutePosition;
var read = Read(buffer);
while (index < read)
{
index = buffer.AsSpan(0, read).Search(signatureBytes, index);
if (index == -1) break;
var offset = absOffset + index;
Offset = offset;
yield return offset;
index++;
}
}
ArrayPool<byte>.Shared.Return(buffer);
} else
{
while (Remaining > 0)
{
Offset = AbsolutePosition;
yield return AbsolutePosition;
if (Offset == AbsolutePosition)
{
break;
}
}
}
ArrayPool<byte>.Shared.Return(buffer);
}
}
}