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

Rework some PawnColumnWorker syncing #502

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Fixed syncing null Designation/DesignationManager
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

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 2b75a74fa256402fcfdd199ac19ef49349969e28
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;
}
},
{
Loading