Ver Fonte

bumped version, applied rich tech handling fix

scrublord há 6 anos atrás
pai
commit
c95f883695

+ 5 - 1
CHANGELOG.md

@@ -1,4 +1,8 @@
-### 2.14.0
+### 2.14.1
+ * BUG FIX - Never allow text to be queued for translation before stabilization check for rich text 
+ * MISC - Improved a spam detection check
+
+### 2.14.0
  * FEATURE - Dramatically improved the text hooking capability for NGUI to much better handle static elements
 
 ### 2.13.1

+ 1 - 1
src/XUnity.AutoTranslator.Patcher/Patcher.cs

@@ -29,7 +29,7 @@ namespace XUnity.AutoTranslator.Patcher
       {
          get
          {
-            return "2.14.0";
+            return "2.14.1";
          }
       }
 

+ 1 - 1
src/XUnity.AutoTranslator.Plugin.BepIn/XUnity.AutoTranslator.Plugin.BepIn.csproj

@@ -2,7 +2,7 @@
 
    <PropertyGroup>
       <TargetFramework>net35</TargetFramework>
-      <Version>2.14.0</Version>
+      <Version>2.14.1</Version>
    </PropertyGroup>
 
    <ItemGroup>

+ 35 - 18
src/XUnity.AutoTranslator.Plugin.Core/AutoTranslationPlugin.cs

@@ -100,7 +100,8 @@ namespace XUnity.AutoTranslator.Plugin.Core
       private int _availableBatchOperations = Settings.MaxAvailableBatchOperations;
       private float _batchOperationSecondCounter = 0;
 
-      private string _previouslyQueuedText = null;
+      private string[] _previouslyQueuedText = new string[ Settings.PreviousTextStaggerCount ];
+      private int _staggerTextCursor = 0;
       private int _concurrentStaggers = 0;
 
       private int _frameForLastQueuedTranslation = -1;
@@ -457,28 +458,44 @@ namespace XUnity.AutoTranslator.Plugin.Core
 
       private void CheckStaggerText( string untranslatedText )
       {
-         if( _previouslyQueuedText != null )
+         bool wasProblematic = false;
+
+         for( int i = 0 ; i < _previouslyQueuedText.Length ; i++ )
          {
-            if( untranslatedText.StartsWith( _previouslyQueuedText ) )
+            var previouslyQueuedText = _previouslyQueuedText[ i ];
+
+            if( previouslyQueuedText != null )
             {
-               _concurrentStaggers++;
-               if( _concurrentStaggers > Settings.MaximumStaggers )
+               if( untranslatedText.StartsWith( previouslyQueuedText ) || previouslyQueuedText.StartsWith( untranslatedText )
+                  || untranslatedText.EndsWith( previouslyQueuedText ) || previouslyQueuedText.EndsWith( untranslatedText ) )
                {
-                  _unstartedJobs.Clear();
-                  _completedJobs.Clear();
-                  _ongoingJobs.Clear();
-
-                  Settings.IsShutdown = true;
-                  Logger.Current.Error( $"SPAM DETECTED: Text that is 'scrolling in' is being translated. Disable that feature. Shutting down plugin." );
+                  wasProblematic = true;
+                  break;
                }
+
             }
-            else
+         }
+
+         if( wasProblematic )
+         {
+            _concurrentStaggers++;
+            if( _concurrentStaggers > Settings.MaximumStaggers )
             {
-               _concurrentStaggers = 0;
-            }
+               _unstartedJobs.Clear();
+               _completedJobs.Clear();
+               _ongoingJobs.Clear();
 
+               Settings.IsShutdown = true;
+               Logger.Current.Error( $"SPAM DETECTED: Text that is 'scrolling in' is being translated. Disable that feature. Shutting down plugin." );
+            }
          }
-         _previouslyQueuedText = untranslatedText;
+         else
+         {
+            _concurrentStaggers = 0;
+         }
+
+         _previouslyQueuedText[ _staggerTextCursor % _previouslyQueuedText.Length ] = untranslatedText;
+         _staggerTextCursor++;
       }
 
       private void CheckThresholds()
@@ -873,12 +890,12 @@ namespace XUnity.AutoTranslator.Plugin.Core
                      var result = parser.Parse( text );
                      if( result.HasRichSyntax )
                      {
-                        translation = TranslateOrQueueWebJobImmediateByParserResult( ui, result, true );
+                        translation = TranslateOrQueueWebJobImmediateByParserResult( ui, result, false );
                         if( translation != null )
                         {
-                           SetTranslatedText( ui, translation, info ); // get rid of textKey here!!
+                           SetTranslatedText( ui, translation, info );
+                           return translation;
                         }
-                        return translation;
                      }
                   }
                }

+ 1 - 0
src/XUnity.AutoTranslator.Plugin.Core/Configuration/Settings.cs

@@ -22,6 +22,7 @@ namespace XUnity.AutoTranslator.Plugin.Core.Configuration
       public static readonly float IncreaseBatchOperationsEvery = 30;
       public static readonly bool EnableObjectTracking = true;
       public static readonly int MaximumStaggers = 6;
+      public static readonly int PreviousTextStaggerCount = 3;
       public static readonly int MaximumConsecutiveFramesTranslated = 90;
       public static readonly int MaximumConsecutiveSecondsTranslated = 60;
       public static bool UsesWhitespaceBetweenWords = false;

+ 1 - 1
src/XUnity.AutoTranslator.Plugin.Core/Constants/PluginData.cs

@@ -11,6 +11,6 @@ namespace XUnity.AutoTranslator.Plugin.Core.Constants
 
       public const string Name = "XUnity Auto Translator";
 
-      public const string Version = "2.14.0";
+      public const string Version = "2.14.1";
    }
 }

+ 1 - 1
src/XUnity.AutoTranslator.Plugin.Core/XUnity.AutoTranslator.Plugin.Core.csproj

@@ -2,7 +2,7 @@
 
    <PropertyGroup>
       <TargetFramework>net35</TargetFramework>
-      <Version>2.14.0</Version>
+      <Version>2.14.1</Version>
    </PropertyGroup>
 
    <ItemGroup>

+ 1 - 1
src/XUnity.AutoTranslator.Plugin.IPA/XUnity.AutoTranslator.Plugin.IPA.csproj

@@ -2,7 +2,7 @@
 
    <PropertyGroup>
       <TargetFramework>net35</TargetFramework>
-      <Version>2.14.0</Version>
+      <Version>2.14.1</Version>
    </PropertyGroup>
 
    <ItemGroup>

+ 1 - 1
src/XUnity.AutoTranslator.Plugin.UnityInjector/XUnity.AutoTranslator.Plugin.UnityInjector.csproj

@@ -2,7 +2,7 @@
 
    <PropertyGroup>
       <TargetFramework>net35</TargetFramework>
-      <Version>2.14.0</Version>
+      <Version>2.14.1</Version>
    </PropertyGroup>
 
    <ItemGroup>

+ 1 - 1
src/XUnity.AutoTranslator.Setup/XUnity.AutoTranslator.Setup.csproj

@@ -4,7 +4,7 @@
       <OutputType>Exe</OutputType>
       <TargetFramework>net40</TargetFramework>
       <AssemblyName>SetupReiPatcherAndAutoTranslator</AssemblyName>
-      <Version>2.14.0</Version>
+      <Version>2.14.1</Version>
    </PropertyGroup>
 
    <ItemGroup>