using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ComputerysModdingUtilities;
using HarmonyLib;
using HeathenEngineering.SteamworksIntegration;
using Microsoft.CodeAnalysis;
using Steamworks;
using TMPro;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: StraftatMod(true)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MatchFilter")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Configurable lobby browser filters and auto-refresh for STRAFTAT")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0")]
[assembly: AssemblyProduct("MatchFilter")]
[assembly: AssemblyTitle("MatchFilter")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.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 MatchFilter
{
public enum FilterOption
{
Any,
Yes,
No
}
public struct HostRankInfo
{
public int Rank;
public int Score;
public bool HasEntry;
}
[BepInPlugin("com.balu.straftat.matchfilter", "MatchFilter", "1.2.0")]
public class Plugin : BaseUnityPlugin
{
public const string PLUGIN_GUID = "com.balu.straftat.matchfilter";
public const string PLUGIN_NAME = "MatchFilter";
public const string PLUGIN_VERSION = "1.2.0";
internal static Plugin Instance;
internal static ManualLogSource Log;
private Harmony _harmony;
public static ConfigEntry<bool> ModEnabled;
public static ConfigEntry<bool> AlwaysShowFriendsLobbies;
public static ConfigEntry<FilterOption> FilterMidMatch;
public static ConfigEntry<FilterOption> FilterSwapper;
public static ConfigEntry<FilterOption> FilterRandomizer;
public static ConfigEntry<FilterOption> FilterOutlines;
public static ConfigEntry<FilterOption> FilterFriendlyFire;
public static ConfigEntry<int> MaxHostKicks;
public static ConfigEntry<int> MaxHostBans;
public static ConfigEntry<bool> HideFullLobbies;
public static ConfigEntry<bool> AutoRefreshEnabled;
public static ConfigEntry<bool> AutoRefreshOnlyWhenEmpty;
public static ConfigEntry<float> AutoRefreshInterval;
public static ConfigEntry<bool> FormatTooltipYesNo;
public static ConfigEntry<bool> ShowRankInTooltip;
public static ConfigEntry<bool> ShowHostRankInLobbyName;
public static ConfigEntry<bool> SortByScore;
public static ConfigEntry<string> LobbyNameRankFormat;
public static ConfigEntry<string> LobbyNameUnrankedFormat;
private static readonly FieldRef<Settings, LeaderboardManager> GetLeaderboardManagerRef = AccessTools.FieldRefAccess<Settings, LeaderboardManager>("leaderboardManager");
public static readonly Dictionary<ulong, HostRankInfo> CachedHostRanks = new Dictionary<ulong, HostRankInfo>();
private static readonly HashSet<ulong> InFlightRankFetches = new HashSet<ulong>();
private static readonly Dictionary<ulong, List<LobbyDataEntry>> PendingUiUpdates = new Dictionary<ulong, List<LobbyDataEntry>>();
private float _refreshTimer = 0f;
private bool _wasBrowserActive = false;
private void Awake()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
Instance = this;
Log = ((BaseUnityPlugin)this).Logger;
InitConfig();
_harmony = new Harmony("com.balu.straftat.matchfilter");
_harmony.PatchAll();
Log.LogInfo((object)"[MatchFilter] Plugin initialized successfully (version 1.2.0)!");
}
private void InitConfig()
{
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Expected O, but got Unknown
ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("1. General", "Enabled", true, "Enable or disable the MatchFilter mod completely.");
AlwaysShowFriendsLobbies = ((BaseUnityPlugin)this).Config.Bind<bool>("2. Lobby Filters", "AlwaysShowFriends", true, "Always show lobbies hosted by Steam friends, bypassing all active filter criteria.");
FilterMidMatch = ((BaseUnityPlugin)this).Config.Bind<FilterOption>("2. Lobby Filters", "MidMatch", FilterOption.Any, "Filter lobbies by Mid Match status.\nAny = Allow all lobbies\nYes = Only show lobbies with match in progress\nNo = Only show lobbies waiting in lobby / match not started");
FilterSwapper = ((BaseUnityPlugin)this).Config.Bind<FilterOption>("2. Lobby Filters", "UsingSwapper", FilterOption.Any, "Filter lobbies by Weapon Swapper usage.\nAny = Allow all lobbies\nYes = Only show lobbies with custom swapper enabled\nNo = Only show lobbies without custom swapper");
FilterRandomizer = ((BaseUnityPlugin)this).Config.Bind<FilterOption>("2. Lobby Filters", "UsingRandomizer", FilterOption.Any, "Filter lobbies by Weapon Randomizer usage.\nAny = Allow all lobbies\nYes = Only show lobbies with randomizer enabled\nNo = Only show lobbies without randomizer");
FilterOutlines = ((BaseUnityPlugin)this).Config.Bind<FilterOption>("2. Lobby Filters", "UsingOutlines", FilterOption.Any, "Filter lobbies by Player Outlines setting.\nAny = Allow all lobbies\nYes = Only show lobbies with player outlines enabled\nNo = Only show lobbies without player outlines");
FilterFriendlyFire = ((BaseUnityPlugin)this).Config.Bind<FilterOption>("2. Lobby Filters", "FriendlyFire", FilterOption.Any, "Filter lobbies by Friendly Fire setting.\nAny = Allow all lobbies\nYes = Only show lobbies with friendly fire enabled\nNo = Only show lobbies without friendly fire");
MaxHostKicks = ((BaseUnityPlugin)this).Config.Bind<int>("2. Lobby Filters", "MaxHostKicks", -1, "Maximum allowed host kicks count. Lobbies where the host has kicked more players than this will be hidden. Set to -1 to allow any amount.");
MaxHostBans = ((BaseUnityPlugin)this).Config.Bind<int>("2. Lobby Filters", "MaxHostBans", -1, "Maximum allowed banned players count by host. Lobbies where the host has banned more players than this will be hidden. Set to -1 to allow any amount.");
HideFullLobbies = ((BaseUnityPlugin)this).Config.Bind<bool>("2. Lobby Filters", "HideFullLobbies", false, "Hide lobbies that are currently full (e.g. 2/2 or 4/4 players).");
AutoRefreshEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("3. Auto Refresh", "Enabled", true, "Automatically refresh the browse lobbies list at regular intervals while the browser is open.");
AutoRefreshOnlyWhenEmpty = ((BaseUnityPlugin)this).Config.Bind<bool>("3. Auto Refresh", "OnlyWhenEmpty", true, "Only auto-refresh when there are no lobbies in the browse list that match your filter criteria. Once matching lobbies are found, auto-refresh pauses to keep the list stable.");
AutoRefreshInterval = ((BaseUnityPlugin)this).Config.Bind<float>("3. Auto Refresh", "IntervalSeconds", 5f, new ConfigDescription("Interval in seconds between automatic lobby list refreshes. Recommended minimum is 2-3 seconds to prevent Steam rate limits.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 60f), Array.Empty<object>()));
FormatTooltipYesNo = ((BaseUnityPlugin)this).Config.Bind<bool>("4. Lobby Tooltip", "FormatTooltipYesNo", true, "Format hover tooltip on lobbies to show 'Yes / No' and 'Host Bans: n' instead of 'true / false' and 'Banned Players: n'.");
ShowRankInTooltip = ((BaseUnityPlugin)this).Config.Bind<bool>("4. Lobby Tooltip", "ShowRankInTooltip", true, "Include host's leaderboard rank and score in the lobby hover tooltip.");
ShowHostRankInLobbyName = ((BaseUnityPlugin)this).Config.Bind<bool>("5. Host Rank & Score", "ShowHostRankInLobbyName", true, "Append host's leaderboard rank and score to the lobby name in the browse lobby list.");
SortByScore = ((BaseUnityPlugin)this).Config.Bind<bool>("5. Host Rank & Score", "SortByScore", true, "Sort lobbies in Browse Lobbies from highest to lowest host score (highest score at the top).");
LobbyNameRankFormat = ((BaseUnityPlugin)this).Config.Bind<string>("5. Host Rank & Score", "LobbyNameRankFormat", "{name} #{rank} ({score})", "Format for displaying rank and score in the lobby name. Available placeholders: {name}, {rank}, {score}.");
LobbyNameUnrankedFormat = ((BaseUnityPlugin)this).Config.Bind<string>("5. Host Rank & Score", "LobbyNameUnrankedFormat", "{name} (Unranked)", "Format for displaying the lobby name when the host has no leaderboard entry. Available placeholders: {name}.");
((BaseUnityPlugin)this).Config.SettingChanged += OnSettingChanged;
}
private void OnSettingChanged(object sender, SettingChangedEventArgs e)
{
if (e.ChangedSetting.Definition.Key == "SortByScore")
{
SortLobbiesByScore();
}
else if ((Object)(object)LobbiesListManager.Instance != (Object)null && (Object)(object)LobbiesListManager.Instance.lobbyListContent != (Object)null && LobbiesListManager.Instance.lobbyListContent.activeInHierarchy && (Object)(object)SteamLobby.Instance != (Object)null && !SteamLobby.Instance.inSteamLobby && !SteamLobby.Instance.findingQuickMatchLobby)
{
Log.LogDebug((object)("[MatchFilter] Setting changed (" + e.ChangedSetting.Definition.Key + "), refreshing lobby browser..."));
ResetRefreshTimer();
LobbiesListManager.Instance.GetListOfLobbies();
}
}
private void Update()
{
if (PendingUiUpdates.Count > 0)
{
LeaderboardManager leaderboardManager = GetLeaderboardManager();
if ((Object)(object)leaderboardManager != (Object)null && (Object)(object)leaderboardManager.leaderboard != (Object)null && leaderboardManager.leaderboard.Valid)
{
List<ulong> list = PendingUiUpdates.Keys.ToList();
foreach (ulong item in list)
{
if (!InFlightRankFetches.Contains(item) && !CachedHostRanks.ContainsKey(item))
{
TriggerFetchHostRank(item, leaderboardManager);
}
}
}
}
if (!ModEnabled.Value || !AutoRefreshEnabled.Value)
{
_wasBrowserActive = false;
_refreshTimer = 0f;
return;
}
if ((Object)(object)LobbiesListManager.Instance == (Object)null || (Object)(object)LobbiesListManager.Instance.lobbyListContent == (Object)null)
{
_wasBrowserActive = false;
_refreshTimer = 0f;
return;
}
bool flag = LobbiesListManager.Instance.lobbyListContent.activeInHierarchy;
if ((Object)(object)SteamLobby.Instance != (Object)null && (SteamLobby.Instance.inSteamLobby || SteamLobby.Instance.findingQuickMatchLobby))
{
flag = false;
}
if (!flag)
{
_wasBrowserActive = false;
_refreshTimer = 0f;
return;
}
if (!_wasBrowserActive)
{
_wasBrowserActive = true;
_refreshTimer = 0f;
return;
}
if (AutoRefreshOnlyWhenEmpty.Value && GetVisibleLobbyCount() > 0)
{
_refreshTimer = 0f;
return;
}
float num = Mathf.Max(1f, AutoRefreshInterval.Value);
_refreshTimer += Time.unscaledDeltaTime;
if (_refreshTimer >= num)
{
_refreshTimer = 0f;
Log.LogDebug((object)$"[MatchFilter] Auto-refreshing browse lobby list (visible lobbies: {GetVisibleLobbyCount()}, interval {num:F1}s)...");
LobbiesListManager.Instance.GetListOfLobbies();
}
}
public void ResetRefreshTimer()
{
_refreshTimer = 0f;
}
public static int GetVisibleLobbyCount()
{
if ((Object)(object)LobbiesListManager.Instance == (Object)null || LobbiesListManager.Instance.listOfLobbies == null)
{
return 0;
}
int num = 0;
for (int i = 0; i < LobbiesListManager.Instance.listOfLobbies.Count; i++)
{
GameObject val = LobbiesListManager.Instance.listOfLobbies[i];
if ((Object)(object)val != (Object)null && val.activeInHierarchy)
{
num++;
}
}
return num;
}
public static bool IsLobbyFlagEnabled(CSteamID lobbyID, string key)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
string lobbyData = SteamMatchmaking.GetLobbyData(lobbyID, key);
return string.Equals(lobbyData, "true", StringComparison.OrdinalIgnoreCase);
}
public static int GetLobbyCount(CSteamID lobbyID, string key)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
string lobbyData = SteamMatchmaking.GetLobbyData(lobbyID, key);
if (!int.TryParse(lobbyData, out var result) || result < 0)
{
return 0;
}
return result;
}
public static bool IsSteamFriend(ulong steamId)
{
//IL_0010: 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_001a: 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_001d: Invalid comparison between Unknown and I4
try
{
if (steamId == 0)
{
return false;
}
EFriendRelationship friendRelationship = SteamFriends.GetFriendRelationship((CSteamID)steamId);
return (int)friendRelationship == 3;
}
catch (Exception ex)
{
Log.LogError((object)$"[MatchFilter] Error checking friend status for {steamId}: {ex.Message}");
return false;
}
}
public static LeaderboardManager GetLeaderboardManager()
{
if ((Object)(object)Settings.Instance == (Object)null)
{
return null;
}
try
{
LeaderboardManager val = GetLeaderboardManagerRef.Invoke(Settings.Instance);
if ((Object)(object)val != (Object)null)
{
return val;
}
}
catch
{
}
return ((Component)Settings.Instance).GetComponentInChildren<LeaderboardManager>();
}
public void ApplyHostRankToLobbyEntry(LobbyDataEntry entry)
{
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
if (!ModEnabled.Value || !ShowHostRankInLobbyName.Value || (Object)(object)entry == (Object)null || (Object)(object)entry.lobbyNameText == (Object)null)
{
return;
}
string lobbyData = SteamMatchmaking.GetLobbyData(entry.lobbyID, "HostAddress");
if (!ulong.TryParse(lobbyData, out var result) || result == 0)
{
return;
}
string baseName = (string.IsNullOrEmpty(entry.lobbyName) ? "Empty" : entry.lobbyName);
if (CachedHostRanks.TryGetValue(result, out var value))
{
((TMP_Text)entry.lobbyNameText).text = FormatRankName(baseName, value);
return;
}
if (!PendingUiUpdates.TryGetValue(result, out var value2))
{
value2 = new List<LobbyDataEntry>();
PendingUiUpdates[result] = value2;
}
if (!value2.Contains(entry))
{
value2.Add(entry);
}
if (!InFlightRankFetches.Contains(result))
{
LeaderboardManager leaderboardManager = GetLeaderboardManager();
if (!((Object)(object)leaderboardManager == (Object)null) && !((Object)(object)leaderboardManager.leaderboard == (Object)null) && leaderboardManager.leaderboard.Valid)
{
TriggerFetchHostRank(result, leaderboardManager);
}
}
}
private void TriggerFetchHostRank(ulong hostSteamId, LeaderboardManager lbManager)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
InFlightRankFetches.Add(hostSteamId);
UserData val = UserData.Get(hostSteamId);
lbManager.leaderboard.GetEntries((UserData[])(object)new UserData[1] { val }, (Action<LeaderboardEntry[], bool>)delegate(LeaderboardEntry[] results, bool error)
{
InFlightRankFetches.Remove(hostSteamId);
try
{
bool flag = !error && results != null && results.Length != 0;
HostRankInfo hostRankInfo = new HostRankInfo
{
HasEntry = flag,
Rank = (flag ? results[0].Rank : 0),
Score = (flag ? results[0].Score : 0)
};
CachedHostRanks[hostSteamId] = hostRankInfo;
if (PendingUiUpdates.TryGetValue(hostSteamId, out var value))
{
foreach (LobbyDataEntry item in value)
{
if ((Object)(object)item != (Object)null && (Object)(object)item.lobbyNameText != (Object)null)
{
string baseName = (string.IsNullOrEmpty(item.lobbyName) ? "Empty" : item.lobbyName);
((TMP_Text)item.lobbyNameText).text = FormatRankName(baseName, hostRankInfo);
}
}
PendingUiUpdates.Remove(hostSteamId);
}
SortLobbiesByScore();
}
catch (Exception arg)
{
Log.LogError((object)$"[MatchFilter] Error processing leaderboard callback for host {hostSteamId}: {arg}");
}
});
}
public static int GetLobbyScore(GameObject lobbyGo)
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)lobbyGo == (Object)null)
{
return int.MinValue;
}
LobbyDataEntry component = lobbyGo.GetComponent<LobbyDataEntry>();
if ((Object)(object)component == (Object)null)
{
return int.MinValue;
}
string lobbyData = SteamMatchmaking.GetLobbyData(component.lobbyID, "HostAddress");
if (!ulong.TryParse(lobbyData, out var result) || result == 0)
{
return int.MinValue;
}
if (CachedHostRanks.TryGetValue(result, out var value))
{
if (value.HasEntry)
{
return value.Score;
}
return -1;
}
return -2;
}
public static int GetLobbyRank(GameObject lobbyGo)
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)lobbyGo == (Object)null)
{
return int.MaxValue;
}
LobbyDataEntry component = lobbyGo.GetComponent<LobbyDataEntry>();
if ((Object)(object)component == (Object)null)
{
return int.MaxValue;
}
string lobbyData = SteamMatchmaking.GetLobbyData(component.lobbyID, "HostAddress");
if (!ulong.TryParse(lobbyData, out var result) || result == 0)
{
return int.MaxValue;
}
if (CachedHostRanks.TryGetValue(result, out var value) && value.HasEntry && value.Rank > 0)
{
return value.Rank;
}
return int.MaxValue;
}
public static void SortLobbiesByScore()
{
if ((Object)(object)Instance == (Object)null || !SortByScore.Value || (Object)(object)LobbiesListManager.Instance == (Object)null || LobbiesListManager.Instance.listOfLobbies == null)
{
return;
}
List<GameObject> listOfLobbies = LobbiesListManager.Instance.listOfLobbies;
listOfLobbies.RemoveAll((GameObject go) => (Object)(object)go == (Object)null);
if (listOfLobbies.Count <= 1)
{
return;
}
listOfLobbies.Sort(delegate(GameObject a, GameObject b)
{
int lobbyScore = GetLobbyScore(a);
int num2 = GetLobbyScore(b).CompareTo(lobbyScore);
if (num2 != 0)
{
return num2;
}
int lobbyRank = GetLobbyRank(a);
int lobbyRank2 = GetLobbyRank(b);
return lobbyRank.CompareTo(lobbyRank2);
});
for (int num = 0; num < listOfLobbies.Count; num++)
{
if ((Object)(object)listOfLobbies[num] != (Object)null)
{
listOfLobbies[num].transform.SetSiblingIndex(num);
}
}
}
private string FormatRankName(string baseName, HostRankInfo info)
{
if (info.HasEntry)
{
return LobbyNameRankFormat.Value.Replace("{name}", baseName).Replace("{rank}", info.Rank.ToString()).Replace("{score}", info.Score.ToString());
}
return LobbyNameUnrankedFormat.Value.Replace("{name}", baseName);
}
private static bool MatchesOption(bool actualValue, FilterOption option)
{
if (1 == 0)
{
}
bool result = option switch
{
FilterOption.Any => true,
FilterOption.Yes => actualValue,
FilterOption.No => !actualValue,
_ => true,
};
if (1 == 0)
{
}
return result;
}
public bool PassesFilter(CSteamID lobbyID)
{
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
if (!ModEnabled.Value)
{
return true;
}
try
{
if (AlwaysShowFriendsLobbies.Value)
{
string lobbyData = SteamMatchmaking.GetLobbyData(lobbyID, "HostAddress");
if (ulong.TryParse(lobbyData, out var result) && result != 0 && IsSteamFriend(result))
{
return true;
}
}
bool actualValue = IsLobbyFlagEnabled(lobbyID, "MidMatch");
if (!MatchesOption(actualValue, FilterMidMatch.Value))
{
return false;
}
bool actualValue2 = IsLobbyFlagEnabled(lobbyID, "UsingCustomSwapper");
if (!MatchesOption(actualValue2, FilterSwapper.Value))
{
return false;
}
bool actualValue3 = IsLobbyFlagEnabled(lobbyID, "UsingRandomizer");
if (!MatchesOption(actualValue3, FilterRandomizer.Value))
{
return false;
}
bool actualValue4 = IsLobbyFlagEnabled(lobbyID, "UsingOutlines");
if (!MatchesOption(actualValue4, FilterOutlines.Value))
{
return false;
}
bool actualValue5 = IsLobbyFlagEnabled(lobbyID, "UsingFriendlyFire");
if (!MatchesOption(actualValue5, FilterFriendlyFire.Value))
{
return false;
}
int value = MaxHostKicks.Value;
if (value >= 0)
{
int lobbyCount = GetLobbyCount(lobbyID, "HostKickCount");
if (lobbyCount > value)
{
return false;
}
}
int value2 = MaxHostBans.Value;
if (value2 >= 0)
{
int lobbyCount2 = GetLobbyCount(lobbyID, "BannedPlayerCount");
if (lobbyCount2 > value2)
{
return false;
}
}
if (HideFullLobbies.Value)
{
int lobbyMemberLimit = SteamMatchmaking.GetLobbyMemberLimit(lobbyID);
int numLobbyMembers = SteamMatchmaking.GetNumLobbyMembers(lobbyID);
if (lobbyMemberLimit > 0 && numLobbyMembers >= lobbyMemberLimit)
{
return false;
}
}
return true;
}
catch (Exception arg)
{
Log.LogError((object)$"[MatchFilter] Error evaluating lobby {lobbyID}: {arg}");
return true;
}
}
private void OnDestroy()
{
((BaseUnityPlugin)this).Config.SettingChanged -= OnSettingChanged;
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
}
[HarmonyPatch(typeof(LobbiesListManager), "DisplayLobbyWithData")]
public static class LobbiesListManager_DisplayLobbyWithData_Patch
{
[HarmonyPrefix]
public static bool Prefix(CSteamID lobbyID)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Plugin.Instance != (Object)null && !Plugin.Instance.PassesFilter(lobbyID))
{
return false;
}
return true;
}
[HarmonyPostfix]
public static void Postfix()
{
Plugin.SortLobbiesByScore();
}
}
[HarmonyPatch(typeof(LobbyDataEntry), "RenderLobby")]
public static class LobbyDataEntry_RenderLobby_Patch
{
[HarmonyPostfix]
public static void Postfix(LobbyDataEntry __instance)
{
if (!((Object)(object)__instance == (Object)null) && !((Object)(object)((Component)__instance).gameObject == (Object)null) && !((Object)(object)__instance.lobbyNameText == (Object)null))
{
Plugin.Instance?.ApplyHostRankToLobbyEntry(__instance);
}
}
}
[HarmonyPatch(typeof(LobbiesListManager), "GetListOfLobbies")]
public static class LobbiesListManager_GetListOfLobbies_Patch
{
[HarmonyPostfix]
public static void Postfix()
{
Plugin.Instance?.ResetRefreshTimer();
}
}
[HarmonyPatch(typeof(LobbiesListManager), "GetTooltipText")]
public static class LobbiesListManager_GetTooltipText_Patch
{
[HarmonyPostfix]
public static void Postfix(CSteamID lobbyID, ref string __result)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
if (Plugin.FormatTooltipYesNo == null || !Plugin.FormatTooltipYesNo.Value)
{
return;
}
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append("Mid Match: ").AppendLine(Plugin.IsLobbyFlagEnabled(lobbyID, "MidMatch") ? "Yes" : "No");
stringBuilder.Append("Using Swapper: ").AppendLine(Plugin.IsLobbyFlagEnabled(lobbyID, "UsingCustomSwapper") ? "Yes" : "No");
stringBuilder.Append("Using Randomizer: ").AppendLine(Plugin.IsLobbyFlagEnabled(lobbyID, "UsingRandomizer") ? "Yes" : "No");
stringBuilder.Append("Using Outlines: ").AppendLine(Plugin.IsLobbyFlagEnabled(lobbyID, "UsingOutlines") ? "Yes" : "No");
stringBuilder.Append("Friendly Fire: ").AppendLine(Plugin.IsLobbyFlagEnabled(lobbyID, "UsingFriendlyFire") ? "Yes" : "No");
stringBuilder.Append("Host Kicks: ").AppendLine(Plugin.GetLobbyCount(lobbyID, "HostKickCount").ToString());
stringBuilder.Append("Host Bans: ").AppendLine(Plugin.GetLobbyCount(lobbyID, "BannedPlayerCount").ToString());
string lobbyData = SteamMatchmaking.GetLobbyData(lobbyID, "HostAddress");
if (ulong.TryParse(lobbyData, out var result) && result != 0)
{
if (Plugin.IsSteamFriend(result))
{
stringBuilder.AppendLine("Steam Friend: Yes");
}
if (Plugin.ShowRankInTooltip != null && Plugin.ShowRankInTooltip.Value && Plugin.CachedHostRanks.TryGetValue(result, out var value))
{
if (value.HasEntry)
{
stringBuilder.Append("Host Rank: #").AppendLine(value.Rank.ToString());
stringBuilder.Append("Host Score: ").AppendLine(value.Score.ToString());
}
else
{
stringBuilder.AppendLine("Host Rank: Unranked");
}
}
}
__result = stringBuilder.ToString();
}
}
}