Compare commits

..

1 Commits

Author SHA1 Message Date
Pieter-Jan Briers
f7c28992f8 Disable string map caching to hopefully fix connect. 2020-12-17 00:48:15 +01:00
3 changed files with 17 additions and 3 deletions

View File

@@ -32,6 +32,7 @@ using Robust.Shared.Interfaces.Timers;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
@@ -65,6 +66,7 @@ namespace Robust.Client
[Dependency] private readonly IScriptClient _scriptClient = default!;
[Dependency] private readonly IComponentManager _componentManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IRobustMappedStringSerializer _stringSerializer = default!;
private CommandLineArgs? _commandLineArgs;
private bool _disableAssemblyLoadContext;
@@ -125,6 +127,7 @@ namespace Robust.Client
ProgramShared.DoMounts(_resourceCache, _commandLineArgs?.MountOptions, "Content.Client", _loaderArgs != null);
if (_loaderArgs != null)
{
_stringSerializer.EnableCaching = false;
_resourceCache.MountLoaderApi(_loaderArgs.FileApi, "Resources/");
_modLoader.VerifierExtraLoadHandler = VerifierExtraLoadHandler;
}

View File

@@ -40,6 +40,8 @@ namespace Robust.Shared.Serialization
/// </exception>
ReadOnlySpan<byte> MappedStringsHash { get; }
bool EnableCaching { get; set; }
/// <summary>
/// Add a string to the constant mapping.
/// </summary>

View File

@@ -121,6 +121,8 @@ namespace Robust.Shared.Serialization
/// </exception>
public ReadOnlySpan<byte> MappedStringsHash => _stringMapHash;
public bool EnableCaching { get; set; } = true;
private static readonly Regex RxSymbolSplitter
= new(
@"(?<=[^\s\W])(?=[A-Z]) # Match for split at start of new capital letter
@@ -283,7 +285,10 @@ namespace Robust.Shared.Serialization
LogSzr.Debug($"Locked in at {_dict.StringCount} mapped strings.");
packageStream.Position = 0;
WriteStringCache(packageStream);
if (EnableCaching)
{
WriteStringCache(packageStream);
}
// ok we're good now
var channel = msg.MsgChannel;
@@ -405,7 +410,7 @@ namespace Robust.Shared.Serialization
LogSzr.Debug($"Received server handshake with hash {hashStr}.");
var fileName = CacheForHash(hashStr);
if (!File.Exists(fileName))
if (fileName == null || !File.Exists(fileName))
{
LogSzr.Debug($"No string cache for {hashStr}.");
var handshake = _net.CreateNetMessage<MsgMapStrClientHandshake>();
@@ -458,8 +463,12 @@ namespace Robust.Shared.Serialization
/// file itself may or may not exist. If it does not exist, no cache
/// was made for the given hash.
/// </returns>
private static string CacheForHash(string hashStr)
private string? CacheForHash(string hashStr)
{
if (!EnableCaching)
{
return null;
}
return PathHelpers.ExecutableRelativeFile($"strings-{hashStr}");
}