Skip to content

Commit

Permalink
remove harmony2 requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
features-not-bugs committed Feb 24, 2021
1 parent a3ed07a commit dd8a110
Show file tree
Hide file tree
Showing 14 changed files with 19 additions and 24 deletions.
Binary file added deps/0Harmony.dll
Binary file not shown.
Binary file added deps/Rust.Harmony.dll
Binary file not shown.
Binary file removed harmony2_override/0Harmony.dll
Binary file not shown.
Binary file removed harmony2_override/Rust.Harmony.dll
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using HarmonyLib;
using Harmony;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
Expand All @@ -19,7 +19,7 @@ public static IEnumerable<CodeInstruction> Transpile(IEnumerable<CodeInstruction
var methodInfo = typeof(MetricsLogger)
.GetMethod(nameof(MetricsLogger.OnPlayerDisconnected), BindingFlags.Instance | BindingFlags.NonPublic);

retList.InsertRange(0, new List<CodeInstruction>
retList.InsertRange(0, new CodeInstruction[]
{
new CodeInstruction(OpCodes.Ldsfld, fieldInfo),
new CodeInstruction(OpCodes.Ldarg_0),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using HarmonyLib;
using Harmony;
using System;
using System.Collections.Generic;
using System.Reflection;
Expand All @@ -24,7 +24,7 @@ public static IEnumerable<CodeInstruction> Transpile(IEnumerable<CodeInstruction

if (idx < 0) throw new Exception("Failed to find the insertion index for PlayerInit");

retList.InsertRange(idx, new List<CodeInstruction>
retList.InsertRange(idx, new CodeInstruction[]
{
new CodeInstruction(OpCodes.Ldsfld, fieldInfo),
new CodeInstruction(OpCodes.Ldarg_0),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using HarmonyLib;
using Harmony;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
Expand All @@ -16,7 +16,7 @@ public static IEnumerable<CodeInstruction> Transpile(IEnumerable<CodeInstruction
var methodInfo = typeof(MetricsLogger)
.GetMethod(nameof(MetricsLogger.Initialize), BindingFlags.Static | BindingFlags.NonPublic);

retList.InsertRange(0, new List<CodeInstruction>
retList.InsertRange(0, new CodeInstruction[]
{
new CodeInstruction(OpCodes.Call, methodInfo)
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using HarmonyLib;
using Harmony;
using Network;
using System.Collections.Generic;
using System.Reflection;
Expand All @@ -20,7 +20,7 @@ public static IEnumerable<CodeInstruction> Transpile(IEnumerable<CodeInstruction
var methodInfo = typeof(MetricsLogger)
.GetMethod(nameof(MetricsLogger.OnNetWritePacketID), BindingFlags.Instance | BindingFlags.NonPublic);

retList.InsertRange(retList.Count - 1, new List<CodeInstruction>
retList.InsertRange(retList.Count - 1, new CodeInstruction[]
{
new CodeInstruction(OpCodes.Ldsfld, fieldInfo),
new CodeInstruction(OpCodes.Ldarg_1),
Expand Down
4 changes: 2 additions & 2 deletions src/RustServerMetrics/HarmonyPatches/NetWrite_Send_Patch.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using HarmonyLib;
using Harmony;
using Network;
using System.Collections.Generic;
using System.Reflection;
Expand All @@ -20,7 +20,7 @@ public static IEnumerable<CodeInstruction> Transpile(IEnumerable<CodeInstruction
var methodInfo = typeof(MetricsLogger)
.GetMethod(nameof(MetricsLogger.OnNetWriteSend), BindingFlags.Instance | BindingFlags.NonPublic);

retList.InsertRange(retList.Count - 1, new List<CodeInstruction>
retList.InsertRange(retList.Count - 1, new CodeInstruction[]
{
new CodeInstruction(OpCodes.Ldsfld, fieldInfo),
new CodeInstruction(OpCodes.Ldarg_1),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using HarmonyLib;
using Harmony;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
Expand All @@ -19,7 +19,7 @@ public static IEnumerable<CodeInstruction> Transpile(IEnumerable<CodeInstruction
var methodInfo = typeof(MetricsLogger)
.GetMethod(nameof(MetricsLogger.OnPerformanceReportGenerated), BindingFlags.Instance | BindingFlags.NonPublic);

retList.InsertRange(retList.Count - 1, new List<CodeInstruction>
retList.InsertRange(retList.Count - 1, new CodeInstruction[]
{
new CodeInstruction(OpCodes.Ldsfld, fieldInfo),
new CodeInstruction(OpCodes.Call, methodInfo)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using HarmonyLib;
using Harmony;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;

namespace RustServerMetrics.HarmonyPatches
{
[HarmonyPatch(typeof(TimeWarning), nameof(TimeWarning.Dispose))]
//[HarmonyPatch(typeof(TimeWarning), nameof(TimeWarning.Dispose))]
public static class TimeWarning_Dispose_Patch
{
[HarmonyTranspiler]
Expand Down
6 changes: 3 additions & 3 deletions src/RustServerMetrics/HarmonyPatches/TimeWarning_New_Patch.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using HarmonyLib;
using Harmony;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;

namespace RustServerMetrics.HarmonyPatches
{
[HarmonyPatch(typeof(TimeWarning), nameof(TimeWarning.New))]
//[HarmonyPatch(typeof(TimeWarning), nameof(TimeWarning.New))]
public static class TimeWarning_New_Patch
{
[HarmonyTranspiler]
Expand All @@ -14,7 +14,7 @@ public static IEnumerable<CodeInstruction> Transpile(IEnumerable<CodeInstruction
var methodInfo = typeof(MetricsTimeWarning)
.GetMethod(nameof(MetricsTimeWarning.GetTimeWarning), BindingFlags.Static | BindingFlags.Public);

return new List<CodeInstruction>
return new CodeInstruction[]
{
new CodeInstruction(OpCodes.Ldarg_0),
new CodeInstruction(OpCodes.Ldarg_1),
Expand Down
4 changes: 1 addition & 3 deletions src/RustServerMetrics/MetricsLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void StatusCommand(ConsoleSystem.Arg arg)
_stringBuilder.AppendLine("[ServerMetrics]: Status");
_stringBuilder.AppendLine("Overview");
_stringBuilder.Append("\tReady: "); _stringBuilder.Append(Ready); _stringBuilder.AppendLine();
_stringBuilder.AppendLine("Report Uploader:");
_stringBuilder.AppendLine("Report Uploader:");
_stringBuilder.Append("\tRunning: "); _stringBuilder.Append(_reportUploader.IsRunning); _stringBuilder.AppendLine();
_stringBuilder.Append("\tIn Buffer: "); _stringBuilder.Append(_reportUploader.BufferSize); _stringBuilder.AppendLine();

Expand Down Expand Up @@ -331,8 +331,6 @@ internal void OnPerformanceReportGenerated()
_reportUploader.AddToSendBuffer(_stringBuilder.ToString());
}

internal TimeWarning OnNewTimeWarning(string name, int maxMilliseconds) => MetricsTimeWarning.GetTimeWarning(name, maxMilliseconds);

bool ValidateConfiguration()
{
if (_configuration == null) return false;
Expand Down
5 changes: 1 addition & 4 deletions src/RustServerMetrics/RustServerMetrics.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@
</Target>
<ItemGroup>
<Reference Include="0Harmony">
<HintPath>..\..\harmony2_override\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Rust.Harmony">
<HintPath>..\..\harmony2_override\Rust.Harmony.dll</HintPath>
<HintPath>..\..\deps\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Accessibility" />
<Reference Include="ApexAI">
Expand Down

0 comments on commit dd8a110

Please sign in to comment.