-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial Addition of Network Update Statistics
- Loading branch information
1 parent
d501188
commit 7c55fd1
Showing
4 changed files
with
133 additions
and
1 deletion.
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,32 @@ | ||
using Harmony; | ||
using Network; | ||
using Oxide.Core; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection.Emit; | ||
|
||
namespace RustServerMetrics_HarmonyPatch.NetWrite | ||
{ | ||
[HarmonyPatch(typeof(Network.NetWrite), nameof(Network.NetWrite.PacketID))] | ||
public class PacketID_Patch | ||
{ | ||
[HarmonyTranspiler] | ||
public static IEnumerable<CodeInstruction> Transpile(IEnumerable<CodeInstruction> originalInstructions) | ||
{ | ||
List<CodeInstruction> retList = new List<CodeInstruction>(originalInstructions); | ||
|
||
var methodInfo = typeof(Interface).GetMethods(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public).FirstOrDefault(x => x.Name == "CallHook" && x.GetParameters().Count() == 2 && x.GetParameters()[1].ParameterType == typeof(object)); | ||
|
||
retList.InsertRange(retList.Count - 1, new List<CodeInstruction> | ||
{ | ||
new CodeInstruction(OpCodes.Ldstr, "OnNetWritePacketID"), | ||
new CodeInstruction(OpCodes.Ldarg_1), | ||
new CodeInstruction(OpCodes.Box, typeof(Message.Type)), | ||
new CodeInstruction(OpCodes.Call, methodInfo), | ||
new CodeInstruction(OpCodes.Pop) | ||
}); | ||
|
||
return retList; | ||
} | ||
} | ||
} |
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,33 @@ | ||
using Harmony; | ||
using Network; | ||
using Oxide.Core; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection.Emit; | ||
|
||
namespace RustServerMetrics_HarmonyPatch.NetWrite | ||
{ | ||
[HarmonyPatch(typeof(Network.NetWrite), nameof(Network.NetWrite.Send))] | ||
public class Send_Patch | ||
{ | ||
[HarmonyTranspiler] | ||
public static IEnumerable<CodeInstruction> Transpile(IEnumerable<CodeInstruction> originalInstructions) | ||
{ | ||
List<CodeInstruction> retList = new List<CodeInstruction>(originalInstructions); | ||
|
||
var methodInfo = typeof(Interface).GetMethods(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public).FirstOrDefault(x => x.Name == "CallHook" && x.GetParameters().Count() == 2 && x.GetParameters()[1].ParameterType == typeof(object)); | ||
|
||
retList.InsertRange(retList.Count - 1, new List<CodeInstruction> | ||
{ | ||
new CodeInstruction(OpCodes.Ldstr, "OnNetWriteSend"), | ||
new CodeInstruction(OpCodes.Ldarg_1), | ||
new CodeInstruction(OpCodes.Box, typeof(SendInfo)), | ||
new CodeInstruction(OpCodes.Call, methodInfo), | ||
new CodeInstruction(OpCodes.Pop) | ||
}); | ||
|
||
return retList; | ||
} | ||
} | ||
} |
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