Skip to content

Commit

Permalink
Cherry-Pick PR26540: "Fix Empty Atmos Deserialization" (#558)
Browse files Browse the repository at this point in the history
# Description

Cherry-Picks Wizden PR 26540, fixing an issue where our downstreams
cannot save maps under certain conditions.

space-wizards/space-station-14#26540

Co-authored-by: Leon Friedrich <[email protected]>
  • Loading branch information
VMSolidus and ElectroJr authored Jul 17, 2024
1 parent 03f1828 commit 3bc5052
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public Dictionary<Vector2i, TileAtmosphere> Read(ISerializationManager serializa
{
node.TryGetValue(new ValueDataNode("version"), out var versionNode);
var version = ((ValueDataNode?) versionNode)?.AsInt() ?? 1;
Dictionary<Vector2i, TileAtmosphere> tiles;
Dictionary<Vector2i, TileAtmosphere> tiles = new();

// Backwards compatability
if (version == 1)
Expand All @@ -36,8 +36,6 @@ public Dictionary<Vector2i, TileAtmosphere> Read(ISerializationManager serializa
var mixies = serializationManager.Read<Dictionary<Vector2i, int>?>(tile2, hookCtx, context);
var unique = serializationManager.Read<List<GasMixture>?>(node["uniqueMixes"], hookCtx, context);

tiles = new Dictionary<Vector2i, TileAtmosphere>();

if (unique != null && mixies != null)
{
foreach (var (indices, mix) in mixies)
Expand All @@ -58,15 +56,14 @@ public Dictionary<Vector2i, TileAtmosphere> Read(ISerializationManager serializa
else
{
var dataNode = (MappingDataNode) node["data"];
var tileNode = (MappingDataNode) dataNode["tiles"];
var chunkSize = serializationManager.Read<int>(dataNode["chunkSize"], hookCtx, context);

var unique = serializationManager.Read<List<GasMixture>?>(dataNode["uniqueMixes"], hookCtx, context);

tiles = new Dictionary<Vector2i, TileAtmosphere>();
dataNode.TryGetValue(new ValueDataNode("uniqueMixes"), out var mixNode);
var unique = mixNode == null ? null : serializationManager.Read<List<GasMixture>?>(mixNode, hookCtx, context);

if (unique != null)
{
var tileNode = (MappingDataNode) dataNode["tiles"];
foreach (var (chunkNode, valueNode) in tileNode)
{
var chunkOrigin = serializationManager.Read<Vector2i>(chunkNode, hookCtx, context);
Expand Down

0 comments on commit 3bc5052

Please sign in to comment.