From 26bd155a4272a1409b90a22186f8c69ec0a2584a Mon Sep 17 00:00:00 2001 From: miniduikboot Date: Thu, 22 May 2025 22:09:52 +0200 Subject: [PATCH] Fix compile warnings --- .../Attributes/MethodRpcAttribute.cs | 4 ++-- Reactor/Networking/Rpc/MethodRpc.cs | 24 +++++++++++++++---- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Reactor/Networking/Attributes/MethodRpcAttribute.cs b/Reactor/Networking/Attributes/MethodRpcAttribute.cs index 5819752..b0fa1b0 100644 --- a/Reactor/Networking/Attributes/MethodRpcAttribute.cs +++ b/Reactor/Networking/Attributes/MethodRpcAttribute.cs @@ -37,7 +37,7 @@ public sealed class MethodRpcAttribute : Attribute /// Gets or sets a value indicating whether the rpc should be sent immediately. /// [Obsolete("Non-immediate RPCs were removed in 2025.5.20. All RPCs are immediate. This property will be removed in a future version.")] - public bool SendImmediately { get; set; } + public bool SendImmediately { get; set; } = true; /// /// Initializes a new instance of the class. @@ -72,7 +72,7 @@ public sealed class MethodRpcAttribute : Attribute try { - var customRpc = new MethodRpc(plugin, method, attribute.Id, attribute.SendOption, attribute.LocalHandling, attribute.SendImmediately); + var customRpc = new MethodRpc(plugin, method, attribute.Id, attribute.SendOption, attribute.LocalHandling); PluginSingleton.Instance.CustomRpcManager.Register(customRpc); } catch (Exception e) diff --git a/Reactor/Networking/Rpc/MethodRpc.cs b/Reactor/Networking/Rpc/MethodRpc.cs index dbf66f7..4901635 100644 --- a/Reactor/Networking/Rpc/MethodRpc.cs +++ b/Reactor/Networking/Rpc/MethodRpc.cs @@ -32,13 +32,11 @@ public class MethodRpc : UnsafeCustomRpc /// The id of the rpc. /// The send option of the rpc. /// The local handling method of the rpc. - /// The value indicating whether the rpc should be sent immediately. - public MethodRpc(BasePlugin plugin, MethodInfo method, uint id, SendOption option, RpcLocalHandling localHandling, bool sendImmediately) : base(plugin, id) + public MethodRpc(BasePlugin plugin, MethodInfo method, uint id, SendOption option, RpcLocalHandling localHandling) : base(plugin, id) { Method = method; LocalHandling = localHandling; SendOption = option; - SendImmediately = sendImmediately; var parameters = method.GetParameters(); @@ -71,6 +69,22 @@ public class MethodRpc : UnsafeCustomRpc _handle = Hook(method, parameters, method.IsStatic); } + /// + /// Initializes a new instance of the class. + /// + /// The plugin that the rpc is attached to. + /// The method of the method rpc. + /// The id of the rpc. + /// The send option of the rpc. + /// The local handling method of the rpc. + /// The value indicating whether the rpc should be sent immediately. + [Obsolete("Non-immediate RPCs were removed in 2025.5.20. All RPCs are immediate. Remove sendImmediately from the parameter list.")] + public MethodRpc(BasePlugin plugin, MethodInfo method, uint id, SendOption option, RpcLocalHandling localHandling, bool sendImmediately) + : this(plugin, method, id, option, localHandling) + { + SendImmediately = sendImmediately; + } + /// /// Gets the method of the method rpc. /// @@ -92,7 +106,7 @@ public class MethodRpc : UnsafeCustomRpc /// Gets a value indicating whether the method rpc should be sent immediately. /// [Obsolete("Non-immediate RPCs were removed in 2025.5.20. All RPCs are immediate. This property will be removed in a future version.")] - public bool SendImmediately { get; } + public bool SendImmediately { get; } = true; /// public override void UnsafeWrite(MessageWriter writer, object? data) @@ -135,7 +149,7 @@ public class MethodRpc : UnsafeCustomRpc /// The arguments to serialize and send. public void Send(InnerNetObject innerNetObject, object[] args) { - UnsafeSend(innerNetObject, args, SendImmediately); + UnsafeSend(innerNetObject, args); } private static readonly MethodInfo _sendMethod = AccessTools.Method(typeof(MethodRpc), nameof(Send));