Skip to content

Commit

Permalink
bumped version, applied rich tech handling fix
Browse files Browse the repository at this point in the history
  • Loading branch information
scrublord committed Sep 1, 2018
1 parent 0558622 commit c95f883
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 26 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/XUnity.AutoTranslator.Patcher/Patcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public override string Version
{
get
{
return "2.14.0";
return "2.14.1";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net35</TargetFramework>
<Version>2.14.0</Version>
<Version>2.14.1</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
53 changes: 35 additions & 18 deletions src/XUnity.AutoTranslator.Plugin.Core/AutoTranslationPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ public class AutoTranslationPlugin : MonoBehaviour
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;
Expand Down Expand Up @@ -457,28 +458,44 @@ public void PeriodicResetFrameCheck()

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()
Expand Down Expand Up @@ -873,12 +890,12 @@ private string TranslateOrQueueWebJobImmediate( object ui, string text, Translat
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;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static class Settings
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public static class PluginData

public const string Name = "XUnity Auto Translator";

public const string Version = "2.14.0";
public const string Version = "2.14.1";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net35</TargetFramework>
<Version>2.14.0</Version>
<Version>2.14.1</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net35</TargetFramework>
<Version>2.14.0</Version>
<Version>2.14.1</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net35</TargetFramework>
<Version>2.14.0</Version>
<Version>2.14.1</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit c95f883

Please sign in to comment.