using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using VoidManager;
using VoidManager.MPModChecks;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("ServerFix")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+3b2d9f34be0c79fb007406c1d985fb45664c6465")]
[assembly: AssemblyProduct("ServerFix")]
[assembly: AssemblyTitle("Fixes an issue which causes the server list to appear as alphabetical characters.")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace VoidCrewServerFix
{
public class MyPluginInfo
{
public const string PLUGIN_GUID = "Dragon.ServerFix";
public const string PLUGIN_NAME = "ServerFix";
public const string USERS_PLUGIN_NAME = "Server Fix";
public const string PLUGIN_VERSION = "1.0.0";
public const string PLUGIN_DESCRIPTION = "Fixes an issue which causes the server list to appear as alphabetical characters.";
public const string PLUGIN_ORIGINAL_AUTHOR = "Dragon";
public const string PLUGIN_AUTHORS = "Dragon";
public const string PLUGIN_THUNDERSTORE_ID = "VoidCrewModdingTeam/Server_Fix";
}
[HarmonyPatch(typeof(PhotonService), "AutoConnectIfDisconnected")]
internal class Patch
{
private static bool SecondAttempt = true;
private static string lastRegionAttempt = "us";
private static bool Prefix(PhotonService __instance)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Invalid comparison between Unknown and I4
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Invalid comparison between Unknown and I4
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Invalid comparison between Unknown and I4
if ((int)PhotonNetwork.NetworkClientState == 15 || (int)PhotonNetwork.NetworkClientState == 7)
{
SecondAttempt = true;
return true;
}
if ((int)PhotonNetwork.NetworkClientState == 14)
{
SecondAttempt = !SecondAttempt;
if (SecondAttempt)
{
string nextAvailableRegion = GetNextAvailableRegion();
Plugins.Log.LogMessage((object)("Detected issue with regions, attempting " + nextAvailableRegion));
__instance.targetRegion = nextAvailableRegion;
return false;
}
}
return true;
}
private static string GetNextAvailableRegion()
{
return lastRegionAttempt switch
{
"us" => "eu",
"eu" => "au",
"au" => "us",
_ => "us",
};
}
}
[BepInPlugin("Dragon.ServerFix", "Server Fix", "1.0.0")]
[BepInProcess("Void Crew.exe")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugins : BaseUnityPlugin
{
internal static ManualLogSource Log;
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Dragon.ServerFix is loaded!");
}
}
public class VoidManagerPlugin : VoidPlugin
{
public override MultiplayerType MPType => (MultiplayerType)8;
public override string Author => "Dragon";
public override string Description => "Fixes an issue which causes the server list to appear as alphabetical characters.";
public override string ThunderstoreID => "VoidCrewModdingTeam/Server_Fix";
}
}