From 094841314a02e8afa09b836c39fbfbb6f7f2ba33 Mon Sep 17 00:00:00 2001 From: Vera Aguilera Puerto Date: Thu, 7 Oct 2021 13:22:01 +0200 Subject: [PATCH] SoundSpecifier read as ValueDataNode can ONLY deserialize ResourcePath --- .../Sound/SoundSpecifierTypeSerializer.cs | 20 +++---------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/Content.Shared/Sound/SoundSpecifierTypeSerializer.cs b/Content.Shared/Sound/SoundSpecifierTypeSerializer.cs index 70d8956642..52c81c537c 100644 --- a/Content.Shared/Sound/SoundSpecifierTypeSerializer.cs +++ b/Content.Shared/Sound/SoundSpecifierTypeSerializer.cs @@ -1,17 +1,11 @@ using System; -using Content.Shared.Audio; -using Robust.Shared.ContentPack; using Robust.Shared.IoC; -using Robust.Shared.Prototypes; -using Robust.Shared.Serialization; using Robust.Shared.Serialization.Manager; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Result; using Robust.Shared.Serialization.Markdown.Mapping; using Robust.Shared.Serialization.Markdown.Validation; using Robust.Shared.Serialization.Markdown.Value; -using Robust.Shared.Serialization.TypeSerializers.Implementations; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; using Robust.Shared.Serialization.TypeSerializers.Interfaces; using Robust.Shared.Utility; @@ -46,14 +40,7 @@ namespace Content.Shared.Sound public DeserializationResult Read(ISerializationManager serializationManager, ValueDataNode node, IDependencyCollection dependencies, bool skipHook, ISerializationContext? context = null) { - var value = node.Value; - if (dependencies.Resolve().HasIndex(value)) - return new DeserializedValue(new SoundCollectionSpecifier(value)); - - if (dependencies.Resolve().ContentFileExists(value)) - return new DeserializedValue(new SoundPathSpecifier(value)); - - throw new InvalidMappingException("SoundSpecifier is neither a resource path or sound collection identifier"); + return new DeserializedValue(new SoundPathSpecifier(node.Value)); } public ValidationNode Validate(ISerializationManager serializationManager, MappingDataNode node, @@ -71,11 +58,10 @@ namespace Content.Shared.Sound public ValidationNode Validate(ISerializationManager serializationManager, ValueDataNode node, IDependencyCollection dependencies, ISerializationContext? context = null) { - if (serializationManager.ValidateNode(node, context) is not ErrorNode - || serializationManager.ValidateNodeWith, ValueDataNode>(node, context) is not ErrorNode) + if (serializationManager.ValidateNode(node, context) is not ErrorNode) return new ValidatedValueNode(node); - return new ErrorNode(node, "SoundSpecifier value is neither a valid resource path nor an existing sound collection identifier!"); + return new ErrorNode(node, "SoundSpecifier value is not a valid resource path!"); } } }