From 3bc50529987c61b764741d53777186238caf9e08 Mon Sep 17 00:00:00 2001 From: VMSolidus Date: Wed, 17 Jul 2024 03:35:16 -0400 Subject: [PATCH] Cherry-Pick PR26540: "Fix Empty Atmos Deserialization" (#558) # Description Cherry-Picks Wizden PR 26540, fixing an issue where our downstreams cannot save maps under certain conditions. https://github.com/space-wizards/space-station-14/pull/26540 Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> --- .../Serialization/TileAtmosCollectionSerializer.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Content.Server/Atmos/Serialization/TileAtmosCollectionSerializer.cs b/Content.Server/Atmos/Serialization/TileAtmosCollectionSerializer.cs index 71e4c2d0def..00be83e86d9 100644 --- a/Content.Server/Atmos/Serialization/TileAtmosCollectionSerializer.cs +++ b/Content.Server/Atmos/Serialization/TileAtmosCollectionSerializer.cs @@ -26,7 +26,7 @@ public Dictionary Read(ISerializationManager serializa { node.TryGetValue(new ValueDataNode("version"), out var versionNode); var version = ((ValueDataNode?) versionNode)?.AsInt() ?? 1; - Dictionary tiles; + Dictionary tiles = new(); // Backwards compatability if (version == 1) @@ -36,8 +36,6 @@ public Dictionary Read(ISerializationManager serializa var mixies = serializationManager.Read?>(tile2, hookCtx, context); var unique = serializationManager.Read?>(node["uniqueMixes"], hookCtx, context); - tiles = new Dictionary(); - if (unique != null && mixies != null) { foreach (var (indices, mix) in mixies) @@ -58,15 +56,14 @@ public Dictionary Read(ISerializationManager serializa else { var dataNode = (MappingDataNode) node["data"]; - var tileNode = (MappingDataNode) dataNode["tiles"]; var chunkSize = serializationManager.Read(dataNode["chunkSize"], hookCtx, context); - var unique = serializationManager.Read?>(dataNode["uniqueMixes"], hookCtx, context); - - tiles = new Dictionary(); + dataNode.TryGetValue(new ValueDataNode("uniqueMixes"), out var mixNode); + var unique = mixNode == null ? null : serializationManager.Read?>(mixNode, hookCtx, context); if (unique != null) { + var tileNode = (MappingDataNode) dataNode["tiles"]; foreach (var (chunkNode, valueNode) in tileNode) { var chunkOrigin = serializationManager.Read(chunkNode, hookCtx, context);