From ab5e82dfc79bfc32eb86fd2f235a5527e7c750b4 Mon Sep 17 00:00:00 2001 From: randoman <738b86bb93c44695854182cc459afcbb@lonestar.no> Date: Sun, 1 Dec 2019 17:40:09 +0100 Subject: [PATCH] Version 4.7.1 (Auto Translator) * BUG FIX - Development-time fix to the nuget package * BUG FIX - The 'Translators' directory must now be placed in the same directory that the XUnity.AutoTranslator.Plugin.Core.dll is placed in. This allows moving around the plugin as you see fit in BepInEx 5.0. For the ReiPatcher installer, the Translators are now found in the Managed directory of the game. For UnityInjector the Translators directory has been moved out of the Config directory * BUG FIX - Minor bug fix where in some cases the plugin could not create the initial translation files on startup Version 1.1.1 (Resource Redirector) * 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 --- CHANGELOG - ResourceRedirector.md | 1 + .../TranslationManager.cs | 3 +++ src/XUnity.ResourceRedirector/AssetBundleHelper.cs | 12 +++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) 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." );