diff --git a/CHANGELOG - ResourceRedirector.md b/CHANGELOG - ResourceRedirector.md index 12d2235e..b7efcfc8 100644 --- a/CHANGELOG - ResourceRedirector.md +++ b/CHANGELOG - ResourceRedirector.md @@ -1,5 +1,6 @@ ### 1.1.1 * BUG FIX - Development-time fix to the nuget package + * BUG FIX - Fixed bug in method 'LoadFromFileWithRandomizedCabIfRequired' where offset was ignored if the initial load attempt failed ### 1.1.0 * FEATURE - Added method to load an asset from a file, with fallback to loading it from an in-memory stream with randomized CAB diff --git a/src/XUnity.AutoTranslator.Plugin.Core/TranslationManager.cs b/src/XUnity.AutoTranslator.Plugin.Core/TranslationManager.cs index 83c4402c..60174794 100644 --- a/src/XUnity.AutoTranslator.Plugin.Core/TranslationManager.cs +++ b/src/XUnity.AutoTranslator.Plugin.Core/TranslationManager.cs @@ -116,6 +116,9 @@ public void CreateEndpoints( GameObject go, InitializationContext context ) else { XuaLogger.AutoTranslator.Warn( "AutoTranslator has been configured to use same destination language as source language. All translators will be disabled!" ); + + //// add built-in endpoint + //AddEndpoint( go, context, typeof( PassthroughTranslateEndpoint ) ); } } diff --git a/src/XUnity.ResourceRedirector/AssetBundleHelper.cs b/src/XUnity.ResourceRedirector/AssetBundleHelper.cs index a7707725..4e6e369e 100644 --- a/src/XUnity.ResourceRedirector/AssetBundleHelper.cs +++ b/src/XUnity.ResourceRedirector/AssetBundleHelper.cs @@ -1,5 +1,6 @@ using System.IO; using UnityEngine; +using XUnity.Common.Extensions; using XUnity.Common.Logging; using XUnity.Common.Utilities; @@ -95,7 +96,16 @@ internal static AssetBundle LoadFromFileWithRandomizedCabIfRequired( string path var bundle = AssetBundle.LoadFromFile( path, crc, offset ); if( bundle == null && ( !confirmFileExists || File.Exists( path ) ) ) { - var buffer = File.ReadAllBytes( path ); + byte[] buffer; + using( var stream = new FileStream( path, FileMode.Open, FileAccess.Read ) ) + { + var fullLength = stream.Length; + var longOffset = (long)offset; + var lengthToRead = fullLength - longOffset; + stream.Seek( longOffset, SeekOrigin.Begin ); + buffer = stream.ReadFully( (int)lengthToRead ); + } + CabHelper.RandomizeCabWithAnyLength( buffer ); XuaLogger.ResourceRedirector.Warn( $"Randomized CAB for '{path}' in order to load it because another asset bundle already uses its CAB-string. You can ignore the previous error message, but this is likely caused by two mods incorrectly using the same CAB-string." );