Skip to content

Commit

Permalink
Fix exposing fields for SyncDelegates (#437)
Browse files Browse the repository at this point in the history
Currently, exposing fields expects the method to provide a full path to the fields, instead of a field relative to the parent object.

For example, before this change the paths needed to be:
`RimWorld.SocialCardUtility+<>c__DisplayClass42_1/roleChangeRitual`, `RimWorld.SocialCardUtility+<>c__DisplayClass42_1/ritualTarget`, `RimWorld.SocialCardUtility+<>c__DisplayClass42_1/CS$<>8__locals1/pawn`

After this change, the paths now need to be:
`roleChangeRitual`, `ritualTarget`, `CS$<>8__locals1/pawn`
  • Loading branch information
SokyranTheDragon authored Apr 10, 2024
1 parent 5b7a8ea commit b61a92b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Source/Client/Syncing/Handler/SyncDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected override void WriteTarget(object target, object[] args, SyncMethodWrit
else if (!fieldTypes[i].IsCompilerGenerated())
{
var type = (SyncType)fieldTypes[i];
if (exposeFields != null && exposeFields.Contains(path))
if (exposeFields != null && exposeFields.Contains(fieldPathsNoTypes[i]))
type.expose = true;

writer(val, type, path);
Expand All @@ -96,7 +96,12 @@ protected override object ReadTarget(ByteReader data)
else if (fieldType.IsCompilerGenerated())
value = Activator.CreateInstance(fieldType);
else
value = SyncSerialization.ReadSyncObject(data, fieldType);
{
SyncType type = fieldType;
if (exposeFields != null && exposeFields.Contains(noTypePath))
type.expose = true;
value = SyncSerialization.ReadSyncObject(data, type);
}

if (value == null)
{
Expand Down

0 comments on commit b61a92b

Please sign in to comment.