Release 1.10.7.2 - Autumn Update 2025 Hotfix 4
This commit is contained in:
+48
-16
@@ -27,6 +27,10 @@ namespace Barotrauma
|
||||
|
||||
private DateTime lastRefreshTime = DateTime.Now;
|
||||
|
||||
// Cache for spam-filtered servers to avoid re-checking on every filter change
|
||||
private readonly HashSet<string> spamServerCache = new HashSet<string>();
|
||||
private readonly Dictionary<string, string> serverInfoStringCache = new Dictionary<string, string>();
|
||||
|
||||
private GUIFrame menu;
|
||||
|
||||
private GUIListBox serverList;
|
||||
@@ -1013,7 +1017,6 @@ namespace Barotrauma
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
if (SpamServerFilters.IsFiltered(serverInfo)) { return false; }
|
||||
|
||||
if (!string.IsNullOrEmpty(searchBox.Text) && !serverInfo.ServerName.Contains(searchBox.Text, StringComparison.OrdinalIgnoreCase)) { return false; }
|
||||
|
||||
@@ -1216,6 +1219,11 @@ namespace Barotrauma
|
||||
|
||||
PingUtils.QueryPingData();
|
||||
|
||||
// Clear spam server cache to allow re-checking servers (user might have changed filters)
|
||||
spamServerCache.Clear();
|
||||
// Also clear server info string cache when manually refreshing, just so we don't end up with broken data in any situation
|
||||
serverInfoStringCache.Clear();
|
||||
|
||||
tabs[TabEnum.All].Clear();
|
||||
serverList.ClearChildren();
|
||||
serverPreview.Content.ClearChildren();
|
||||
@@ -1328,26 +1336,21 @@ namespace Barotrauma
|
||||
if (serverInfo.PlayerCount > serverInfo.MaxPlayers + 1) { return; }
|
||||
if (serverInfo.PlayerCount < 0) { return; }
|
||||
if (serverInfo.MaxPlayers <= 0) { return; }
|
||||
if (!serverInfo.SelectedSub.IsNullOrEmpty())
|
||||
{
|
||||
if (serverInfo.SelectedSub.Length > SubmarineInfo.MaxNameLength) { return; }
|
||||
}
|
||||
//no way a legit server can have this many players
|
||||
if (serverInfo.MaxPlayers > MaxAllowedPlayers) { return; }
|
||||
|
||||
int similarServerCount = 0;
|
||||
string serverInfoStr = getServerInfoStr(serverInfo);
|
||||
foreach (var serverElement in serverList.Content.Children)
|
||||
// Check spam filter with caching to avoid re-checking on every filter change
|
||||
string serverCacheKey = serverInfo.Endpoints.First().StringRepresentation;
|
||||
if (spamServerCache.Contains(serverCacheKey)) { return; }
|
||||
if (SpamServerFilters.IsFiltered(serverInfo))
|
||||
{
|
||||
if (!serverElement.Visible) { continue; }
|
||||
if (serverElement.UserData is not ServerInfo otherServer || otherServer == serverInfo) { continue; }
|
||||
if (ToolBox.LevenshteinDistance(serverInfoStr, getServerInfoStr(otherServer)) < serverInfoStr.Length * (1.0f - MinSimilarityPercentage))
|
||||
{
|
||||
similarServerCount++;
|
||||
if (similarServerCount > MaxAllowedSimilarServers)
|
||||
{
|
||||
DebugConsole.Log($"Server {serverInfo.ServerName} seems to be almost identical to {otherServer.ServerName}. Hiding as a potential spam server.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
spamServerCache.Add(serverCacheKey);
|
||||
return;
|
||||
}
|
||||
if (similarServerCount > MaxAllowedSimilarServers) { return; }
|
||||
|
||||
static string getServerInfoStr(ServerInfo serverInfo)
|
||||
{
|
||||
@@ -1356,6 +1359,35 @@ namespace Barotrauma
|
||||
return str;
|
||||
}
|
||||
|
||||
string getCachedServerInfoStr(ServerInfo serverInfo)
|
||||
{
|
||||
string cacheKey = serverInfo.Endpoints.First().StringRepresentation;
|
||||
if (!serverInfoStringCache.TryGetValue(cacheKey, out string cachedStr))
|
||||
{
|
||||
cachedStr = getServerInfoStr(serverInfo);
|
||||
serverInfoStringCache[cacheKey] = cachedStr;
|
||||
}
|
||||
return cachedStr;
|
||||
}
|
||||
|
||||
int similarServerCount = 0;
|
||||
string serverInfoStr = getServerInfoStr(serverInfo);
|
||||
foreach (var serverElement in serverList.Content.Children)
|
||||
{
|
||||
if (!serverElement.Visible) { continue; }
|
||||
if (serverElement.UserData is not ServerInfo otherServer || otherServer == serverInfo) { continue; }
|
||||
if (ToolBox.LevenshteinDistance(serverInfoStr, getCachedServerInfoStr(otherServer)) < serverInfoStr.Length * (1.0f - MinSimilarityPercentage))
|
||||
{
|
||||
similarServerCount++;
|
||||
if (similarServerCount > MaxAllowedSimilarServers)
|
||||
{
|
||||
DebugConsole.Log($"Server {serverInfo.ServerName} seems to be almost identical to {otherServer.ServerName}. Hiding as a potential spam server.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (similarServerCount > MaxAllowedSimilarServers) { return; }
|
||||
|
||||
RemoveMsgFromServerList(MsgUserData.RefreshingServerList);
|
||||
RemoveMsgFromServerList(MsgUserData.NoServers);
|
||||
var serverFrame = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.06f), serverList.Content.RectTransform) { MinSize = new Point(0, 35) },
|
||||
|
||||
@@ -338,10 +338,7 @@ namespace Barotrauma
|
||||
private GUIImage previewImage;
|
||||
private GUILayoutGroup previewImageButtonHolder;
|
||||
|
||||
private const int submarineNameLimit = 30;
|
||||
private GUITextBlock submarineNameCharacterCount;
|
||||
|
||||
private const int submarineDescriptionLimit = 500;
|
||||
private GUITextBlock submarineDescriptionCharacterCount;
|
||||
|
||||
private Mode mode;
|
||||
@@ -2304,20 +2301,19 @@ namespace Barotrauma
|
||||
};
|
||||
nameBox.OnTextChanged += (textBox, text) =>
|
||||
{
|
||||
if (text.Length > submarineNameLimit)
|
||||
if (text.Length > SubmarineInfo.MaxNameLength)
|
||||
{
|
||||
nameBox.Text = text.Substring(0, submarineNameLimit);
|
||||
nameBox.Text = text.Substring(0, SubmarineInfo.MaxNameLength);
|
||||
nameBox.Flash(GUIStyle.Red);
|
||||
return true;
|
||||
}
|
||||
|
||||
submarineNameCharacterCount.Text = text.Length + " / " + submarineNameLimit;
|
||||
submarineNameCharacterCount.Text = text.Length + " / " + SubmarineInfo.MaxNameLength;
|
||||
return true;
|
||||
};
|
||||
|
||||
nameBox.Text = MainSub?.Info.Name ?? "";
|
||||
|
||||
submarineNameCharacterCount.Text = nameBox.Text.Length + " / " + submarineNameLimit;
|
||||
submarineNameCharacterCount.Text = nameBox.Text.Length + " / " + SubmarineInfo.MaxNameLength;
|
||||
|
||||
var descriptionHeaderGroup = new GUILayoutGroup(new RectTransform(new Vector2(.975f, 0.03f), leftColumn.RectTransform), isHorizontal: true);
|
||||
|
||||
@@ -2333,9 +2329,9 @@ namespace Barotrauma
|
||||
|
||||
descriptionBox.OnTextChanged += (textBox, text) =>
|
||||
{
|
||||
if (text.Length > submarineDescriptionLimit)
|
||||
if (text.Length > SubmarineInfo.MaxDescriptionLength)
|
||||
{
|
||||
descriptionBox.Text = text.Substring(0, submarineDescriptionLimit);
|
||||
descriptionBox.Text = text.Substring(0, SubmarineInfo.MaxDescriptionLength);
|
||||
descriptionBox.Flash(GUIStyle.Red);
|
||||
return true;
|
||||
}
|
||||
@@ -3439,7 +3435,7 @@ namespace Barotrauma
|
||||
enemySubmarineSettingsContainer.Recalculate();
|
||||
|
||||
descriptionBox.Text = MainSub == null ? "" : MainSub.Info.Description.Value;
|
||||
submarineDescriptionCharacterCount.Text = descriptionBox.Text.Length + " / " + submarineDescriptionLimit;
|
||||
submarineDescriptionCharacterCount.Text = descriptionBox.Text.Length + " / " + SubmarineInfo.MaxDescriptionLength;
|
||||
|
||||
subTypeDropdown.SelectItem(MainSub.Info.Type);
|
||||
|
||||
@@ -5045,7 +5041,7 @@ namespace Barotrauma
|
||||
textBox.UserData = text;
|
||||
}
|
||||
|
||||
submarineDescriptionCharacterCount.Text = text.Length + " / " + submarineDescriptionLimit;
|
||||
submarineDescriptionCharacterCount.Text = text.Length + " / " + SubmarineInfo.MaxDescriptionLength;
|
||||
}
|
||||
|
||||
private bool SelectPrefab(GUIComponent component, object obj)
|
||||
|
||||
Reference in New Issue
Block a user