Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed syncing null Designation/DesignationManager
Browse files Browse the repository at this point in the history
I haven't considered how map syncing works when writing those 2 sync worker delegates, and made an error in the way they handle maps.

Specifically, the issue here is that writing a null map may result in a non-null map when reading if another sync worker is syncing the map. Likewise, I believe attempting to sync a null map may have set the map to null for a different sync worker delegate, causing issues there.

The change here is to, rather than sync the map itself (which we may have potentially synced as null and caused issues for other sync workers) we instead sync a bool that determines if the manager is null or has null map (and we then set the MpContext to use its map).
SokyranTheDragon committed Oct 9, 2024
1 parent 93fd1de commit 2b75a74
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions Source/Client/Syncing/Dict/SyncDictRimWorld.cs
Original file line number Diff line number Diff line change
@@ -667,12 +667,18 @@ public static class SyncDictRimWorld
}
},
{
(SyncWorker sync, ref DesignationManager manager) =>
(ByteWriter data, DesignationManager manager) =>
{
if (sync.isWriting)
sync.Write(manager?.map);
else
manager = sync.Read<Map>()?.designationManager;
var isNull = manager?.map == null;
data.WriteBool(isNull);
if (!isNull)
data.MpContext().map = manager.map;
},
(ByteReader data) =>
{
if (data.ReadBool())
return null;
return data.MpContext().map.designationManager;
}
},
{

0 comments on commit 2b75a74

Please sign in to comment.