Decompiled source of PEAKAntiCheat v1.0.0

patchers/PEAKAntiCheatPATCHER.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Collections.Generic;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("NoiseSuppression")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NoiseSuppression")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c99807f0-dbec-4945-968a-6be06a6d91f2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AntiCheatPreloader;

public static class AntiCheatPatcher
{
	public static IEnumerable<string> TargetDLLs { get; } = new string[1] { "Assembly-CSharp.dll" };


	public static List<string> TargetMethods { get; } = new List<string> { "System.Void Campfire::SetFireWoodCount(System.Int32)", "System.Void Campfire::Extinguish_Rpc()", "System.Void Campfire::Light_Rpc()", "System.Void Character::RPCA_Die(UnityEngine.Vector3)", "System.Void Character::RPCA_ReviveAtPosition(UnityEngine.Vector3,System.Boolean)", "System.Void Bugfix::AttachBug(System.Int32)" };


	public static void Patch(AssemblyDefinition assembly)
	{
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0272: Unknown result type (might be due to invalid IL or missing references)
		//IL_0277: Unknown result type (might be due to invalid IL or missing references)
		//IL_0223: Unknown result type (might be due to invalid IL or missing references)
		//IL_0228: Unknown result type (might be due to invalid IL or missing references)
		//IL_0360: Unknown result type (might be due to invalid IL or missing references)
		//IL_036a: Expected O, but got Unknown
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Expected O, but got Unknown
		//IL_029f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
		TypeReference val = default(TypeReference);
		if (!assembly.MainModule.TryGetTypeReference("Photon.Pun.PhotonMessageInfo", ref val))
		{
			Console.Error.WriteLine("[AntiCheatPatcher] PhotonMessageInfo type not found!");
			return;
		}
		List<MethodDefinition> list = new List<MethodDefinition>();
		Console.WriteLine("[AntiCheatPatcher] Adding PhotonMessageInfo parameter to RPC methods...");
		foreach (TypeDefinition type in assembly.MainModule.GetTypes())
		{
			Enumerator<MethodDefinition> enumerator2 = type.Methods.GetEnumerator();
			try
			{
				while (enumerator2.MoveNext())
				{
					MethodDefinition current2 = enumerator2.Current;
					try
					{
						if (TargetMethods.Contains(((MemberReference)current2).FullName) && current2.HasBody && ((IEnumerable<CustomAttribute>)current2.CustomAttributes).Any((CustomAttribute attr) => ((object)attr.AttributeType).ToString() == "Photon.Pun.PunRPC") && !((IEnumerable<ParameterDefinition>)((MethodReference)current2).Parameters).Any((ParameterDefinition param) => ((object)((ParameterReference)param).ParameterType).ToString() == "Photon.Pun.PhotonMessageInfo"))
						{
							Console.WriteLine("[AntiCheatPatcher] Patching " + ((MemberReference)current2).FullName + "...");
							ParameterDefinition val2 = new ParameterDefinition("info", (ParameterAttributes)0, val);
							((MethodReference)current2).Parameters.Add(val2);
							list.Add(current2);
							Console.WriteLine("[AntiCheatPatcher] Successfully patched " + ((MemberReference)current2).FullName);
						}
					}
					catch (Exception arg)
					{
						Console.Error.WriteLine($"[AntiCheatPatcher] Error patching {((MemberReference)current2).FullName}: {arg}");
					}
				}
			}
			finally
			{
				((IDisposable)enumerator2).Dispose();
			}
		}
		Console.WriteLine($"[AntiCheatPatcher] Patched {list.Count} methods");
		Console.WriteLine("[AntiCheatPatcher] Adding default PhotonMessageInfo to method calls...");
		foreach (TypeDefinition type2 in assembly.MainModule.GetTypes())
		{
			Enumerator<MethodDefinition> enumerator4 = type2.Methods.GetEnumerator();
			try
			{
				while (enumerator4.MoveNext())
				{
					MethodDefinition current4 = enumerator4.Current;
					if (!current4.HasBody)
					{
						continue;
					}
					try
					{
						ILProcessor iLProcessor = current4.Body.GetILProcessor();
						List<Instruction> list2 = new List<Instruction>();
						Enumerator<Instruction> enumerator5 = current4.Body.Instructions.GetEnumerator();
						try
						{
							while (enumerator5.MoveNext())
							{
								Instruction current5 = enumerator5.Current;
								foreach (MethodDefinition item in list)
								{
									if (current5.OpCode == OpCodes.Call || current5.OpCode == OpCodes.Callvirt)
									{
										object operand = current5.Operand;
										MethodReference val3 = (MethodReference)((operand is MethodReference) ? operand : null);
										if (val3 != null && ((MemberReference)val3).FullName == ((MemberReference)item).FullName)
										{
											list2.Add(current5);
										}
									}
								}
							}
						}
						finally
						{
							((IDisposable)enumerator5).Dispose();
						}
						if (list2.Count <= 0)
						{
							continue;
						}
						current4.Body.Variables.Add(new VariableDefinition(val));
						int num = current4.Body.Variables.Count - 1;
						foreach (Instruction item2 in list2)
						{
							Console.WriteLine("[AntiCheatPatcher] Patching call in " + ((MemberReference)current4).FullName + "...");
							iLProcessor.InsertBefore(item2, iLProcessor.Create(OpCodes.Ldloca_S, (byte)num));
							iLProcessor.InsertBefore(item2, iLProcessor.Create(OpCodes.Initobj, val));
							iLProcessor.InsertBefore(item2, iLProcessor.Create(OpCodes.Ldloc_S, (byte)num));
						}
					}
					catch (Exception arg2)
					{
						Console.Error.WriteLine($"[AntiCheatPatcher] Error patching calls in {((MemberReference)current4).FullName}: {arg2}");
					}
				}
			}
			finally
			{
				((IDisposable)enumerator4).Dispose();
			}
		}
		Console.WriteLine("[AntiCheatPatcher] Preloader patching complete!");
	}
}

plugins/PEAKAntiCheat.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Photon.Pun;
using Photon.Realtime;
using Steamworks;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("NoiseSuppression")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NoiseSuppression")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c99807f0-dbec-4945-968a-6be06a6d91f2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AntiCheatMod;

[BepInPlugin("com.hiccup444.anticheat", "PEAK Anticheat", "1.000")]
public class AntiCheatPlugin : BaseUnityPlugin, IConnectionCallbacks, IMatchmakingCallbacks, IInRoomCallbacks
{
	[CompilerGenerated]
	private sealed class <CheckNewPlayerDelayed>d__37 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Player player;

		public AntiCheatPlugin <>4__this;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <CheckNewPlayerDelayed>d__37(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(2f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<>4__this.CheckPlayerForCheatMods(player);
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <CheckPlayersForCheats>d__18 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public AntiCheatPlugin <>4__this;

		private Player[] <>s__1;

		private int <>s__2;

		private Player <player>5__3;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <CheckPlayersForCheats>d__18(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>s__1 = null;
			<player>5__3 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				break;
			case 1:
				<>1__state = -1;
				if (PhotonNetwork.InRoom && PhotonNetwork.IsMasterClient)
				{
					<>s__1 = PhotonNetwork.PlayerList;
					for (<>s__2 = 0; <>s__2 < <>s__1.Length; <>s__2++)
					{
						<player>5__3 = <>s__1[<>s__2];
						<>4__this.CheckPlayerForCheatMods(<player>5__3);
						<player>5__3 = null;
					}
					<>s__1 = null;
				}
				break;
			}
			<>2__current = (object)new WaitForSeconds(5f);
			<>1__state = 1;
			return true;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <DestroyPlayerDelayed>d__17 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public PhotonView cheaterPhotonView;

		private Exception <ex>5__1;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <DestroyPlayerDelayed>d__17(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<ex>5__1 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(0.1f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				try
				{
					if ((Object)(object)cheaterPhotonView != (Object)null && cheaterPhotonView.IsMine)
					{
						PhotonNetwork.Destroy(cheaterPhotonView);
						Logger.LogInfo((object)"Successfully destroyed cheater's character");
					}
				}
				catch (Exception ex)
				{
					<ex>5__1 = ex;
					Logger.LogError((object)("Error destroying cheater's character: " + <ex>5__1.Message));
				}
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <Reclaim_MasterClientDelayed>d__22 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public AntiCheatPlugin <>4__this;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <Reclaim_MasterClientDelayed>d__22(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(1f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				if (!PhotonNetwork.LocalPlayer.IsMasterClient)
				{
					PhotonNetwork.SetMasterClient(PhotonNetwork.LocalPlayer);
					Logger.LogInfo((object)"Reclaimed master client after soft-locking cheater");
				}
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	public static ManualLogSource Logger;

	private static AntiCheatPlugin Instance;

	private static ConfigFile Config;

	private static ConfigEntry<bool> ShowVisualLogs;

	private static ConfigEntry<bool> CheckSteamNames;

	public static ConfigEntry<bool> VerboseRPCLogging;

	private static PlayerConnectionLog _connectionLog;

	private static readonly Queue<(string message, bool onlySendOnce, bool sfxJoin, bool sfxLeave)> _queuedLogs = new Queue<(string, bool, bool, bool)>(8);

	private static readonly HashSet<int> _softLockedPlayers = new HashSet<int>();

	private static MethodInfo _getColorTagMethod;

	private static MethodInfo _addMessageMethod;

	private static FieldInfo _currentLogField;

	private void Awake()
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Expected O, but got Unknown
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Expected O, but got Unknown
		Instance = this;
		Logger = ((BaseUnityPlugin)this).Logger;
		Config = new ConfigFile(Path.Combine(Paths.ConfigPath, "com.hiccup444.PEAKanticheat.cfg"), true);
		ShowVisualLogs = Config.Bind<bool>("General", "ShowVisualLogs", true, "Show anti-cheat messages in the connection log");
		CheckSteamNames = Config.Bind<bool>("General", "CheckSteamNames", true, "Check if Photon names match Steam names");
		VerboseRPCLogging = Config.Bind<bool>("Debug", "VerboseRPCLogging", false, "Log all RPC calls for debugging");
		Logger.LogInfo((object)"Anti-cheat protection active!");
		Harmony val = new Harmony("com.hiccup444.PEAKanticheat");
		val.PatchAll();
		PhotonNetwork.AddCallbackTarget((object)this);
		((MonoBehaviour)this).StartCoroutine(CheckPlayersForCheats());
	}

	private void Update()
	{
		while (_queuedLogs.Count != 0)
		{
			(string, bool, bool, bool) tuple = _queuedLogs.Peek();
			if (!LogVisually(tuple.Item1, tuple.Item2, tuple.Item3, tuple.Item4))
			{
				break;
			}
			_queuedLogs.Dequeue();
		}
	}

	private void OnDestroy()
	{
		PhotonNetwork.RemoveCallbackTarget((object)this);
	}

	public static bool LogVisually(string message, bool onlySendOnce = false, bool sfxJoin = false, bool sfxLeave = false)
	{
		//IL_0399: Unknown result type (might be due to invalid IL or missing references)
		//IL_0413: Unknown result type (might be due to invalid IL or missing references)
		if (!ShowVisualLogs.Value)
		{
			return true;
		}
		if (!Object.op_Implicit((Object)(object)_connectionLog))
		{
			_connectionLog = Object.FindObjectOfType<PlayerConnectionLog>();
			if (Object.op_Implicit((Object)(object)_connectionLog))
			{
				Type type = ((object)_connectionLog).GetType();
				_getColorTagMethod = type.GetMethod("GetColorTag", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				_addMessageMethod = type.GetMethod("AddMessage", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				_currentLogField = type.GetField("currentLog", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (_getColorTagMethod == null)
				{
					Logger.LogWarning((object)"GetColorTag method not found!");
				}
				if (_addMessageMethod == null)
				{
					Logger.LogWarning((object)"AddMessage method not found!");
				}
				if (_currentLogField == null)
				{
					Logger.LogWarning((object)"currentLog field not found!");
				}
			}
		}
		if (!Object.op_Implicit((Object)(object)_connectionLog) || _getColorTagMethod == null || _addMessageMethod == null)
		{
			_queuedLogs.Enqueue((message, onlySendOnce, sfxJoin, sfxLeave));
			return false;
		}
		try
		{
			StringBuilder stringBuilder = new StringBuilder(message);
			FieldInfo field = ((object)_connectionLog).GetType().GetField("joinedColor", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			FieldInfo field2 = ((object)_connectionLog).GetType().GetField("leftColor", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			FieldInfo field3 = ((object)_connectionLog).GetType().GetField("userColor", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field != null && field2 != null && field3 != null)
			{
				object value = field.GetValue(_connectionLog);
				object value2 = field2.GetValue(_connectionLog);
				object value3 = field3.GetValue(_connectionLog);
				string text = (string)_getColorTagMethod.Invoke(_connectionLog, new object[1] { value });
				string text2 = (string)_getColorTagMethod.Invoke(_connectionLog, new object[1] { value2 });
				string text3 = (string)_getColorTagMethod.Invoke(_connectionLog, new object[1] { value3 });
				stringBuilder.Replace("{joinedColor}", text ?? "");
				stringBuilder.Replace("{leftColor}", text2 ?? "");
				stringBuilder.Replace("{userColor}", text3 ?? "");
			}
			message = stringBuilder.ToString();
			if (onlySendOnce && _currentLogField != null)
			{
				string text4 = _currentLogField.GetValue(_connectionLog) as string;
				if (!string.IsNullOrEmpty(text4) && text4.Contains(message))
				{
					return true;
				}
			}
			_addMessageMethod.Invoke(_connectionLog, new object[1] { message });
			FieldInfo field4 = ((object)_connectionLog).GetType().GetField("sfxJoin", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			FieldInfo field5 = ((object)_connectionLog).GetType().GetField("sfxLeave", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (sfxJoin && field4 != null)
			{
				object value4 = field4.GetValue(_connectionLog);
				value4?.GetType().GetMethod("Play", new Type[1] { typeof(Vector3) })?.Invoke(value4, new object[1] { Vector3.zero });
			}
			if (sfxLeave && field5 != null)
			{
				object value5 = field5.GetValue(_connectionLog);
				value5?.GetType().GetMethod("Play", new Type[1] { typeof(Vector3) })?.Invoke(value5, new object[1] { Vector3.zero });
			}
			return true;
		}
		catch (Exception ex)
		{
			Logger.LogError((object)("Error in LogVisually: " + ex.Message));
			return false;
		}
	}

	public static void SoftLockPlayer(Player cheater, string reason)
	{
		//IL_0205: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		if (!PhotonNetwork.IsMasterClient)
		{
			return;
		}
		if (cheater.ActorNumber == PhotonNetwork.LocalPlayer.ActorNumber)
		{
			Logger.LogInfo((object)"Not soft-locking local player");
		}
		else
		{
			if (_softLockedPlayers.Contains(cheater.ActorNumber))
			{
				return;
			}
			Logger.LogWarning((object)("CHEATER DETECTED: " + cheater.NickName + " - Reason: " + reason));
			LogVisually("{userColor}" + cheater.NickName + "</color> {leftColor}softlocked - " + reason + "</color>", onlySendOnce: false, sfxJoin: false, sfxLeave: true);
			AirportCheckInKiosk val = Object.FindObjectOfType<AirportCheckInKiosk>();
			if ((Object)(object)val != (Object)null)
			{
				PhotonView component = ((Component)val).GetComponent<PhotonView>();
				if ((Object)(object)component != (Object)null)
				{
					component.RPC("BeginIslandLoadRPC", cheater, new object[2] { "Pretitle", 7 });
					Logger.LogInfo((object)("Soft-locked cheater via kiosk: " + cheater.NickName));
					_softLockedPlayers.Add(cheater.ActorNumber);
					return;
				}
			}
			Logger.LogInfo((object)("Not in airport scene, using alternative soft-lock for: " + cheater.NickName));
			Character[] array = Object.FindObjectsOfType<Character>();
			Character val2 = null;
			Character[] array2 = array;
			foreach (Character val3 in array2)
			{
				PhotonView component2 = ((Component)val3).GetComponent<PhotonView>();
				if ((Object)(object)component2 != (Object)null && component2.Owner != null && component2.Owner.ActorNumber == cheater.ActorNumber)
				{
					val2 = val3;
					break;
				}
			}
			if ((Object)(object)val2 != (Object)null)
			{
				PhotonView component3 = ((Component)val2).GetComponent<PhotonView>();
				if ((Object)(object)component3 != (Object)null)
				{
					try
					{
						component3.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2]
						{
							(object)new Vector3(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity),
							true
						});
						Logger.LogInfo((object)("Black screened cheater: " + cheater.NickName));
						component3.OwnershipTransfer = (OwnershipOption)2;
						component3.OwnerActorNr = PhotonNetwork.LocalPlayer.ActorNumber;
						component3.ControllerActorNr = PhotonNetwork.LocalPlayer.ActorNumber;
						component3.RequestOwnership();
						component3.TransferOwnership(PhotonNetwork.LocalPlayer);
						((MonoBehaviour)Instance).StartCoroutine(DestroyPlayerDelayed(component3));
						Logger.LogInfo((object)("Initiated destruction of cheater: " + cheater.NickName));
					}
					catch (Exception ex)
					{
						Logger.LogError((object)("Error applying alternative soft-lock to " + cheater.NickName + ": " + ex.Message));
					}
				}
			}
			else
			{
				Logger.LogWarning((object)("Could not find character for cheater: " + cheater.NickName));
			}
			_softLockedPlayers.Add(cheater.ActorNumber);
		}
	}

	[IteratorStateMachine(typeof(<DestroyPlayerDelayed>d__17))]
	private static IEnumerator DestroyPlayerDelayed(PhotonView cheaterPhotonView)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <DestroyPlayerDelayed>d__17(0)
		{
			cheaterPhotonView = cheaterPhotonView
		};
	}

	[IteratorStateMachine(typeof(<CheckPlayersForCheats>d__18))]
	private IEnumerator CheckPlayersForCheats()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <CheckPlayersForCheats>d__18(0)
		{
			<>4__this = this
		};
	}

	private void CheckPlayerForCheatMods(Player player)
	{
		if (player.ActorNumber != PhotonNetwork.LocalPlayer.ActorNumber && !_softLockedPlayers.Contains(player.ActorNumber))
		{
			if (((Dictionary<object, object>)(object)player.CustomProperties).ContainsKey((object)"CherryUser"))
			{
				Logger.LogWarning((object)(player.NickName + " is using the Cherry cheat mod!"));
				LogVisually("{userColor}" + player.NickName + "</color> {leftColor}is using the Cherry cheat mod!</color>", onlySendOnce: true, sfxJoin: false, sfxLeave: true);
				SoftLockPlayer(player, "Cherry cheat mod user");
			}
			else if (((Dictionary<object, object>)(object)player.CustomProperties).ContainsKey((object)"CherryOwner"))
			{
				Logger.LogWarning((object)(player.NickName + " is the Owner of the Cherry cheat mod!"));
				LogVisually("{userColor}" + player.NickName + "</color> {leftColor}is the Owner of the Cherry cheat mod!</color>", onlySendOnce: true, sfxJoin: false, sfxLeave: true);
				SoftLockPlayer(player, "Cherry cheat mod owner");
			}
			else if (((Dictionary<object, object>)(object)player.CustomProperties).ContainsKey((object)"AtlUser"))
			{
				Logger.LogWarning((object)(player.NickName + " is using the Atlas cheat mod!"));
				LogVisually("{userColor}" + player.NickName + "</color> {leftColor}is using the Atlas cheat mod!</color>", onlySendOnce: true, sfxJoin: false, sfxLeave: true);
				SoftLockPlayer(player, "Atlas cheat mod user");
			}
			else if (((Dictionary<object, object>)(object)player.CustomProperties).ContainsKey((object)"AtlOwner"))
			{
				Logger.LogWarning((object)(player.NickName + " is the Owner of the Atlas cheat mod!"));
				LogVisually("{userColor}" + player.NickName + "</color> {leftColor}is the Owner of the Atlas cheat mod!</color>", onlySendOnce: true, sfxJoin: false, sfxLeave: true);
				SoftLockPlayer(player, "Atlas cheat mod owner");
			}
			else if (CheckSteamNames.Value)
			{
				CheckSteamNameMatch(player);
			}
		}
	}

	private void CheckSteamNameMatch(Player player)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		SteamLobbyHandler service = GameHandler.GetService<SteamLobbyHandler>();
		CSteamID val = default(CSteamID);
		if (service == null || !service.InSteamLobby(ref val))
		{
			return;
		}
		int numLobbyMembers = SteamMatchmaking.GetNumLobbyMembers(val);
		bool flag = false;
		for (int i = 0; i < numLobbyMembers; i++)
		{
			CSteamID lobbyMemberByIndex = SteamMatchmaking.GetLobbyMemberByIndex(val, i);
			string friendPersonaName = SteamFriends.GetFriendPersonaName(lobbyMemberByIndex);
			if (friendPersonaName == player.NickName)
			{
				flag = true;
				break;
			}
		}
		if (!flag)
		{
			Logger.LogWarning((object)(player.NickName + " has no matching Steam name in lobby!"));
			LogVisually("{userColor}" + player.NickName + "</color> {leftColor}has mismatched Steam/Photon name!</color>", onlySendOnce: true, sfxJoin: false, sfxLeave: true);
			SoftLockPlayer(player, "Name mismatch - possible spoofer");
		}
	}

	public void OnMasterClientSwitched(Player newMasterClient)
	{
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		Logger.LogInfo((object)$"{newMasterClient.NickName} (#{newMasterClient.ActorNumber}) is the new master client!");
		if (newMasterClient.ActorNumber != PhotonNetwork.LocalPlayer.ActorNumber && !PhotonNetwork.LocalPlayer.IsMasterClient)
		{
			SteamLobbyHandler service = GameHandler.GetService<SteamLobbyHandler>();
			CSteamID val = default(CSteamID);
			if (service != null && service.InSteamLobby(ref val) && SteamMatchmaking.GetLobbyOwner(val) == SteamUser.GetSteamID())
			{
				Logger.LogWarning((object)("Master client stolen by: " + newMasterClient.NickName));
				LogVisually("{userColor}" + newMasterClient.NickName + "</color> {leftColor}tried to take master client</color>", onlySendOnce: false, sfxJoin: false, sfxLeave: true);
				SoftLockPlayer(newMasterClient, "Stole master client");
				((MonoBehaviour)this).StartCoroutine(Reclaim_MasterClientDelayed());
			}
		}
	}

	[IteratorStateMachine(typeof(<Reclaim_MasterClientDelayed>d__22))]
	private IEnumerator Reclaim_MasterClientDelayed()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <Reclaim_MasterClientDelayed>d__22(0)
		{
			<>4__this = this
		};
	}

	public void OnConnected()
	{
	}

	public void OnConnectedToMaster()
	{
	}

	public void OnDisconnected(DisconnectCause cause)
	{
	}

	public void OnRegionListReceived(RegionHandler regionHandler)
	{
	}

	public void OnCustomAuthenticationResponse(Dictionary<string, object> data)
	{
	}

	public void OnCustomAuthenticationFailed(string debugMessage)
	{
	}

	public void OnFriendListUpdate(List<FriendInfo> friendList)
	{
	}

	public void OnCreatedRoom()
	{
	}

	public void OnCreateRoomFailed(short returnCode, string message)
	{
	}

	public void OnJoinedRoom()
	{
	}

	public void OnJoinRoomFailed(short returnCode, string message)
	{
	}

	public void OnJoinRandomFailed(short returnCode, string message)
	{
	}

	public void OnLeftRoom()
	{
		_softLockedPlayers.Clear();
	}

	public void OnPlayerEnteredRoom(Player newPlayer)
	{
		if (PhotonNetwork.IsMasterClient)
		{
			((MonoBehaviour)this).StartCoroutine(CheckNewPlayerDelayed(newPlayer));
		}
	}

	[IteratorStateMachine(typeof(<CheckNewPlayerDelayed>d__37))]
	private IEnumerator CheckNewPlayerDelayed(Player player)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <CheckNewPlayerDelayed>d__37(0)
		{
			<>4__this = this,
			player = player
		};
	}

	public void OnPlayerLeftRoom(Player otherPlayer)
	{
		if (_softLockedPlayers.Contains(otherPlayer.ActorNumber))
		{
			_softLockedPlayers.Remove(otherPlayer.ActorNumber);
			Logger.LogInfo((object)("Removed " + otherPlayer.NickName + " from soft-lock list (disconnected)"));
		}
	}

	public void OnPlayerPropertiesUpdate(Player targetPlayer, Hashtable changedProps)
	{
	}

	public void OnRoomPropertiesUpdate(Hashtable propertiesThatChanged)
	{
	}
}
[HarmonyPatch]
public static class AntiCheatPatches
{
	[HarmonyPatch(typeof(Campfire), "SetFireWoodCount")]
	[HarmonyPrefix]
	public static bool PreCampfireSetFireWoodCount(Campfire __instance, int count, PhotonMessageInfo info)
	{
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Invalid comparison between Unknown and I4
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		if (AntiCheatPlugin.VerboseRPCLogging.Value)
		{
			ManualLogSource logger = AntiCheatPlugin.Logger;
			Player sender = info.Sender;
			logger.LogInfo((object)$"Campfire.SetFireWoodCount called by {((sender != null) ? sender.NickName : null)} with count: {count}");
		}
		PhotonView component = ((Component)__instance).GetComponent<PhotonView>();
		bool flag = (int)__instance.state == 2 || info.Sender == null || ((Object)(object)component != (Object)null && info.Sender.ActorNumber == component.Owner.ActorNumber);
		if (!flag && PhotonNetwork.IsMasterClient)
		{
			AntiCheatPlugin.Logger.LogWarning((object)$"{info.Sender.NickName} (#{info.Sender.ActorNumber}) tried to set the log count to {count} for the {__instance.advanceToSegment} campfire!");
			AntiCheatPlugin.LogVisually("{userColor}" + info.Sender.NickName + "</color> {leftColor}attempted to modify campfire logs!</color>", onlySendOnce: false, sfxJoin: false, sfxLeave: true);
			AntiCheatPlugin.SoftLockPlayer(info.Sender, "Campfire log manipulation");
			__instance.FireWoodCount = 3;
			return false;
		}
		return flag;
	}

	[HarmonyPatch(typeof(Campfire), "Extinguish_Rpc")]
	[HarmonyPrefix]
	public static bool PreCampfireExtinguish_Rpc(Campfire __instance, PhotonMessageInfo info)
	{
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		if (AntiCheatPlugin.VerboseRPCLogging.Value)
		{
			ManualLogSource logger = AntiCheatPlugin.Logger;
			Player sender = info.Sender;
			logger.LogInfo((object)("Campfire.Extinguish_Rpc called by " + ((sender != null) ? sender.NickName : null)));
		}
		PhotonView component = ((Component)__instance).GetComponent<PhotonView>();
		bool flag = info.Sender == null || ((Object)(object)component != (Object)null && info.Sender.ActorNumber == component.Owner.ActorNumber);
		if (!flag)
		{
			AntiCheatPlugin.Logger.LogWarning((object)$"{info.Sender.NickName} (#{info.Sender.ActorNumber}) tried to extinguish the {__instance.advanceToSegment} campfire!");
			AntiCheatPlugin.LogVisually($"{{userColor}}{info.Sender.NickName}</color> {{leftColor}}attempted to extinguish the {__instance.advanceToSegment} campfire!</color>", onlySendOnce: false, sfxJoin: false, sfxLeave: true);
			AntiCheatPlugin.SoftLockPlayer(info.Sender, "Unauthorized campfire extinguish");
			return false;
		}
		return flag;
	}

	[HarmonyPatch(typeof(Character), "RPCA_Die")]
	[HarmonyPrefix]
	public static void PreCharacterRPCA_Die(Character __instance, PhotonMessageInfo info)
	{
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		if (AntiCheatPlugin.VerboseRPCLogging.Value)
		{
			ManualLogSource logger = AntiCheatPlugin.Logger;
			Player sender = info.Sender;
			string obj = ((sender != null) ? sender.NickName : null);
			PhotonView component = ((Component)__instance).GetComponent<PhotonView>();
			object obj2;
			if (component == null)
			{
				obj2 = null;
			}
			else
			{
				Player owner = component.Owner;
				obj2 = ((owner != null) ? owner.NickName : null);
			}
			logger.LogInfo((object)("Character.RPCA_Die called by " + obj + " on " + (string?)obj2));
		}
		PhotonView component2 = ((Component)__instance).GetComponent<PhotonView>();
		if (info.Sender != null && !info.Sender.IsMasterClient && (!((Object)(object)component2 != (Object)null) || info.Sender.ActorNumber != component2.Owner.ActorNumber))
		{
			ManualLogSource logger2 = AntiCheatPlugin.Logger;
			object[] obj3 = new object[4]
			{
				info.Sender.NickName,
				info.Sender.ActorNumber,
				null,
				null
			};
			object obj4;
			if (component2 == null)
			{
				obj4 = null;
			}
			else
			{
				Player owner2 = component2.Owner;
				obj4 = ((owner2 != null) ? owner2.NickName : null);
			}
			obj3[2] = obj4;
			int? obj5;
			if (component2 == null)
			{
				obj5 = null;
			}
			else
			{
				Player owner3 = component2.Owner;
				obj5 = ((owner3 != null) ? new int?(owner3.ActorNumber) : null);
			}
			obj3[3] = obj5;
			logger2.LogWarning((object)string.Format("{0} (#{1}) killed {2} (#{3})!", obj3));
			string[] obj6 = new string[5]
			{
				"{userColor}",
				info.Sender.NickName,
				"</color> {leftColor}killed</color> {userColor}",
				null,
				null
			};
			object obj7;
			if (component2 == null)
			{
				obj7 = null;
			}
			else
			{
				Player owner4 = component2.Owner;
				obj7 = ((owner4 != null) ? owner4.NickName : null);
			}
			obj6[3] = (string)obj7;
			obj6[4] = "</color>{leftColor}!</color>";
			AntiCheatPlugin.LogVisually(string.Concat(obj6), onlySendOnce: false, sfxJoin: false, sfxLeave: true);
			AntiCheatPlugin.SoftLockPlayer(info.Sender, "Unauthorized kill");
		}
	}
}