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) },
|
||||
|
||||
Reference in New Issue
Block a user