Skip to content

Commit

Permalink
bagel update (space-wizards#34572)
Browse files Browse the repository at this point in the history
* bagel update

* Decal fault tolerance

* Also fix writes

* fix mv cable, decal issues, yar

* fix a floor tile and some other shit

---------

Co-authored-by: metalgearsloth <[email protected]>
  • Loading branch information
Emisse and metalgearsloth authored Jan 22, 2025
1 parent 20acef1 commit 3499b47
Show file tree
Hide file tree
Showing 2 changed files with 10,633 additions and 11,372 deletions.
27 changes: 19 additions & 8 deletions Content.Shared/Decals/DecalGridChunkCollectionTypeSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public DecalGridChunkCollection Read(ISerializationManager serializationManager,
node.TryGetValue(new ValueDataNode("version"), out var versionNode);
var version = ((ValueDataNode?) versionNode)?.AsInt() ?? 1;
Dictionary<Vector2i, DecalChunk> dictionary;
uint nextIndex = 0;
var ids = new HashSet<uint>();

// TODO: Dump this when we don't need support anymore.
if (version > 1)
Expand All @@ -53,22 +55,31 @@ public DecalGridChunkCollection Read(ISerializationManager serializationManager,
var chunkOrigin = SharedMapSystem.GetChunkIndices(coords, SharedDecalSystem.ChunkSize);
var chunk = dictionary.GetOrNew(chunkOrigin);
var decal = new Decal(coords, data.Id, data.Color, data.Angle, data.ZIndex, data.Cleanable);
chunk.Decals.Add(dUid, decal);

nextIndex = Math.Max(nextIndex, dUid);

// Re-used ID somehow
// This will bump all IDs by up to 1 but will ensure the map is still readable.
if (!ids.Add(dUid))
{
dUid = nextIndex++;
ids.Add(dUid);
}

chunk.Decals[dUid] = decal;
}
}
}
else
{
dictionary = serializationManager.Read<Dictionary<Vector2i, DecalChunk>>(node, hookCtx, context, notNullableOverride: true);
}

uint nextIndex = 0;

foreach (var decals in dictionary.Values)
{
foreach (var uid in decals.Decals.Keys)
foreach (var decals in dictionary.Values)
{
nextIndex = Math.Max(uid, nextIndex);
foreach (var uid in decals.Decals.Keys)
{
nextIndex = Math.Max(uid, nextIndex);
}
}
}

Expand Down
Loading

0 comments on commit 3499b47

Please sign in to comment.