From 34fe04483f5a8a4af692a993dfa734b18c52553a Mon Sep 17 00:00:00 2001 From: Paul Ritter Date: Fri, 5 Aug 2022 00:17:16 +0200 Subject: [PATCH] content changes for "refactors copy api to use ref" (#10180) --- Content.Server/Disease/DiseaseSystem.cs | 2 +- Content.Server/Jobs/AddComponentSpecial.cs | 6 +++--- Content.Server/Payload/EntitySystems/PayloadSystem.cs | 6 ++++-- .../Decals/DecalGridChunkCollectionTypeSerializer.cs | 3 ++- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Content.Server/Disease/DiseaseSystem.cs b/Content.Server/Disease/DiseaseSystem.cs index 7e0571b09f..3589127bbe 100644 --- a/Content.Server/Disease/DiseaseSystem.cs +++ b/Content.Server/Disease/DiseaseSystem.cs @@ -386,7 +386,7 @@ namespace Content.Server.Disease return; } - var freshDisease = _serializationManager.CreateCopy(addedDisease); + var freshDisease = _serializationManager.Copy(addedDisease); if (freshDisease == null) return; diff --git a/Content.Server/Jobs/AddComponentSpecial.cs b/Content.Server/Jobs/AddComponentSpecial.cs index ccfb00648c..06b5b9ce8f 100644 --- a/Content.Server/Jobs/AddComponentSpecial.cs +++ b/Content.Server/Jobs/AddComponentSpecial.cs @@ -26,9 +26,9 @@ namespace Content.Server.Jobs var component = (Component) factory.GetComponent(name); component.Owner = mob; - var copied = (Component?) serializationManager.Copy(data.Component, component, null); - if (copied != null) - entityManager.AddComponent(mob, copied); + var temp = (object) component; + serializationManager.Copy(data.Component, ref temp); + entityManager.AddComponent(mob, (Component)temp!); } } } diff --git a/Content.Server/Payload/EntitySystems/PayloadSystem.cs b/Content.Server/Payload/EntitySystems/PayloadSystem.cs index d11747394d..bd822ba8e1 100644 --- a/Content.Server/Payload/EntitySystems/PayloadSystem.cs +++ b/Content.Server/Payload/EntitySystems/PayloadSystem.cs @@ -9,6 +9,7 @@ using Content.Shared.Payload.Components; using Content.Shared.Tag; using Robust.Shared.Containers; using Robust.Shared.Serialization.Manager; +using Robust.Shared.Serialization.Markdown.Validation; using Robust.Shared.Utility; namespace Content.Server.Payload.EntitySystems; @@ -98,8 +99,9 @@ public sealed class PayloadSystem : EntitySystem component.Owner = uid; - if (_serializationManager.Copy(data.Component, component, null) is Component copied) - EntityManager.AddComponent(uid, copied); + var temp = (object) component; + _serializationManager.Copy(data.Component, ref temp); + EntityManager.AddComponent(uid, (Component)temp!); trigger.GrantedComponents.Add(registration.Type); } diff --git a/Content.Shared/Decals/DecalGridChunkCollectionTypeSerializer.cs b/Content.Shared/Decals/DecalGridChunkCollectionTypeSerializer.cs index 9840a65278..03a1f0f6d3 100644 --- a/Content.Shared/Decals/DecalGridChunkCollectionTypeSerializer.cs +++ b/Content.Shared/Decals/DecalGridChunkCollectionTypeSerializer.cs @@ -59,7 +59,8 @@ namespace Content.Shared.Decals public DecalGridComponent.DecalGridChunkCollection Copy(ISerializationManager serializationManager, DecalGridComponent.DecalGridChunkCollection source, DecalGridComponent.DecalGridChunkCollection target, bool skipHook, ISerializationContext? context = null) { - var dict = serializationManager.Copy(source.ChunkCollection, target.ChunkCollection, context, skipHook)!; + var dict = target.ChunkCollection; + serializationManager.Copy(source.ChunkCollection, ref dict, context, skipHook); return new DecalGridComponent.DecalGridChunkCollection(dict) {NextUid = source.NextUid}; } }