diff --git a/Reactor/Networking/Rpc/MethodRpc.cs b/Reactor/Networking/Rpc/MethodRpc.cs
index 49016355..09e5583a 100644
--- a/Reactor/Networking/Rpc/MethodRpc.cs
+++ b/Reactor/Networking/Rpc/MethodRpc.cs
@@ -18,7 +18,7 @@ namespace Reactor.Networking.Rpc;
///
/// Provides a custom rpc for method rpc.
///
-public class MethodRpc : UnsafeCustomRpc
+public class MethodRpc : UnsafeCustomRpc, IDisposable
{
private delegate object HandleDelegate(InnerNetObject innerNetObject, object[] args);
@@ -154,12 +154,29 @@ public void Send(InnerNetObject innerNetObject, object[] args)
private static readonly MethodInfo _sendMethod = AccessTools.Method(typeof(MethodRpc), nameof(Send));
+ // ReSharper disable once NotAccessedField.Local
+ private Hook? _hook;
+
///
/// Hooks the rpc with a dynamic method that sends it.
///
private HandleDelegate Hook(MethodInfo method, ParameterInfo[] parameters, bool isStatic)
{
- var detour = new Detour(method, GenerateSender());
+ // MonoMod Hook is used instead of Detour because Starlight
+ // uses the "reorg" branch which no longer includes Detour.
+ // Hook is still present with the same signature.
+ // DMD is a workaround since reorganized Hook doesn't contain a
+ // function to make a trampoline.
+
+ // Create a copy of the original method with DMD
+ var dmd = new DynamicMethodDefinition(method);
+ var originalTrampoline = dmd.Generate();
+
+ // Hook the method to send the RPC
+ _hook = new Hook(method, GenerateSender());
+
+ // Return the generated Handler method
+ return GenerateHandler(originalTrampoline);
// Used as target when hooking, sends the method rpc
DynamicMethod GenerateSender()
@@ -244,7 +261,7 @@ DynamicMethod GenerateSender()
}
// Proxy translating object array to trampoline method args, used by MethodRpc to invoke original handling
- HandleDelegate GenerateHandler(DynamicMethod trampoline)
+ HandleDelegate GenerateHandler(MethodInfo trampoline)
{
var dynamicMethod = new DynamicMethod($"Handler<{method.GetID(simple: true)}>", typeof(object), new[] { typeof(InnerNetObject), typeof(object[]) });
dynamicMethod.DefineParameter(0, ParameterAttributes.None, "innerNetObject");
@@ -280,7 +297,12 @@ HandleDelegate GenerateHandler(DynamicMethod trampoline)
return dynamicMethod.CreateDelegate();
}
+ }
- return GenerateHandler((DynamicMethod) detour.GenerateTrampoline());
+ ///
+ public void Dispose()
+ {
+ GC.SuppressFinalize(this);
+ _hook?.Dispose();
}
}
diff --git a/Reactor/Patches/Miscellaneous/SplashSkipPatch.cs b/Reactor/Patches/Miscellaneous/SplashSkipPatch.cs
index 20e3519c..2258b180 100644
--- a/Reactor/Patches/Miscellaneous/SplashSkipPatch.cs
+++ b/Reactor/Patches/Miscellaneous/SplashSkipPatch.cs
@@ -11,13 +11,4 @@ private static void RemoveMinimumWait(SplashManager __instance)
{
__instance.minimumSecondsBeforeSceneChange = 0;
}
-
- [HarmonyPatch(typeof(SplashManager), nameof(SplashManager.Update))]
- [HarmonyPrefix]
- private static bool WaitForLogin(SplashManager __instance)
- {
- if (__instance.startedSceneLoad) return true;
-
- return true;
- }
}
diff --git a/Reactor/Patches/Miscellaneous/StandaloneSteamPatch.cs b/Reactor/Patches/Miscellaneous/StandaloneSteamPatch.cs
index 0e6a33a2..50532029 100644
--- a/Reactor/Patches/Miscellaneous/StandaloneSteamPatch.cs
+++ b/Reactor/Patches/Miscellaneous/StandaloneSteamPatch.cs
@@ -27,11 +27,11 @@ public static MethodBase TargetMethod()
public static bool Prefix(out bool __result)
{
- const string file = "steam_appid.txt";
+ const string AppIdFile = "steam_appid.txt";
- if (!File.Exists(file))
+ if (!File.Exists(AppIdFile))
{
- File.WriteAllText(file, "945360");
+ File.WriteAllText(AppIdFile, "945360");
}
return __result = false;