Skip to content

Commit

Permalink
Merge pull request #1 from Escartem/main
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
yarik0chka authored May 1, 2024
2 parents 054df3b + 494d005 commit fa7512f
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 27 deletions.
6 changes: 3 additions & 3 deletions AssetStudio.GUI/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public MainForm()
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
InitializeComponent();
Text = $"YarikStudio v{Application.ProductVersion}";
Text = $"Studio v{Application.ProductVersion}";
InitializeExportOptions();
InitializeProgressBar();
InitializeLogger();
Expand Down Expand Up @@ -308,7 +308,7 @@ private async void BuildAssetStructures()
}
}

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;

Expand Down Expand Up @@ -1484,7 +1484,7 @@ private void StatusStripUpdate(string statusText)

public void ResetForm()
{
Text = $"YarikStudio v{Application.ProductVersion}";
Text = $"Studio v{Application.ProductVersion}";
assetsManager.Clear();
assemblyLoader.Clear();
exportableAssets.Clear();
Expand Down
13 changes: 11 additions & 2 deletions AssetStudio.GUI/Studio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,18 @@ public static (string, List<TreeNode>) BuildAssetData()
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;
}
}
}
Expand Down
68 changes: 46 additions & 22 deletions AssetStudio/OffsetStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ namespace AssetStudio
{
public class OffsetStream : Stream
{

private readonly Stream _baseStream;
private long _offset;

Expand Down Expand Up @@ -81,34 +80,59 @@ public IEnumerable<long> GetOffsets(string path)
else
{
using var reader = new FileReader(path, this, true);
var signature = reader.FileType switch

var readSignature = reader.FileType;
var signature = "";

if (readSignature == FileType.BundleFile ||
readSignature == FileType.MhyFile ||
readSignature == FileType.Blb3File)
{
FileType.BundleFile => "UnityFS\x00",
FileType.MhyFile => "mhy",
FileType.Blb3File => "Blb\x03",
_ => throw new InvalidOperationException()
};
switch (reader.FileType)
{
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}");
Logger.Verbose($"Parsed signature: {signature}");

var signatureBytes = Encoding.UTF8.GetBytes(signature);
var buffer = ArrayPool<byte>.Shared.Rent((int)reader.Length);
while (Remaining > 0)
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
{
var index = 0;
var absOffset = AbsolutePosition;
var read = Read(buffer);
while (index < read)
while (Remaining > 0)
{
index = buffer.AsSpan(0, read).Search(signatureBytes, index);
if (index == -1) break;
var offset = absOffset + index;
Offset = offset;
yield return offset;
index++;
Offset = AbsolutePosition;
yield return AbsolutePosition;
if (Offset == AbsolutePosition)
{
break;
}
}
}
ArrayPool<byte>.Shared.Return(buffer);
}
}
}
Expand Down

0 comments on commit fa7512f

Please sign in to comment.