Decompiled source of ExpiredPingFix v1.0.0

plugin/ExpiredPingFix.dll

Decompiled 5 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using IL.RoR2;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using R2API.Utils;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("ExpiredPingFix")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ExpiredPingFix")]
[assembly: AssemblyTitle("ExpiredPingFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ExpiredPingFix;

[BepInPlugin("com.kking117.ExpiredPingFix", "ExpiredPingFix", "1.0.0")]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
public class MainPlugin : BaseUnityPlugin
{
	public const string MODUID = "com.kking117.ExpiredPingFix";

	public const string MODNAME = "ExpiredPingFix";

	public const string MODVERSION = "1.0.0";

	public void Awake()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		PingerController.AttemptPing += new Manipulator(IL_AttemptPing);
	}

	private void IL_AttemptPing(ILContext il)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		ILCursor val = new ILCursor(il);
		if (val.TryGotoNext(new Func<Instruction, bool>[2]
		{
			(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 0),
			(Instruction x) => ILPatternMatchingExt.MatchLdfld(x, typeof(PingInfo), "targetNetworkIdentity")
		}) && val.TryGotoNext(new Func<Instruction, bool>[2]
		{
			(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 0),
			(Instruction x) => ILPatternMatchingExt.MatchLdfld(x, typeof(PingInfo), "targetNetworkIdentity")
		}))
		{
			int index = val.Index;
			val.Index = index + 1;
			val.RemoveRange(4);
			val.Emit(OpCodes.Ldarg_0);
			val.EmitDelegate<Func<PingInfo, PingerController, bool>>((Func<PingInfo, PingerController, bool>)((PingInfo newInfo, PingerController pingerController) => Object.op_Implicit((Object)(object)pingerController.pingIndicator) && (Object)(object)pingerController.currentPing.targetNetworkIdentity == (Object)(object)newInfo.targetNetworkIdentity));
			val.Emit(OpCodes.Ldc_I4_1);
		}
		else
		{
			Debug.LogError((object)"ExpiredPingFix: Expired Ping Fix - IL Hook failed");
		}
	}
}