From 03681dcbb482823e1b003a4e70fb3597e9df4f33 Mon Sep 17 00:00:00 2001 From: SokyranTheDragon Date: Sun, 7 Apr 2024 20:53:04 +0200 Subject: [PATCH] Apply changes to SyncWorkerEntry 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. --- Source/Common/Syncing/Worker/SyncWorkerEntry.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Source/Common/Syncing/Worker/SyncWorkerEntry.cs b/Source/Common/Syncing/Worker/SyncWorkerEntry.cs index ada01cfc..2f8f2a37 100644 --- a/Source/Common/Syncing/Worker/SyncWorkerEntry.cs +++ b/Source/Common/Syncing/Worker/SyncWorkerEntry.cs @@ -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; @@ -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(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(SyncWorkerDelegate func)