using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using ExitGames.Client.Photon;
using HarmonyLib;
using Photon.Pun;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[BepInPlugin("com.gil.photonvoicefix", "Photon Voice Fix", "1.0.0")]
public class VoiceFixPlugin : BaseUnityPlugin
{
private void Awake()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected O, but got Unknown
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Expected O, but got Unknown
try
{
Harmony val = new Harmony("com.gil.photonvoicefix");
MethodInfo methodInfo = AccessTools.Method(typeof(PhotonPeer), "SendOperation", new Type[3]
{
typeof(byte),
typeof(ParameterDictionary),
typeof(SendOptions)
}, (Type[])null);
MethodInfo methodInfo2 = AccessTools.Method(typeof(PhotonFixPatch), "DeepScrubPrefix", (Type[])null, (Type[])null);
val.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
MethodInfo methodInfo3 = AccessTools.Method(typeof(PhotonPeer), "EnqueueOperation", (Type[])null, (Type[])null);
MethodInfo methodInfo4 = AccessTools.Method(typeof(PhotonFixPatch), "UniversalPrefix", (Type[])null, (Type[])null);
val.Patch((MethodBase)methodInfo3, new HarmonyMethod(methodInfo4), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
((BaseUnityPlugin)this).Logger.LogInfo((object)"VoiceFix: Enumerator Scrub v1.1.9 Active.");
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)("VoiceFix: Patch Failed: " + ex.Message));
}
}
private void Update()
{
if (PhotonNetwork.InRoom && (PhotonNetwork.CloudRegion == null || PhotonNetwork.CloudRegion.ToLower().Contains("custom")))
{
((PhotonPeer)PhotonNetwork.NetworkingClient.LoadBalancingPeer).SerializationProtocolType = (SerializationProtocol)0;
}
}
}
public static class PhotonFixPatch
{
public static void DeepScrubPrefix(byte operationCode, ParameterDictionary operationParameters, ref SendOptions sendOptions)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
sendOptions.DeliveryMode = (DeliveryMode)1;
sendOptions.Encrypt = false;
if (operationParameters == null)
{
return;
}
PairIterator<byte, object> enumerator = operationParameters.GetEnumerator();
while (enumerator.MoveNext())
{
KeyValuePair<byte, object> current = enumerator.Current;
object obj = ScrubObject(current.Value);
if (obj != current.Value)
{
operationParameters[current.Key] = obj;
}
}
}
private static object ScrubObject(object obj)
{
if (obj == null)
{
return null;
}
ByteArraySlice val = (ByteArraySlice)((obj is ByteArraySlice) ? obj : null);
if (val != null)
{
byte[] array = new byte[val.Count];
Buffer.BlockCopy(val.Buffer, val.Offset, array, 0, val.Count);
return array;
}
if (obj is object[] array2)
{
for (int i = 0; i < array2.Length; i++)
{
array2[i] = ScrubObject(array2[i]);
}
return array2;
}
return obj;
}
public static void UniversalPrefix(ref SendOptions sendOptions)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
sendOptions.Encrypt = false;
sendOptions.DeliveryMode = (DeliveryMode)1;
}
}