-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-Patched RPC Execution, allowing PML RPCs to run earlier.
-Changed Patch locations to send mod info and verify clients earlier.
- Loading branch information
Showing
3 changed files
with
80 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using HarmonyLib; | ||
using PulsarModLoader.Patches; | ||
using System.Collections.Generic; | ||
using System.Reflection.Emit; | ||
|
||
namespace PulsarModLoader.ModMessages | ||
{ | ||
[HarmonyPatch(typeof(NetworkingPeer), "ExecuteRpc")] | ||
class AllowPMLRPCPatch | ||
{ | ||
static bool PatchMethod(bool ShouldContinue, string MethodName) | ||
{ | ||
if (MethodName == "ReceiveConnectionMessage" || MethodName == "ReceiveMessage") | ||
{ | ||
return true; | ||
} | ||
else | ||
{ | ||
return ShouldContinue; | ||
} | ||
} | ||
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) | ||
{ | ||
List<CodeInstruction> targetSequence = new List<CodeInstruction>() | ||
{ | ||
new CodeInstruction(OpCodes.Stloc_S, (byte)10), | ||
new CodeInstruction(OpCodes.Ldloc_S, (byte)10), | ||
}; | ||
|
||
List<CodeInstruction> injectedSequence = new List<CodeInstruction>() | ||
{ | ||
new CodeInstruction(OpCodes.Ldloc_2), | ||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(AllowPMLRPCPatch), "PatchMethod")), | ||
}; | ||
return HarmonyHelpers.PatchBySequence(instructions, targetSequence, injectedSequence, patchMode: HarmonyHelpers.PatchMode.AFTER); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters