Skip to content

Commit

Permalink
star rail 2.7 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Escartem committed Dec 4, 2024
1 parent e41996d commit 1a482d7
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 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
39 changes: 39 additions & 0 deletions AssetStudio/BundleFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public enum CompressionType
Zstd = 5,
Lz4Lit4 = 4,
Lz4Lit5 = 5,
OodleHSR = 6,
OodleMr0k = 7,
Oodle = 9,
}

Expand Down Expand Up @@ -555,6 +557,43 @@ private void ReadBlocks(FileReader reader, Stream blocksStream)
compressedStream = ms;
}
SevenZipHelper.StreamDecompress(compressedStream, blocksStream, blockInfo.compressedSize, blockInfo.uncompressedSize);
break;
}
case CompressionType.OodleHSR:
case CompressionType.OodleMr0k:
{
// Star Rail v2.7 fix, thanks to Yarik
var compressedSize = (int)blockInfo.compressedSize;
var uncompressedSize = (int)blockInfo.uncompressedSize;

var compressedBytes = ArrayPool<byte>.Shared.Rent(compressedSize);
var uncompressedBytes = ArrayPool<byte>.Shared.Rent(uncompressedSize);

var compressedBytesSpan = compressedBytes.AsSpan(0, compressedSize);
var uncompressedBytesSpan = uncompressedBytes.AsSpan(0, uncompressedSize);

try
{
reader.Read(compressedBytesSpan);
if (compressionType == CompressionType.OodleMr0k && Mr0kUtils.IsMr0k(compressedBytes))
{
Logger.Verbose($"Block encrypted with mr0k, decrypting...");
compressedBytesSpan = Mr0kUtils.Decrypt(compressedBytesSpan, (Mr0k)Game);
}

var numWrite = OodleHelper.Decompress(compressedBytesSpan, uncompressedBytesSpan);
if (numWrite != uncompressedSize)
{
Logger.Warning($"Oodle decompression error, write {numWrite} bytes but expected {uncompressedSize} bytes");
}
}
finally
{
blocksStream.Write(uncompressedBytesSpan);
ArrayPool<byte>.Shared.Return(compressedBytes, true);
ArrayPool<byte>.Shared.Return(uncompressedBytes, true);
}

break;
}
case CompressionType.Lz4: //LZ4
Expand Down

0 comments on commit 1a482d7

Please sign in to comment.