using System; 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 Steamworks; 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.3.2.0")] [assembly: AssemblyInformationalVersion("1.3.2+bc4f59ce0b3de43097fa80dfaaf16befd1b294d3")] [assembly: AssemblyProduct("ShiftMorePlayers")] [assembly: AssemblyTitle("ShiftMorePlayers")] [assembly: AssemblyVersion("1.3.2.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(selectedMaxPlayers); ManualLogSource log = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(47, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ShiftMorePlayers] StartGameArgs.PlayerCount = "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(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(ex.Message); } log2.LogError(val2); } } } [HarmonyPatch(typeof(SteamMatchmaking), "CreateLobby")] public static class SteamCreateLobbyPatch { public static void Prefix(ref int cMaxMembers) { cMaxMembers = Plugin.SelectedMaxPlayers; } } [HarmonyPatch(typeof(PlatformManager_Steam), "HostLobby")] public static class HostLobbyPatch { public static void Postfix() { PlatformManager.s_MAXPLAYERS = Plugin.SelectedMaxPlayers; } } [HarmonyPatch(typeof(CreateLobbySettings), "StartLobby")] public static class StartLobbyPatch { public static void Prefix(CreateLobbySettings __instance) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown bool flag = default(bool); try { Plugin.SelectedMaxPlayers = Math.Clamp(__instance.maxPlayersDropdown.value + 1, 1, Plugin.MaxPlayers.Value); 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(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(ex.Message); } log2.LogError(val2); } } } [HarmonyPatch(typeof(PlatformManager_Steam), "OnLobbyChatUpdate")] public static class LobbyChatUpdateLogPatch { public static void Postfix(LobbyChatUpdate_t callback) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) bool flag = default(bool); try { int numLobbyMembers = SteamMatchmaking.GetNumLobbyMembers(new CSteamID(callback.m_ulSteamIDLobby)); ManualLogSource log = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(62, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ShiftMorePlayers] Lobby member change: state="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted((EChatMemberStateChange)callback.m_rgfChatMemberStateChange); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", members now = "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(numLobbyMembers); } log.LogInfo(val); } catch (Exception ex) { ManualLogSource log2 = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(47, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ShiftMorePlayers] LobbyChatUpdate log failed: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(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(player); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" at index "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(index); } log.LogInfo(val); } } [HarmonyPatch(typeof(CreateLobbySettings), "UpdateDropdownLanguage")] public static class ExtendMaxPlayersDropdownPatch { public static void Postfix(CreateLobbySettings __instance) { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown bool flag = default(bool); try { TMP_Dropdown maxPlayersDropdown = __instance.maxPlayersDropdown; if ((Object)(object)maxPlayersDropdown == (Object)null || maxPlayersDropdown.options == null) { return; } int value = Plugin.MaxPlayers.Value; if (maxPlayersDropdown.options.Count < value) { while (maxPlayersDropdown.options.Count < value) { int num = maxPlayersDropdown.options.Count + 1; maxPlayersDropdown.options.Add(new OptionData(num.ToString())); } maxPlayersDropdown.RefreshShownValue(); ManualLogSource log = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(60, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ShiftMorePlayers] Max players dropdown extended to "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" options"); } log.LogInfo(val); } } catch (Exception ex) { ManualLogSource log2 = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(58, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ShiftMorePlayers] Failed to extend max players dropdown: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); } log2.LogError(val2); } } } } [BepInPlugin("com.tntcrafthim.shiftmoreplayers", "ShiftMorePlayers", "1.3.2")] public class Plugin : BasePlugin { public const int DefaultMaxPlayers = 8; public const int TheoreticalMaxPlayers = 250; private const string CurrentConfigFileName = "com.tntcrafthim.shiftmoreplayers.cfg"; private const string LegacyConfigFileName = "com.tntcraft.shiftmoreplayers.cfg"; public static ConfigEntry MaxPlayers; public static ManualLogSource Log; public static int SelectedMaxPlayers; public override void Load() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown Log = ((BasePlugin)this).Log; MigrateLegacyConfig(); MaxPlayers = ((BasePlugin)this).Config.Bind("General", "MaxPlayers", 8, new ConfigDescription("Maximum players per session. Vanilla limit is 3. Only the host needs this mod for the limit to raise; clients joining a modded host work without 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(2, 250), Array.Empty())); ((BasePlugin)this).Config.Save(); SelectedMaxPlayers = MaxPlayers.Value; TryPatch(typeof(Patches.FusionStartGamePatch)); TryPatch(typeof(Patches.SteamCreateLobbyPatch)); TryPatch(typeof(Patches.HostLobbyPatch)); TryPatch(typeof(Patches.StartLobbyPatch)); TryPatch(typeof(Patches.LobbyChatUpdateLogPatch)); 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(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("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(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(patchClass.Name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex); } log2.LogError(val2); } } } }