using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Steamworks; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Kalamies")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("More Players")] [assembly: AssemblyTitle("MorePlayers")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.0")] [module: UnverifiableCode] [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 MorePlayers { [BepInPlugin("kalamies.MorePlayers", "MorePlayers", "0.1.0")] public class Plugin : BaseUnityPlugin { public const string Guid = "kalamies.MorePlayers"; public const string Name = "MorePlayers"; public const string Version = "0.1.0"; internal static ManualLogSource Log; internal static ConfigEntry MaxPlayers; public static int Limit => MaxPlayers.Value; private void Awake() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; MaxPlayers = ((BaseUnityPlugin)this).Config.Bind("General", "MaxPlayers", 32, new ConfigDescription("How many players can be in a lobby you host, counting you.", (AcceptableValueBase)(object)new AcceptableValueRange(2, 250), Array.Empty())); new Harmony("kalamies.MorePlayers").PatchAll(); Log.LogInfo((object)string.Format("{0} {1} loaded. MaxPlayers={2}", "MorePlayers", "0.1.0", MaxPlayers.Value)); } } [HarmonyPatch(typeof(SteamManager), "CreateLobby")] internal static class CreateLobby_Patch { internal static bool Rewrote; private static IEnumerable Transpiler(IEnumerable instructions) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown List list = new List(instructions); MethodInfo methodInfo = AccessTools.Method(typeof(SteamMatchmaking), "CreateLobby", new Type[2] { typeof(ELobbyType), typeof(int) }, (Type[])null); int num = 1; while (methodInfo != null && num < list.Count) { if (CodeInstructionExtensions.Calls(list[num], methodInfo) && CodeInstructionExtensions.LoadsConstant(list[num - 1])) { list[num - 1] = new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(Plugin), "Limit")); Rewrote = true; break; } num++; } if (!Rewrote) { Plugin.Log.LogWarning((object)"Could not rewrite the lobby size in SteamManager.CreateLobby; falling back to resizing the lobby once it exists."); } return list; } } [HarmonyPatch(typeof(ConnectionManager), "CreateOnlineLobby")] internal static class CreateOnlineLobby_Patch { private static void Prefix(ref int maxPlayers) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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) maxPlayers = Plugin.Limit; if (!CreateLobby_Patch.Rewrote) { CSteamID currentLobbyID = SteamManager.CurrentLobbyID; if (currentLobbyID != CSteamID.Nil && !SteamMatchmaking.SetLobbyMemberLimit(currentLobbyID, Plugin.Limit)) { Plugin.Log.LogWarning((object)$"Steam refused a member limit of {Plugin.Limit}."); } } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }