Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-Pick PR26540: "Fix Empty Atmos Deserialization" #558

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading