Scrublord1336 vor 6 Jahren
Ursprung
Commit
b32bb83c5b

+ 30 - 1
src/XUnity.AutoTranslator.Plugin.Core/AutoTranslationPlugin.cs

@@ -97,6 +97,8 @@ namespace XUnity.AutoTranslator.Plugin.Core
 
       private int _availableBatchOperations = Settings.MaxAvailableBatchOperations;
       private float _batchOperationSecondCounter = 0;
+      private string _previouslyQueuedText = null;
+      private int _concurrentStaggers = 0;
       private int _frameForLastQueuedTranslation = -1;
       private int _consecutiveFramesQueued = 0;
 
@@ -325,6 +327,7 @@ namespace XUnity.AutoTranslator.Plugin.Core
 
          _unstartedJobs.Add( lookupKey, ongoingJob );
 
+         CheckStaggerText( lookupKey );
          CheckConsecutiveFrames();
          CheckThresholds();
 
@@ -366,6 +369,32 @@ namespace XUnity.AutoTranslator.Plugin.Core
          _frameForLastQueuedTranslation = currentFrame;
       }
 
+      private void CheckStaggerText( string untranslatedText )
+      {
+         if( _previouslyQueuedText != null )
+         {
+            if( untranslatedText.StartsWith( _previouslyQueuedText ) )
+            {
+               _concurrentStaggers++;
+               if( _concurrentStaggers > Settings.MaximumStaggers )
+               {
+                  _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." );
+               }
+            }
+            else
+            {
+               _concurrentStaggers = 0;
+            }
+
+         }
+         _previouslyQueuedText = untranslatedText;
+      }
+
       private void CheckThresholds()
       {
          if( _unstartedJobs.Count > Settings.MaxUnstartedJobs )
@@ -373,8 +402,8 @@ namespace XUnity.AutoTranslator.Plugin.Core
             _unstartedJobs.Clear();
             _completedJobs.Clear();
             _ongoingJobs.Clear();
-            Settings.IsShutdown = true;
 
+            Settings.IsShutdown = true;
             Logger.Current.Error( $"SPAM DETECTED: More than {Settings.MaxUnstartedJobs} queued for translations due to unknown reasons. Shutting down plugin." );
          }
 

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

@@ -18,6 +18,7 @@ namespace XUnity.AutoTranslator.Plugin.Core.Configuration
       public static readonly int MaxUnstartedJobs = 3500;
       public static readonly float IncreaseBatchOperationsEvery = 30;
       public static readonly bool EnableObjectTracking = true;
+      public static readonly int MaximumStaggers = 5;
       public static readonly int MaximumConcurrentFrameTranslations = 60;
 
       public static bool IsShutdown = false;