OBT/1.2.0(Spring Update)

Sync with Upstream
This commit is contained in:
NotAlwaysTrue
2026-04-25 13:25:41 +08:00
committed by GitHub
parent 5207b381b7
commit 59bc21973a
421 changed files with 24090 additions and 11391 deletions
@@ -0,0 +1,35 @@
using RestSharp;
namespace Barotrauma
{
/// <summary>
/// Factory methods for creating RestSharp clients and requests with default timeout
/// settings, to avoid unforeseen connectivity issues hanging the game.
/// The timeout needs to be added to both the client and the request, due to known
/// issues with RestSharp 106.x that we use: https://github.com/restsharp/RestSharp/issues/1900
/// </summary>
public static class RestFactory
{
/// <summary>
/// Creates a RestClient with <see cref="GameSettings.Config.RemoteContentTimeoutMs"/> applied.
/// </summary>
public static RestClient CreateClient(string baseUrl)
{
return new RestClient(baseUrl)
{
Timeout = GameSettings.CurrentConfig.RemoteContentTimeoutMs
};
}
/// <summary>
/// Creates a RestRequest with <see cref="GameSettings.Config.RemoteContentTimeoutMs"/> applied.
/// </summary>
public static RestRequest CreateRequest(string resource, Method method = Method.GET)
{
return new RestRequest(resource, method)
{
Timeout = GameSettings.CurrentConfig.RemoteContentTimeoutMs
};
}
}
}
@@ -11,6 +11,7 @@ using System.Net;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
using System.Collections.Concurrent;
namespace Barotrauma
{
@@ -75,7 +76,7 @@ namespace Barotrauma
return !corrected;
}
private static readonly Dictionary<string, string> cachedFileNames = new Dictionary<string, string>();
private static readonly ConcurrentDictionary<string, string> cachedFileNames = new ConcurrentDictionary<string, string>();
public static string CorrectFilenameCase(string filename, out bool corrected, string directory = "")
{
@@ -153,7 +154,7 @@ namespace Barotrauma
if (i < subDirs.Length - 1) { filename += "/"; }
}
cachedFileNames.Add(originalFilename, filename);
cachedFileNames.TryAdd(originalFilename, filename);
return filename;
}