Merge branch 'master' of bitbucket.org:Regalis11/barotrauma
This commit is contained in:
@@ -1471,7 +1471,7 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
|
||||
float similarity = 0;
|
||||
similarity += sender.ChatSpamSpeed; //the faster messages are being sent, the faster the filter will block
|
||||
similarity += sender.ChatSpamSpeed * 0.05f; //the faster messages are being sent, the faster the filter will block
|
||||
for (int i = 0; i < sender.ChatMessages.Count; i++)
|
||||
{
|
||||
float closeFactor = 1.0f / (20.0f - i);
|
||||
|
||||
@@ -365,6 +365,35 @@ namespace Barotrauma
|
||||
|
||||
return inputType;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the minimum number of single-character edits (i.e. insertions, deletions or substitutions) required to change one string into the other
|
||||
/// </summary>
|
||||
public static int LevenshteinDistance(string s, string t)
|
||||
{
|
||||
int n = s.Length;
|
||||
int m = t.Length;
|
||||
int[,] d = new int[n + 1, m + 1];
|
||||
|
||||
if (n == 0 || m == 0) return 0;
|
||||
|
||||
for (int i = 0; i <= n; d[i, 0] = i++);
|
||||
for (int j = 0; j <= m; d[0, j] = j++);
|
||||
|
||||
for (int i = 1; i <= n; i++)
|
||||
{
|
||||
for (int j = 1; j <= m; j++)
|
||||
{
|
||||
int cost = (t[j - 1] == s[i - 1]) ? 0 : 1;
|
||||
|
||||
d[i, j] = Math.Min(
|
||||
Math.Min(d[i - 1, j] + 1, d[i, j - 1] + 1),
|
||||
d[i - 1, j - 1] + cost);
|
||||
}
|
||||
}
|
||||
|
||||
return d[n, m];
|
||||
}
|
||||
|
||||
public static string WrapText(string text, float lineLength, SpriteFont font)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user