Skip to content

Commit

Permalink
Fix empty atmos deserialization (#26540)
Browse files Browse the repository at this point in the history
Fix atmos deserialization
  • Loading branch information
ElectroJr authored and VMSolidus committed Jul 17, 2024
1 parent 03f1828 commit c9f44f8
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 c9f44f8

Please sign in to comment.