mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Deterministic RobustMappedStringSerializer (#1265)
This commit is contained in:
committed by
GitHub
parent
5261c8d5aa
commit
6b92db35f0
@@ -17,9 +17,9 @@ namespace Robust.Shared.Serialization
|
||||
|
||||
public partial class RobustSerializer : IRobustSerializer
|
||||
{
|
||||
|
||||
[Dependency] private readonly IReflectionManager _reflectionManager = default!;
|
||||
[Dependency] private readonly INetManager _netManager = default!;
|
||||
[Dependency] private readonly IRobustMappedStringSerializer _mappedStringSerializer = default!;
|
||||
|
||||
private readonly Lazy<ISawmill> _lazyLogSzr = new Lazy<ISawmill>(() => Logger.GetSawmill("szr"));
|
||||
|
||||
@@ -30,8 +30,6 @@ namespace Robust.Shared.Serialization
|
||||
|
||||
private HashSet<Type> _serializableTypes = default!;
|
||||
|
||||
private readonly RobustMappedStringSerializer _mappedStringSerializer = new RobustMappedStringSerializer();
|
||||
|
||||
private static Type[] AlwaysNetSerializable => new[]
|
||||
{
|
||||
typeof(Vector2i)
|
||||
@@ -61,8 +59,6 @@ namespace Robust.Shared.Serialization
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
IoCManager.RegisterInstance<IRobustMappedStringSerializer>(_mappedStringSerializer);
|
||||
|
||||
var types = _reflectionManager.FindTypesWithAttribute<NetSerializableAttribute>().ToList();
|
||||
#if !FULL_RELEASE
|
||||
// confirm only shared types are marked for serialization, no client & server only types
|
||||
@@ -82,22 +78,15 @@ namespace Robust.Shared.Serialization
|
||||
|
||||
types.AddRange(AlwaysNetSerializable);
|
||||
|
||||
_mappedStringSerializer.InitLogging();
|
||||
_mappedStringSerializer.Initialize();
|
||||
|
||||
var settings = new Settings
|
||||
{
|
||||
CustomTypeSerializers = new ITypeSerializer[] {_mappedStringSerializer}
|
||||
CustomTypeSerializers = new[] {_mappedStringSerializer.TypeSerializer}
|
||||
};
|
||||
_serializer = new Serializer(types, settings);
|
||||
_serializableTypes = new HashSet<Type>(_serializer.GetTypeMap().Keys);
|
||||
LogSzr.Info($"Serializer Types Hash: {_serializer.GetSHA256()}");
|
||||
|
||||
if (_netManager.IsClient)
|
||||
{
|
||||
_mappedStringSerializer.LockMappedStrings = true;
|
||||
}
|
||||
|
||||
_mappedStringSerializer.NetworkInitialize(_netManager);
|
||||
}
|
||||
|
||||
public void Serialize(Stream stream, object toSerialize)
|
||||
|
||||
Reference in New Issue
Block a user