using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Fusion;
using HarmonyLib;
using Il2CppSystem;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ShiftMorePlayers")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.4.0.0")]
[assembly: AssemblyInformationalVersion("1.4.0+888776ba78582efc2803e8b6c2b2c159b02cec0c")]
[assembly: AssemblyProduct("ShiftMorePlayers")]
[assembly: AssemblyTitle("ShiftMorePlayers")]
[assembly: AssemblyVersion("1.4.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 ShiftMorePlayers
{
public static class Patches
{
[HarmonyPatch(typeof(NetworkRunner), "StartGame")]
public static class FusionStartGamePatch
{
public static void Prefix(StartGameArgs args)
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
int selectedMaxPlayers = Plugin.SelectedMaxPlayers;
bool flag = default(bool);
try
{
args.PlayerCount = new Nullable<int>(selectedMaxPlayers);
ManualLogSource log = Plugin.Log;
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(47, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ShiftMorePlayers] StartGameArgs.PlayerCount = ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(selectedMaxPlayers);
}
log.LogInfo(val);
}
catch (Exception ex)
{
ManualLogSource log2 = Plugin.Log;
BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(46, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ShiftMorePlayers] Failed to set PlayerCount: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
}
log2.LogError(val2);
}
}
}
[HarmonyPatch]
public static class SteamCreateLobbyPatch
{
private static MethodBase _target;
public static bool Prepare()
{
_target = FindDeclaredMethod(FindLoadedType("Steamworks.SteamMatchmaking"), "CreateLobby", 2);
if (_target == null)
{
Plugin.Log.LogInfo((object)"[ShiftMorePlayers] Steam matchmaking is absent; skipping the Steam lobby limit patch.");
}
return _target != null;
}
public static MethodBase TargetMethod()
{
return _target;
}
public static void Prefix(ref int cMaxMembers)
{
cMaxMembers = Plugin.SelectedMaxPlayers;
}
}
[HarmonyPatch]
public static class PlatformHostLobbyPatch
{
public static IEnumerable<MethodBase> TargetMethods()
{
Type[] array = new Type[3]
{
typeof(PlatformManager),
GetGameType("PlatformManager_Steam"),
GetGameType("PlatformManager_Xbox")
};
HashSet<MethodBase> seen = new HashSet<MethodBase>();
Type[] array2 = array;
bool flag = default(bool);
foreach (Type type in array2)
{
MethodBase methodBase = FindDeclaredMethod(type, "HostLobby", 0);
if (methodBase != null && seen.Add(methodBase))
{
ManualLogSource log = Plugin.Log;
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(38, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ShiftMorePlayers] Patching ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(type.Name);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".HostLobby");
}
log.LogInfo(val);
yield return methodBase;
}
}
}
public static void Prefix()
{
RestorePlatformPlayerLimit();
}
public static void Postfix()
{
RestorePlatformPlayerLimit();
}
}
[HarmonyPatch]
public static class XboxFullLobbyDirectJoinPatch
{
private static MethodBase _target;
private static PropertyInfo _sessionManagerProperty;
private static PropertyInfo _lastJoinFailedDueToFullProperty;
private static PropertyInfo _currentSessionHandleProperty;
private static bool _loggedArmed;
public static bool Prepare()
{
Type gameType = GetGameType("PlatformManager_Xbox");
Type type = FindLoadedType("HLG.Runtime.GameCore.GameCoreSessionManager");
_target = FindDeclaredMethod(gameType, "OnJoinSessionCompleted", 1);
_sessionManagerProperty = gameType?.GetProperty("gamecoreSessionManager", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
_lastJoinFailedDueToFullProperty = type?.GetProperty("LastJoinFailedDueToSessionFull", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
_currentSessionHandleProperty = type?.GetProperty("CurrentSessionHandle", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (gameType == null)
{
Plugin.Log.LogInfo((object)"[ShiftMorePlayers] Xbox platform is absent; skipping the full-lobby direct join fallback.");
return false;
}
if (_target == null || _sessionManagerProperty == null || _lastJoinFailedDueToFullProperty == null || _currentSessionHandleProperty == null)
{
Plugin.Log.LogInfo((object)"[ShiftMorePlayers] Xbox full-lobby direct join fallback is not present on this build; skipping it.");
return false;
}
if (!_loggedArmed)
{
_loggedArmed = true;
Plugin.Log.LogInfo((object)"[ShiftMorePlayers] Xbox full-lobby direct join fallback armed.");
}
return true;
}
public static MethodBase TargetMethod()
{
return _target;
}
public static void Prefix(object __instance, ref bool success)
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Expected O, but got Unknown
if (success)
{
return;
}
try
{
object value = _sessionManagerProperty.GetValue(__instance);
if (value != null)
{
bool num = Convert.ToBoolean(_lastJoinFailedDueToFullProperty.GetValue(value));
object value2 = _currentSessionHandleProperty.GetValue(value);
if (num && value2 != null)
{
success = true;
Plugin.Log.LogWarning((object)"[ShiftMorePlayers] Xbox MPSD lobby is full; bypassing its 3-member template and joining the Fusion room directly. Every Xbox player joining beyond the vanilla limit must have ShiftMorePlayers installed.");
}
}
}
catch (Exception ex)
{
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(64, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ShiftMorePlayers] Xbox full-lobby direct join fallback failed: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
log.LogError(val);
}
}
}
[HarmonyPatch]
public static class StartLobbyPatch
{
private static MethodBase _target;
public static bool Prepare()
{
if (MaxPlayersDropdownProperty == null)
{
Plugin.Log.LogInfo((object)"[ShiftMorePlayers] This platform has no lobby-size dropdown; skipping the dropdown selection patch.");
return false;
}
_target = FindDeclaredMethod(typeof(CreateLobbySettings), "StartLobby", 0);
return _target != null;
}
public static MethodBase TargetMethod()
{
return _target;
}
public static void Prefix(CreateLobbySettings __instance)
{
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Expected O, but got Unknown
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
bool flag = default(bool);
try
{
Plugin.SelectedMaxPlayers = ReadSelectedMaxPlayers(__instance);
SetLobbyPlayerLimit(__instance, Plugin.SelectedMaxPlayers);
RestorePlatformPlayerLimit();
if (_lastLoggedSelectedMaxPlayers != Plugin.SelectedMaxPlayers)
{
_lastLoggedSelectedMaxPlayers = Plugin.SelectedMaxPlayers;
ManualLogSource log = Plugin.Log;
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(47, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ShiftMorePlayers] Host selected max players = ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Plugin.SelectedMaxPlayers);
}
log.LogInfo(val);
}
}
catch (Exception ex)
{
ManualLogSource log2 = Plugin.Log;
BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(56, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ShiftMorePlayers] Failed to read max players dropdown: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
}
log2.LogError(val2);
}
}
}
[HarmonyPatch(typeof(FusionNetworkManager), "SpawnPlayerInGameScene")]
public static class SpawnPlayerLogPatch
{
public static void Postfix(PlayerRef player, int index)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(44, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ShiftMorePlayers] Spawned player ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<PlayerRef>(player);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" at index ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(index);
}
log.LogInfo(val);
}
}
[HarmonyPatch]
public static class ExtendMaxPlayersDropdownPatch
{
private static MethodBase _target;
public static bool Prepare()
{
if (MaxPlayersDropdownProperty == null)
{
Plugin.Log.LogInfo((object)"[ShiftMorePlayers] This platform has no lobby-size dropdown; skipping dropdown extension.");
return false;
}
_target = FindDeclaredMethod(typeof(CreateLobbySettings), "UpdateDropdownLanguage", 0) ?? FindDeclaredMethod(typeof(CreateLobbySettings), "OnEnable", 0);
if (_target == null)
{
Plugin.Log.LogWarning((object)"[ShiftMorePlayers] No lobby-menu refresh method was found; dropdown extension is unavailable.");
}
return _target != null;
}
public static MethodBase TargetMethod()
{
return _target;
}
public static void Postfix(CreateLobbySettings __instance)
{
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Expected O, but got Unknown
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Expected O, but got Unknown
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Expected O, but got Unknown
bool flag = default(bool);
try
{
TMP_Dropdown val = FindMaxPlayersDropdown(__instance, forceRescan: true);
if ((Object)(object)val == (Object)null || val.options == null)
{
SetLobbyPlayerLimit(__instance, Plugin.MaxPlayers.Value);
return;
}
int value = Plugin.MaxPlayers.Value;
if (val.options.Count < value)
{
while (val.options.Count < value)
{
int num = val.options.Count + 1;
val.options.Add(new OptionData(num.ToString()));
}
val.RefreshShownValue();
ManualLogSource log = Plugin.Log;
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(60, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ShiftMorePlayers] Max players dropdown extended to ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(value);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" options");
}
log.LogInfo(val2);
}
}
catch (Exception ex)
{
ManualLogSource log2 = Plugin.Log;
BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(58, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[ShiftMorePlayers] Failed to extend max players dropdown: ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
}
log2.LogError(val3);
}
}
}
private const BindingFlags DeclaredInstanceMembers = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
private const BindingFlags DeclaredStaticMembers = BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
private static readonly PropertyInfo MaxPlayersDropdownProperty = typeof(CreateLobbySettings).GetProperty("maxPlayersDropdown", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly PropertyInfo LobbyMaxPlayersProperty = typeof(CreateLobbySettings).GetProperty("maxPlayers", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly PropertyInfo PlatformMaxPlayersProperty = typeof(PlatformManager).GetProperty("s_MAXPLAYERS", BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
private static int _loggedDropdownInstanceId;
private static int _searchedDropdownOwnerId;
private static TMP_Dropdown _cachedDropdown;
private static bool _dropdownSearchCompleted;
private static bool _loggedDropdownFallback;
private static bool _loggedMissingLobbyLimit;
private static bool _loggedMissingPlatformLimit;
private static int _lastLoggedSelectedMaxPlayers = -1;
private static MethodInfo FindDeclaredMethod(Type type, string name, int parameterCount = -1)
{
if (type == null)
{
return null;
}
BindingFlags bindingAttr = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
MethodInfo[] methods = type.GetMethods(bindingAttr);
foreach (MethodInfo methodInfo in methods)
{
if (methodInfo.Name == name && (parameterCount < 0 || methodInfo.GetParameters().Length == parameterCount))
{
return methodInfo;
}
}
return null;
}
private static Type GetGameType(string name)
{
return typeof(PlatformManager).Assembly.GetType(name, throwOnError: false);
}
private static Type FindLoadedType(string fullName)
{
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
for (int i = 0; i < assemblies.Length; i++)
{
Type type = assemblies[i].GetType(fullName, throwOnError: false);
if (type != null)
{
return type;
}
}
return null;
}
private static TMP_Dropdown FindMaxPlayersDropdown(CreateLobbySettings instance, bool forceRescan = false)
{
//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
//IL_01ef: Expected O, but got Unknown
if ((Object)(object)instance == (Object)null)
{
return null;
}
try
{
object? obj = MaxPlayersDropdownProperty?.GetValue(instance);
TMP_Dropdown val = (TMP_Dropdown)((obj is TMP_Dropdown) ? obj : null);
if (val != null && (Object)(object)val != (Object)null)
{
return val;
}
}
catch
{
}
int instanceID = ((Object)instance).GetInstanceID();
if (!forceRescan && _dropdownSearchCompleted && _searchedDropdownOwnerId == instanceID)
{
return _cachedDropdown;
}
TMP_Dropdown val2 = null;
int num = int.MinValue;
foreach (TMP_Dropdown componentsInChild in ((Component)instance).GetComponentsInChildren<TMP_Dropdown>(true))
{
if ((Object)(object)componentsInChild == (Object)null)
{
continue;
}
int num2 = 0;
GameObject gameObject = ((Component)componentsInChild).gameObject;
string obj3 = ((gameObject == null) ? null : ((Object)gameObject).name?.ToLowerInvariant()) ?? string.Empty;
if (obj3.Contains("max"))
{
num2 += 300;
}
if (obj3.Contains("player"))
{
num2 += 300;
}
if (obj3.Contains("type"))
{
num2 -= 200;
}
int num3 = componentsInChild.options?.Count ?? 0;
int num4 = 0;
for (int i = 0; i < num3; i++)
{
OptionData obj4 = componentsInChild.options[i];
if (int.TryParse((obj4 != null) ? obj4.text : null, out var _))
{
num4++;
}
}
num2 = ((num3 <= 0 || num4 != num3) ? (num2 + num4 * 20) : (num2 + (1000 + Math.Min(num3, 250))));
if (num2 > num)
{
num = num2;
val2 = componentsInChild;
}
}
if (num < 600)
{
val2 = null;
}
_searchedDropdownOwnerId = instanceID;
_dropdownSearchCompleted = true;
_cachedDropdown = val2;
if ((Object)(object)val2 != (Object)null)
{
int instanceID2 = ((Object)val2).GetInstanceID();
if (_loggedDropdownInstanceId != instanceID2)
{
_loggedDropdownInstanceId = instanceID2;
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(68, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[ShiftMorePlayers] Max players dropdown resolved from UI hierarchy: ");
GameObject gameObject2 = ((Component)val2).gameObject;
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>((gameObject2 != null) ? ((Object)gameObject2).name : null);
}
log.LogInfo(val3);
}
}
return val2;
}
private static void SetLobbyPlayerLimit(CreateLobbySettings instance, int maxPlayers)
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
try
{
PropertyInfo lobbyMaxPlayersProperty = LobbyMaxPlayersProperty;
if ((object)lobbyMaxPlayersProperty != null && lobbyMaxPlayersProperty.CanWrite)
{
LobbyMaxPlayersProperty.SetValue(instance, maxPlayers);
}
else if (!_loggedMissingLobbyLimit)
{
_loggedMissingLobbyLimit = true;
Plugin.Log.LogWarning((object)"[ShiftMorePlayers] CreateLobbySettings.maxPlayers is unavailable on this build.");
}
}
catch (Exception ex)
{
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(53, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ShiftMorePlayers] Failed to set lobby player limit: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
log.LogError(val);
}
}
private static int ReadSelectedMaxPlayers(CreateLobbySettings instance)
{
TMP_Dropdown val = FindMaxPlayersDropdown(instance);
if ((Object)(object)val != (Object)null)
{
return Math.Clamp(val.value + 1, 1, Plugin.MaxPlayers.Value);
}
if (!_loggedDropdownFallback)
{
_loggedDropdownFallback = true;
Plugin.Log.LogInfo((object)"[ShiftMorePlayers] This platform has no max players dropdown; using the configured limit.");
}
return Plugin.MaxPlayers.Value;
}
private static void RestorePlatformPlayerLimit()
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Expected O, but got Unknown
try
{
PropertyInfo platformMaxPlayersProperty = PlatformMaxPlayersProperty;
if ((object)platformMaxPlayersProperty != null && platformMaxPlayersProperty.CanWrite)
{
PlatformMaxPlayersProperty.SetValue(null, Plugin.SelectedMaxPlayers);
}
else if (!_loggedMissingPlatformLimit)
{
_loggedMissingPlatformLimit = true;
Plugin.Log.LogWarning((object)"[ShiftMorePlayers] PlatformManager.s_MAXPLAYERS is unavailable on this build.");
}
}
catch (Exception ex)
{
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(60, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ShiftMorePlayers] Failed to restore platform player limit: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
log.LogError(val);
}
}
}
[BepInPlugin("com.tntcrafthim.shiftmoreplayers", "ShiftMorePlayers", "1.4.0")]
public class Plugin : BasePlugin
{
public const int DefaultMaxPlayers = 10;
public const int TheoreticalMaxPlayers = 250;
private const string CurrentConfigFileName = "com.tntcrafthim.shiftmoreplayers.cfg";
private const string LegacyConfigFileName = "com.tntcraft.shiftmoreplayers.cfg";
public static ConfigEntry<int> MaxPlayers;
public static ManualLogSource Log;
public static int SelectedMaxPlayers;
public override void Load()
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Expected O, but got Unknown
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Expected O, but got Unknown
Log = ((BasePlugin)this).Log;
MigrateLegacyConfig();
MaxPlayers = ((BasePlugin)this).Config.Bind<int>("General", "MaxPlayers", 10, new ConfigDescription("Maximum players per session. Vanilla limit is 3. Steam only requires the host to install this mod. Xbox app / Game Pass players joining beyond the platform's 3-member lobby template must also install it. The configurable maximum is Steam's theoretical 250-member lobby ceiling. Values above 10 exceed known gameplay data structures and may break interactions or monster detection.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 250), Array.Empty<object>()));
((BasePlugin)this).Config.Save();
SelectedMaxPlayers = MaxPlayers.Value;
TryPatch(typeof(Patches.FusionStartGamePatch));
TryPatch(typeof(Patches.SteamCreateLobbyPatch));
TryPatch(typeof(Patches.PlatformHostLobbyPatch));
TryPatch(typeof(Patches.XboxFullLobbyDirectJoinPatch));
TryPatch(typeof(Patches.StartLobbyPatch));
TryPatch(typeof(Patches.SpawnPlayerLogPatch));
TryPatch(typeof(Patches.ExtendMaxPlayersDropdownPatch));
ManualLogSource log = Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(62, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("ShiftMorePlayers loaded. Player limit raised to ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(MaxPlayers.Value);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (vanilla: 3).");
}
log.LogInfo(val);
}
private void MigrateLegacyConfig()
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Expected O, but got Unknown
string text = Path.Combine(Paths.ConfigPath, "com.tntcrafthim.shiftmoreplayers.cfg");
string text2 = Path.Combine(Paths.ConfigPath, "com.tntcraft.shiftmoreplayers.cfg");
if (!File.Exists(text) && File.Exists(text2))
{
File.Copy(text2, text);
((BasePlugin)this).Config.Reload();
ManualLogSource log = Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(62, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Migrated legacy config to ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("com.tntcrafthim.shiftmoreplayers.cfg");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("; the old file was kept as a backup.");
}
log.LogInfo(val);
}
}
private static void TryPatch(Type patchClass)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Expected O, but got Unknown
bool flag = default(bool);
try
{
Harmony.CreateAndPatchAll(patchClass, (string)null);
ManualLogSource log = Log;
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(10, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Patch OK: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(patchClass.Name);
}
log.LogInfo(val);
}
catch (Exception ex)
{
ManualLogSource log2 = Log;
BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(16, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Patch FAILED: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(patchClass.Name);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
}
log2.LogError(val2);
}
}
}
}