Skip to content

Commit

Permalink
Apply changes to SyncWorkerEntry
Browse files Browse the repository at this point in the history
Those changes were originally applied to a different file, but it got removed/renamed/code was moved so the changes got lost in the rebase.
  • Loading branch information
SokyranTheDragon committed Apr 7, 2024
1 parent 62d53a9 commit 03681dc
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Source/Common/Syncing/Worker/SyncWorkerEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Multiplayer.Client;
public class SyncWorkerEntry
{
delegate bool SyncWorkerDelegate(SyncWorker sync, ref object? obj);
delegate void SyncWorkerDelegateNoReturn(SyncWorker sync, ref object? obj);

public Type type;
public bool shouldConstruct;
Expand All @@ -35,8 +36,19 @@ public SyncWorkerEntry(SyncWorkerEntry other)

public void Add(MethodInfo method)
{
// todo: Find a way to do this without DynDelegate
Add(DynDelegate.DynamicDelegate.Create<SyncWorkerDelegate>(method), method.ReturnType == typeof(void));
if (method.ReturnType == typeof(void))
{
var func = (SyncWorkerDelegateNoReturn)Delegate.CreateDelegate(typeof(SyncWorkerDelegateNoReturn), method);
Add((SyncWorker sync, ref object obj) =>
{
func(sync, ref obj);
return true;
}, true);
}
else
{
Add((SyncWorkerDelegate)Delegate.CreateDelegate(typeof(SyncWorkerDelegate), method), false);
}
}

public void Add<T>(SyncWorkerDelegate<T> func)
Expand Down

0 comments on commit 03681dc

Please sign in to comment.