using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Steamworks;
using Steamworks.Data;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("MorePlayersFixedNext")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("MorePlayersFixedNext")]
[assembly: AssemblyTitle("MorePlayersFixedNext")]
[assembly: AssemblyVersion("1.0.2.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace MorePlayersFixedNext
{
[HarmonyPatch(typeof(SteamLobbyManager))]
internal static class SteamLobbyManagerPatch
{
[HarmonyPatch("CreateLobby")]
[HarmonyPrefix]
private static bool CreateLobbyPrefix()
{
Plugin.Log.LogInfo((object)$"Creating Steam lobby with {16} members.");
SteamMatchmaking.CreateLobbyAsync(16);
return false;
}
[HarmonyPatch("OnLobbyCreated")]
[HarmonyPostfix]
private static void OnLobbyCreatedPostfix(Result result, Lobby lobby)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Invalid comparison between Unknown and I4
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
if ((int)result != 1)
{
Plugin.Log.LogError((object)$"Steam lobby creation failed: {result}.");
return;
}
int maxMembers = ((Lobby)(ref lobby)).MaxMembers;
Plugin.Log.LogInfo((object)$"Steam lobby created: members={((Lobby)(ref lobby)).MemberCount}, capacity={maxMembers} (requested {16}).");
if (maxMembers != 16)
{
Plugin.Log.LogWarning((object)"Steam lobby capacity does not match the requested player limit.");
}
}
}
[BepInPlugin("local.oldmarketsimulator.moreplayersfixednext", "MorePlayersFixedNext", "1.0.2")]
[BepInIncompatibility("ca.tredecate.moreplayersfixed")]
public sealed class Plugin : BaseUnityPlugin
{
public const string PluginGuid = "local.oldmarketsimulator.moreplayersfixednext";
public const string PluginName = "MorePlayersFixedNext";
public const string PluginVersion = "1.0.2";
public const int MaxPlayers = 16;
internal static ManualLogSource Log;
private readonly Harmony harmony = new Harmony("local.oldmarketsimulator.moreplayersfixednext");
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
harmony.PatchAll(typeof(Plugin).Assembly);
((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("{0} {1} loaded. Patched methods: {2}. Max players: {3}.", "MorePlayersFixedNext", "1.0.2", harmony.GetPatchedMethods().Count(), 16));
}
}
}