Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ModSyncChecker v1.2.23
BepInEx\plugins\ModSyncChecker.dll
Decompiled 2 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Photon.Pun; using Photon.Realtime; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: ComVisible(false)] [assembly: AssemblyTitle("R.E.P.O. ModSyncChecker")] [assembly: AssemblyDescription("Host-based BepInEx MOD environment integrity checker.")] [assembly: AssemblyCompany("Codex")] [assembly: AssemblyProduct("ModSyncChecker")] [assembly: AssemblyFileVersion("1.2.21.0")] [assembly: AssemblyVersion("1.2.23.0")] namespace ModSyncChecker; public sealed class SyncConfig { internal ConfigEntry<bool> StrictMode; internal ConfigEntry<bool> AllowHostForceStart; internal ConfigEntry<bool> AutoKickMismatch; internal ConfigEntry<int> KickAfterSeconds; internal ConfigEntry<int> InitialTimeoutSeconds; internal ConfigEntry<int> RetryIntervalSeconds; internal ConfigEntry<int> MaxRetries; internal ConfigEntry<string> IgnorePluginGuids; internal ConfigEntry<string> IgnoreNameContains; internal ConfigEntry<bool> IgnoreSelf; internal ConfigEntry<bool> ShowLobbyOverlay; internal ConfigEntry<bool> EnableExtraFileHashing; internal ConfigEntry<string> ExtraExtensions; internal ConfigEntry<int> MaxFileSizeMB; internal static SyncConfig Bind(ConfigFile config) { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Expected O, but got Unknown //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Expected O, but got Unknown //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Expected O, but got Unknown //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Expected O, but got Unknown //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Expected O, but got Unknown //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Expected O, but got Unknown SyncConfig syncConfig = new SyncConfig(); Dictionary<ConfigDefinition, string> orphanedEntries = GetOrphanedEntries(config); syncConfig.StrictMode = config.Bind<bool>("强制规则", "严格模式", ReadLegacyBool(orphanedEntries, "Enforcement", "StrictMode", fallback: true), "开启后,当前房间内所有玩家都必须完成校验并显示一致,房主才能开始游戏。"); syncConfig.AutoKickMismatch = config.Bind<bool>("强制规则", "自动踢出不匹配玩家", ReadLegacyBool(orphanedEntries, "Enforcement", "AutoKickMismatch", fallback: false), "确认玩家 MOD 不一致后,是否在等待一段时间后自动将其踢出。默认关闭。"); syncConfig.KickAfterSeconds = config.Bind<int>("强制规则", "踢出等待秒数", ReadLegacyInt(orphanedEntries, "Enforcement", "KickAfterSeconds", 15), new ConfigDescription("启用自动踢出后,从确认不一致到踢出玩家之间等待的秒数。", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 120), new object[0])); syncConfig.AllowHostForceStart = config.Bind<bool>("强制规则", "允许危险强制开始", false, "危险选项:允许房主在玩家待校验、无响应或 MOD 不一致时仍然强制开始。建议保持关闭。"); syncConfig.InitialTimeoutSeconds = config.Bind<int>("网络校验", "首次超时秒数", ReadLegacyInt(orphanedEntries, "Network", "InitialTimeout", 5), new ConfigDescription("第一次校验请求发出后,等待多少秒再重试。", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 30), new object[0])); syncConfig.RetryIntervalSeconds = config.Bind<int>("网络校验", "重试间隔秒数", ReadLegacyInt(orphanedEntries, "Network", "RetryInterval", 2), new ConfigDescription("后续每次校验重试之间的间隔秒数。", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 30), new object[0])); syncConfig.MaxRetries = config.Bind<int>("网络校验", "最大重试次数", ReadLegacyInt(orphanedEntries, "Network", "MaxRetries", 2), new ConfigDescription("第一次请求失败后最多重试多少次;全部失败会标记为无响应。", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10), new object[0])); syncConfig.IgnorePluginGuids = config.Bind<string>("忽略规则", "忽略插件GUID", ReadLegacyString(orphanedEntries, "Ignore", "IgnorePluginGuids", string.Empty), new ConfigDescription("不参与比较的插件 GUID,多个值用英文逗号分隔。", (AcceptableValueBase)null, new object[1] { "HideFromREPOConfig" })); syncConfig.IgnoreNameContains = config.Bind<string>("忽略规则", "忽略名称关键词", ReadLegacyString(orphanedEntries, "Ignore", "IgnoreNameContains", string.Empty), new ConfigDescription("名称中包含这些关键词的 MOD 不参与比较,多个值用英文逗号分隔,不区分大小写。", (AcceptableValueBase)null, new object[1] { "HideFromREPOConfig" })); syncConfig.IgnoreSelf = config.Bind<bool>("忽略规则", "忽略本插件", ReadLegacyBool(orphanedEntries, "Ignore", "IgnoreSelf", fallback: true), "不把 MOD同步检查器自身加入玩家 MOD 清单。建议保持开启。"); syncConfig.ShowLobbyOverlay = config.Bind<bool>("界面", "在玩家列表显示校验状态", ReadLegacyBool(orphanedEntries, "界面", "显示大厅校验面板", ReadLegacyBool(orphanedEntries, "UI", "ShowLobbyOverlay", fallback: true)), "把房主判定的 MOD 校验结果直接显示在游戏大厅每位玩家的延迟数值左侧,不创建额外常驻窗口。"); syncConfig.EnableExtraFileHashing = config.Bind<bool>("资源校验", "启用资源文件校验", true, "除已加载的插件 DLL 外,同时校验 BepInEx/plugins 下的资源文件。建议保持开启。"); syncConfig.ExtraExtensions = config.Bind<string>("资源校验", "资源扩展名", ReadLegacyString(orphanedEntries, "FileIntegrity", "ExtraExtensions", ".repobundle,.bundle,.assetbundle"), new ConfigDescription("需要加入校验清单的资源文件扩展名,多个值用英文逗号分隔。`.repobundle` 始终会被包含。", (AcceptableValueBase)null, new object[1] { "HideFromREPOConfig" })); syncConfig.MaxFileSizeMB = config.Bind<int>("资源校验", "最大哈希文件MB", ReadLegacyInt(orphanedEntries, "FileIntegrity", "MaxFileSizeMB", 512), new ConfigDescription("资源文件小于或等于此大小时计算完整 SHA256;更大的文件只比较文件大小。", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 2048), new object[0])); RemoveLegacyEntries(orphanedEntries); try { config.Save(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("保存中文配置失败:" + ex.Message)); } return syncConfig; } internal static Dictionary<ConfigDefinition, string> GetOrphanedEntries(ConfigFile config) { try { PropertyInfo property = typeof(ConfigFile).GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic); return (property != null) ? (property.GetValue(config, null) as Dictionary<ConfigDefinition, string>) : null; } catch { return null; } } internal static string ReadLegacyString(Dictionary<ConfigDefinition, string> legacy, string section, string key, string fallback) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown if (legacy == null) { return fallback; } if (!legacy.TryGetValue(new ConfigDefinition(section, key), out var value)) { return fallback; } return value; } internal static bool ReadLegacyBool(Dictionary<ConfigDefinition, string> legacy, string section, string key, bool fallback) { if (!bool.TryParse(ReadLegacyString(legacy, section, key, string.Empty), out var result)) { return fallback; } return result; } internal static int ReadLegacyInt(Dictionary<ConfigDefinition, string> legacy, string section, string key, int fallback) { if (!int.TryParse(ReadLegacyString(legacy, section, key, string.Empty), out var result)) { return fallback; } return result; } internal static void RemoveLegacyEntries(Dictionary<ConfigDefinition, string> legacy) { if (legacy != null) { string[] keys = new string[5] { "StrictMode", "AutoKickMismatch", "KickAfterSeconds", "AllowHostForceStart", "AllowUnsafeForceStart" }; string[] keys2 = new string[3] { "InitialTimeout", "RetryInterval", "MaxRetries" }; string[] keys3 = new string[3] { "IgnorePluginGuids", "IgnoreNameContains", "IgnoreSelf" }; string[] keys4 = new string[1] { "ShowLobbyOverlay" }; string[] keys5 = new string[4] { "EnableExtraFileHashing", "EnableResourceFileHashing", "ExtraExtensions", "MaxFileSizeMB" }; RemoveSectionKeys(legacy, "Enforcement", keys); RemoveSectionKeys(legacy, "Network", keys2); RemoveSectionKeys(legacy, "Ignore", keys3); RemoveSectionKeys(legacy, "UI", keys4); RemoveSectionKeys(legacy, "界面", new string[1] { "显示大厅校验面板" }); RemoveSectionKeys(legacy, "FileIntegrity", keys5); } } internal static void RemoveSectionKeys(Dictionary<ConfigDefinition, string> legacy, string section, IEnumerable<string> keys) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown foreach (string key in keys) { legacy.Remove(new ConfigDefinition(section, key)); } } internal HashSet<string> GetIgnoredGuids() { return new HashSet<string>(Split(IgnorePluginGuids.Value), StringComparer.OrdinalIgnoreCase); } internal string[] GetIgnoredNameFragments() { return Split(IgnoreNameContains.Value); } internal HashSet<string> GetExtraExtensions() { HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase); string[] array = Split(ExtraExtensions.Value); foreach (string text in array) { string item = (text.StartsWith(".", StringComparison.Ordinal) ? text : ("." + text)); hashSet.Add(item); } hashSet.Add(".repobundle"); return hashSet; } internal static string[] Split(string value) { if (string.IsNullOrEmpty(value)) { return new string[0]; } return (from x in value.Split(new char[4] { ',', ';', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries) select x.Trim() into x where x.Length > 0 select x).ToArray(); } } public static class HashUtil { internal static string ComputeFileHash(string path) { using FileStream inputStream = File.OpenRead(path); using SHA256 sHA = SHA256.Create(); return "sha256:" + ToHex(sHA.ComputeHash(inputStream)); } internal static string ComputeFingerprint(IEnumerable<ModManifestEntry> entries) { StringBuilder stringBuilder = new StringBuilder(); foreach (ModManifestEntry entry in entries) { stringBuilder.Append(entry.Guid ?? string.Empty); stringBuilder.Append('\0'); stringBuilder.Append(entry.Version ?? string.Empty); stringBuilder.Append('\0'); stringBuilder.Append(entry.ContentHash ?? string.Empty); stringBuilder.Append('\n'); } using SHA256 sHA = SHA256.Create(); return ToHex(sHA.ComputeHash(Encoding.UTF8.GetBytes(stringBuilder.ToString()))); } internal static string ComputeTextHash(string value) { using SHA256 sHA = SHA256.Create(); return ToHex(sHA.ComputeHash(Encoding.UTF8.GetBytes(value ?? string.Empty))); } internal static string ToHex(byte[] bytes) { StringBuilder stringBuilder = new StringBuilder(bytes.Length * 2); for (int i = 0; i < bytes.Length; i++) { stringBuilder.Append(bytes[i].ToString("x2")); } return stringBuilder.ToString(); } } public enum IntegrityDifferenceType { Missing, Extra, VersionMismatch, ContentMismatch } public sealed class IntegrityDifference { internal IntegrityDifferenceType Type; internal string Guid; internal string Name; internal string HostVersion; internal string ClientVersion; internal string HostHash; internal string ClientHash; internal string ToShortString() { return Type switch { IntegrityDifferenceType.Missing => $"MISSING {Name} {HostVersion}", IntegrityDifferenceType.Extra => $"EXTRA {Name} {ClientVersion}", IntegrityDifferenceType.VersionMismatch => $"VERSION_MISMATCH {Name}: {HostVersion} -> {ClientVersion}", _ => $"CONTENT_MISMATCH {Name} {HostVersion}", }; } } public sealed class ModManifest { internal const int MaxEntries = 256; internal IReadOnlyList<ModManifestEntry> Entries { get; set; } internal string Fingerprint { get; set; } internal ModManifest(IReadOnlyList<ModManifestEntry> entries, string fingerprint) { Entries = entries; Fingerprint = fingerprint; } internal static bool TryCreate(IEnumerable<ModManifestEntry> source, out ModManifest manifest, out string error) { manifest = null; error = null; if (source == null) { error = "manifest-null"; return false; } List<ModManifestEntry> list = source.Where((ModManifestEntry x) => x != null).OrderBy<ModManifestEntry, string>((ModManifestEntry x) => x.Guid, StringComparer.OrdinalIgnoreCase).ToList(); if (list.Count > 256) { error = "too-many-plugins"; return false; } HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase); foreach (ModManifestEntry item in list) { if (string.IsNullOrEmpty(item.Guid)) { error = "empty-guid"; return false; } if (!hashSet.Add(item.Guid)) { error = "duplicate-guid:" + item.Guid; return false; } } string fingerprint = HashUtil.ComputeFingerprint(list); manifest = new ModManifest(list.AsReadOnly(), fingerprint); return true; } internal ModManifestEntry Find(string guid) { if (guid == null) { return null; } return Entries.FirstOrDefault((ModManifestEntry x) => string.Equals(x.Guid, guid, StringComparison.OrdinalIgnoreCase)); } } public sealed class ModManifestCollector { internal sealed class PluginSnapshot { internal string Guid; internal string Name; internal string Version; internal string Location; internal Guid ModuleVersionId; internal string AssemblyFullName; internal bool IsResource; internal long MaxHashBytes; } internal sealed class ResourcePackageInfo { internal string Name; internal string Version; } internal sealed class CollectionResult { internal ModManifest Manifest; internal string Error; } internal readonly SyncConfig _config; internal Task<CollectionResult> _task; internal ModManifest _result; internal string _error; internal bool _started; internal bool IsReady => _result != null; internal bool IsFailed => _error != null; internal string Error => _error; internal ModManifest Result => _result; internal ModManifestCollector(SyncConfig config) { _config = config; } internal void EnsureStarted() { if (_started) { return; } _started = true; try { List<PluginSnapshot> snapshots = new List<PluginSnapshot>(); HashSet<string> ignoredGuids = _config.GetIgnoredGuids(); string[] ignoredNameFragments = _config.GetIgnoredNameFragments(); foreach (PluginInfo value in Chainloader.PluginInfos.Values) { if (value != null && value.Metadata != null) { string text = value.Metadata.GUID ?? string.Empty; string name = value.Metadata.Name ?? string.Empty; if ((!_config.IgnoreSelf.Value || !string.Equals(text, "com.codex.modsyncchecker", StringComparison.OrdinalIgnoreCase)) && !ignoredGuids.Contains(text) && !ignoredNameFragments.Any((string fragment) => name.IndexOf(fragment, StringComparison.OrdinalIgnoreCase) >= 0)) { Assembly assembly = (((Object)(object)value.Instance != (Object)null) ? ((object)value.Instance).GetType().Assembly : null); snapshots.Add(new PluginSnapshot { Guid = Bound(text, 128), Name = Bound(name, 256), Version = Bound((value.Metadata.Version != null) ? value.Metadata.Version.ToString() : string.Empty, 64), Location = value.Location, ModuleVersionId = ((assembly != null) ? assembly.ManifestModule.ModuleVersionId : Guid.Empty), AssemblyFullName = ((assembly != null) ? assembly.FullName : string.Empty), IsResource = false, MaxHashBytes = long.MaxValue }); } } } int count = snapshots.Count; int num = 0; if (_config.EnableExtraFileHashing.Value) { num = AddResourceSnapshots(snapshots, ignoredGuids, ignoredNameFragments); } _task = Task.Run(() => Collect(snapshots)); Plugin.Log.LogInfo((object)$"Manifest collection started: {count} plugins, {num} resource files."); } catch (Exception ex) { Fail(ex.GetType().Name); } } internal void Poll() { if (_task == null || !_task.IsCompleted || _result != null || _error != null) { return; } try { CollectionResult result = _task.GetAwaiter().GetResult(); if (result.Manifest == null) { Fail(result.Error ?? "manifest-failed"); return; } _result = result.Manifest; Plugin.Log.LogInfo((object)$"Manifest ready: {_result.Entries.Count} entries, fp={Prefix(_result.Fingerprint, 8)}"); } catch (Exception ex) { Fail(ex.GetType().Name); } } internal void EnsureReadyBlocking() { EnsureStarted(); if (_task == null || _result != null || _error != null) { return; } try { _task.Wait(); Poll(); } catch (Exception ex) { Fail(ex.GetType().Name); } } internal void Fail(string error) { _error = (string.IsNullOrEmpty(error) ? "manifest-failed" : error); Plugin.Log.LogError((object)("Manifest collection failed: " + _error)); } internal static CollectionResult Collect(IReadOnlyList<PluginSnapshot> snapshots) { List<ModManifestEntry> list = new List<ModManifestEntry>(snapshots.Count); for (int i = 0; i < snapshots.Count; i++) { PluginSnapshot pluginSnapshot = snapshots[i]; list.Add(new ModManifestEntry(pluginSnapshot.Guid, pluginSnapshot.Name, pluginSnapshot.Version, BuildContentId(pluginSnapshot))); } if (!ModManifest.TryCreate(list, out var manifest, out var error)) { CollectionResult collectionResult = new CollectionResult(); collectionResult.Error = error; return collectionResult; } CollectionResult collectionResult2 = new CollectionResult(); collectionResult2.Manifest = manifest; return collectionResult2; } internal static string BuildContentId(PluginSnapshot plugin) { if (!string.IsNullOrEmpty(plugin.Location) && File.Exists(plugin.Location)) { try { if (plugin.IsResource) { long length = new FileInfo(plugin.Location).Length; if (length > plugin.MaxHashBytes) { return "size-only:" + length; } } return HashUtil.ComputeFileHash(plugin.Location); } catch (Exception ex) { Plugin.Log.LogWarning((object)("DLL hash failed for " + plugin.Guid + ": " + ex.Message)); } } if (plugin.IsResource) { return "resource-unreadable"; } if (plugin.ModuleVersionId != Guid.Empty) { return "mvid:" + plugin.ModuleVersionId.ToString("D").ToLowerInvariant(); } return Bound("metadata:" + (plugin.AssemblyFullName ?? string.Empty), 160); } internal static string Bound(string value, int maxLength) { if (value == null) { value = string.Empty; } if (value.Length > maxLength) { return value.Substring(0, maxLength); } return value; } internal static string Prefix(string value, int length) { if (string.IsNullOrEmpty(value)) { return string.Empty; } if (value.Length > length) { return value.Substring(0, length); } return value; } internal int AddResourceSnapshots(List<PluginSnapshot> snapshots, HashSet<string> ignoredGuids, string[] ignoredNames) { string pluginPath = Paths.PluginPath; if (string.IsNullOrEmpty(pluginPath) || !Directory.Exists(pluginPath)) { return 0; } HashSet<string> extraExtensions = _config.GetExtraExtensions(); long maxHashBytes = (long)Math.Max(1, _config.MaxFileSizeMB.Value) * 1024L * 1024; int num = 0; foreach (string item in Directory.EnumerateFiles(pluginPath, "*", SearchOption.AllDirectories)) { string extension = Path.GetExtension(item); if (extraExtensions.Contains(extension)) { MakeRelativePath(pluginPath, item).Replace('\\', '/'); ResourcePackageInfo resourcePackageInfo = ReadNearbyPackageInfo(pluginPath, item); string fileName = Path.GetFileName(item); string text = ((!string.IsNullOrEmpty(resourcePackageInfo.Name)) ? (resourcePackageInfo.Name + "/" + fileName) : fileName); string text2 = "resource:" + text.ToLowerInvariant(); if (text2.Length > 128) { text2 = "resource:" + HashUtil.ComputeTextHash(text.ToLowerInvariant()); } string name = new DirectoryInfo(Path.GetDirectoryName(item)).Name; string text3 = ((!string.IsNullOrEmpty(resourcePackageInfo.Name)) ? resourcePackageInfo.Name : name); string displayName = "[资源] " + text3 + "/" + fileName; if (!ignoredGuids.Contains(text2) && !ignoredNames.Any((string fragment) => displayName.IndexOf(fragment, StringComparison.OrdinalIgnoreCase) >= 0)) { snapshots.Add(new PluginSnapshot { Guid = Bound(text2, 128), Name = Bound(displayName, 256), Version = Bound(resourcePackageInfo.Version, 64), Location = item, ModuleVersionId = Guid.Empty, AssemblyFullName = string.Empty, IsResource = true, MaxHashBytes = maxHashBytes }); num++; } } } return num; } internal static ResourcePackageInfo ReadNearbyPackageInfo(string pluginRoot, string file) { ResourcePackageInfo resourcePackageInfo = new ResourcePackageInfo(); resourcePackageInfo.Name = string.Empty; resourcePackageInfo.Version = "resource"; ResourcePackageInfo resourcePackageInfo2 = resourcePackageInfo; string text = Path.GetFullPath(pluginRoot).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); string directoryName = Path.GetDirectoryName(Path.GetFullPath(file)); while (!string.IsNullOrEmpty(directoryName) && directoryName.StartsWith(text, StringComparison.OrdinalIgnoreCase)) { string path = Path.Combine(directoryName, "manifest.json"); if (File.Exists(path)) { try { string input = File.ReadAllText(path); Match match = Regex.Match(input, "\"name\"\\s*:\\s*\"([^\"]+)\"", RegexOptions.IgnoreCase); Match match2 = Regex.Match(input, "\"(?:version_number|versionNumber)\"\\s*:\\s*\"([^\"]+)\"", RegexOptions.IgnoreCase); if (match.Success) { resourcePackageInfo2.Name = match.Groups[1].Value; } if (match2.Success) { resourcePackageInfo2.Version = match2.Groups[1].Value; } return resourcePackageInfo2; } catch { } } if (string.Equals(directoryName.TrimEnd(new char[1] { Path.DirectorySeparatorChar }), text, StringComparison.OrdinalIgnoreCase)) { break; } directoryName = Path.GetDirectoryName(directoryName); } return resourcePackageInfo2; } internal static string MakeRelativePath(string root, string file) { string uriString = Path.GetFullPath(root).TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar) + Path.DirectorySeparatorChar; Uri uri = new Uri(uriString); Uri uri2 = new Uri(Path.GetFullPath(file)); return Uri.UnescapeDataString(uri.MakeRelativeUri(uri2).ToString()); } } public static class ModManifestComparer { internal static List<IntegrityDifference> Compare(ModManifest host, ModManifest client) { List<IntegrityDifference> list = new List<IntegrityDifference>(); if (host == null || client == null) { return list; } Dictionary<string, ModManifestEntry> dictionary = new Dictionary<string, ModManifestEntry>(StringComparer.OrdinalIgnoreCase); foreach (ModManifestEntry entry in client.Entries) { dictionary[entry.Guid] = entry; } Dictionary<string, ModManifestEntry> dictionary2 = new Dictionary<string, ModManifestEntry>(StringComparer.OrdinalIgnoreCase); foreach (ModManifestEntry entry2 in host.Entries) { dictionary2[entry2.Guid] = entry2; } foreach (ModManifestEntry entry3 in host.Entries) { if (!dictionary.TryGetValue(entry3.Guid, out var value)) { list.Add(new IntegrityDifference { Type = IntegrityDifferenceType.Missing, Guid = entry3.Guid, Name = entry3.Name, HostVersion = entry3.Version, HostHash = entry3.ContentHash }); } else if (!string.Equals(entry3.Version, value.Version, StringComparison.Ordinal)) { list.Add(new IntegrityDifference { Type = IntegrityDifferenceType.VersionMismatch, Guid = entry3.Guid, Name = entry3.Name, HostVersion = entry3.Version, ClientVersion = value.Version, HostHash = entry3.ContentHash, ClientHash = value.ContentHash }); } else if (!string.Equals(entry3.ContentHash, value.ContentHash, StringComparison.OrdinalIgnoreCase)) { list.Add(new IntegrityDifference { Type = IntegrityDifferenceType.ContentMismatch, Guid = entry3.Guid, Name = entry3.Name, HostVersion = entry3.Version, ClientVersion = value.Version, HostHash = entry3.ContentHash, ClientHash = value.ContentHash }); } } foreach (ModManifestEntry entry4 in client.Entries) { if (!dictionary2.ContainsKey(entry4.Guid)) { list.Add(new IntegrityDifference { Type = IntegrityDifferenceType.Extra, Guid = entry4.Guid, Name = entry4.Name, ClientVersion = entry4.Version, ClientHash = entry4.ContentHash }); } } return list; } } public sealed class ModManifestEntry { internal string Guid { get; set; } internal string Name { get; set; } internal string Version { get; set; } internal string ContentHash { get; set; } internal string ShortHash { get { if (string.IsNullOrEmpty(ContentHash)) { return "-"; } if (ContentHash.Length > 16) { return ContentHash.Substring(0, 16); } return ContentHash; } } internal ModManifestEntry(string guid, string name, string version, string contentHash) { Guid = guid ?? string.Empty; Name = name ?? string.Empty; Version = version ?? string.Empty; ContentHash = contentHash ?? string.Empty; } public override string ToString() { return $"{Name} {Version} ({Guid})"; } } public sealed class ModSyncRuntime { internal SyncConfig _config; internal ModManifestCollector _collector; internal PhotonTransport _transport; internal LobbyPlayerListStatusUi _playerListStatusUi; internal HostIntegrityState _hostState = new HostIntegrityState(); internal ClientIntegrityState _clientState = new ClientIntegrityState(); internal readonly Dictionary<int, ManifestChunkAssembler> _assemblers = new Dictionary<int, ManifestChunkAssembler>(); internal bool _initialized; internal bool _roomActive; internal string _roomName = string.Empty; internal string _rosterSignature = string.Empty; internal int _masterActor; internal long _epoch; internal string _lastBaselineFingerprint = string.Empty; internal bool _snapshotDirty; internal float _lastSnapshotTime; internal bool _clientHelloSent; internal bool _startPromptOpen; internal bool _allowNextStart; internal MenuPageLobby _startInstance; internal string _startReason = string.Empty; internal bool _detailPromptOpen; internal bool _detailPopupScheduled; internal Vector2 _detailScroll; internal string _detailTitle = string.Empty; internal string _detailText = string.Empty; internal int _detailRequestedActor; internal int _lastTickFrame = -1; internal bool _runtimeLoopLogged; internal EventData _lastPhotonEvent; internal int _lastPhotonEventFrame = -1; internal static ModSyncRuntime Instance { get; set; } internal void Initialize(SyncConfig config) { if (!_initialized) { Instance = this; _config = config; _collector = new ModManifestCollector(config); _transport = new PhotonTransport(); _playerListStatusUi = new LobbyPlayerListStatusUi(); _playerListStatusUi.StatusClicked += HandleStatusClicked; _transport.EventReceived += ReceivePhotonEvent; _initialized = true; } } internal void ReceivePhotonEvent(EventData photonEvent) { if (photonEvent != null) { int frameCount = Time.frameCount; if (!object.ReferenceEquals(_lastPhotonEvent, photonEvent) || _lastPhotonEventFrame != frameCount) { _lastPhotonEvent = photonEvent; _lastPhotonEventFrame = frameCount; OnPhotonEvent(photonEvent); } } } internal void Tick() { if (!_initialized) { return; } int frameCount = Time.frameCount; if (_lastTickFrame == frameCount) { return; } _lastTickFrame = frameCount; if (!_runtimeLoopLogged) { _runtimeLoopLogged = true; Plugin.Log.LogInfo((object)"Runtime loop active; manifest and Photon checks are now running."); } try { _collector.EnsureStarted(); _collector.Poll(); _transport.Update(); if (!PhotonNetwork.InRoom || PhotonNetwork.CurrentRoom == null) { if (_playerListStatusUi != null) { _playerListStatusUi.Restore(); } if (_roomActive) { LeaveRoomView(); } return; } string text = PhotonNetwork.CurrentRoom.Name ?? string.Empty; int num = ((PhotonNetwork.MasterClient != null) ? PhotonNetwork.MasterClient.ActorNumber : 0); if (!_roomActive || !string.Equals(text, _roomName, StringComparison.Ordinal)) { EnterRoomView(text, num); } else if (num != _masterActor) { HandleMasterChanged(num); } if (PhotonNetwork.IsMasterClient) { TickHost(); if (_snapshotDirty && Time.unscaledTime - _lastSnapshotTime >= 0.1f) { BroadcastSnapshot(); } } else { TickClient(); } } catch (Exception ex) { Plugin.Log.LogError((object)("Runtime update failed safely: " + ex)); } } internal void EnterRoomView(string roomName, int masterActor) { _roomActive = true; _roomName = roomName; _masterActor = masterActor; _epoch = NewEpoch(); _rosterSignature = string.Empty; _assemblers.Clear(); _clientHelloSent = false; _lastBaselineFingerprint = string.Empty; _hostState.Reset(_epoch); _clientState.Reset(_epoch); _snapshotDirty = true; Plugin.Log.LogInfo((object)$"Room entered: {_roomName}; master={_masterActor}; epoch={_epoch}"); } internal void RefreshPlayerListUi() { if (_initialized && _playerListStatusUi != null) { if (!_roomActive || !PhotonNetwork.InRoom) { _playerListStatusUi.Restore(); return; } IList<IntegrityWire.SnapshotPlayerData> statuses = (PhotonNetwork.IsMasterClient ? _hostState.ToSnapshot().Players : _clientState.Players); _playerListStatusUi.Refresh(statuses, _config.ShowLobbyOverlay.Value); } } internal void HandlePlayerListInput() { if (_initialized && _playerListStatusUi != null && _roomActive && PhotonNetwork.InRoom) { _playerListStatusUi.HandleInput(); } } internal void LeaveRoomView() { if (_playerListStatusUi != null) { _playerListStatusUi.Restore(); } _roomActive = false; _roomName = string.Empty; _masterActor = 0; _rosterSignature = string.Empty; _assemblers.Clear(); _clientHelloSent = false; _startPromptOpen = false; _startInstance = null; _detailPromptOpen = false; _detailPopupScheduled = false; _detailRequestedActor = 0; _hostState.Reset(0L); _clientState.Reset(0L); Plugin.Log.LogInfo((object)"Room left; integrity state cleared."); } internal void HandleMasterChanged(int masterActor) { _masterActor = masterActor; _assemblers.Clear(); _clientHelloSent = false; if (PhotonNetwork.IsMasterClient) { _epoch = NewEpoch(); _hostState.Reset(_epoch); _lastBaselineFingerprint = string.Empty; _rosterSignature = string.Empty; _snapshotDirty = true; Plugin.Log.LogInfo((object)("Master client migrated to this player; created new integrity epoch " + _epoch + ".")); } else { _epoch = 0L; _clientState.Reset(0L); Plugin.Log.LogInfo((object)"Master client changed; waiting for the new host integrity request."); } } internal void TickHost() { Player[] array = (Player[])(((object)PhotonNetwork.PlayerList) ?? ((object)new Player[0])); HashSet<int> hashSet = new HashSet<int>(array.Select((Player x) => x.ActorNumber)); string text = string.Join(",", (from x in array orderby x.ActorNumber select x.ActorNumber.ToString()).ToArray()); if (!string.Equals(text, _rosterSignature, StringComparison.Ordinal)) { _rosterSignature = text; _hostState.RemoveExcept(hashSet); foreach (int item in _assemblers.Keys.ToList()) { if (!hashSet.Contains(item)) { _assemblers.Remove(item); } } Player[] array2 = array; foreach (Player val in array2) { HostPlayerIntegrity hostPlayerIntegrity = _hostState.Ensure(val); if (val.ActorNumber != PhotonNetwork.LocalPlayer.ActorNumber) { hostPlayerIntegrity.State = PlayerIntegrityState.Pending; hostPlayerIntegrity.Summary = "正在等待校验"; hostPlayerIntegrity.Differences.Clear(); hostPlayerIntegrity.Attempts = 0; hostPlayerIntegrity.PendingSinceUtc = DateTime.UtcNow; hostPlayerIntegrity.LastRequestUtc = DateTime.MinValue; hostPlayerIntegrity.ReportedFingerprint = string.Empty; hostPlayerIntegrity.ReportedEntryCount = -1; } } _snapshotDirty = true; Plugin.Log.LogInfo((object)("Roster changed; integrity checks restarted for " + array.Length + " players.")); } HostPlayerIntegrity hostPlayerIntegrity2 = _hostState.Ensure(PhotonNetwork.LocalPlayer); if (_collector.IsReady) { if (hostPlayerIntegrity2 != null && hostPlayerIntegrity2.State != PlayerIntegrityState.Match) { hostPlayerIntegrity2.State = PlayerIntegrityState.Match; hostPlayerIntegrity2.Summary = "MOD 一致"; hostPlayerIntegrity2.Differences.Clear(); _snapshotDirty = true; } string fingerprint = _collector.Result.Fingerprint; if (!string.Equals(fingerprint, _lastBaselineFingerprint, StringComparison.Ordinal)) { _lastBaselineFingerprint = fingerprint; Plugin.Log.LogInfo((object)$"Host baseline ready: {_collector.Result.Entries.Count} manifest entries, fp={Prefix(fingerprint, 8)}"); foreach (HostPlayerIntegrity player in _hostState.Players) { if (player.ActorNumber != PhotonNetwork.LocalPlayer.ActorNumber) { ResetToPending(player); } } _snapshotDirty = true; } { foreach (HostPlayerIntegrity item2 in _hostState.Players.ToList()) { if (item2.ActorNumber == PhotonNetwork.LocalPlayer.ActorNumber) { continue; } if (item2.State == PlayerIntegrityState.Pending) { DateTime utcNow = DateTime.UtcNow; if (item2.Attempts == 0) { RequestPlayer(item2); continue; } int num2 = ((item2.Attempts == 1) ? Math.Max(1, _config.InitialTimeoutSeconds.Value) : Math.Max(1, _config.RetryIntervalSeconds.Value)); if ((utcNow - item2.LastRequestUtc).TotalSeconds >= (double)num2) { if (item2.Attempts <= Math.Max(0, _config.MaxRetries.Value)) { RequestPlayer(item2); } else { SetUnavailable(item2, "未收到回应(超时)"); } } } else if (_config.AutoKickMismatch.Value && IsMismatch(item2) && item2.MismatchSinceUtc != DateTime.MinValue && (DateTime.UtcNow - item2.MismatchSinceUtc).TotalSeconds >= (double)Math.Max(1, _config.KickAfterSeconds.Value)) { TryKick(item2.ActorNumber); } } return; } } if (_collector.IsFailed && hostPlayerIntegrity2 != null && hostPlayerIntegrity2.State != PlayerIntegrityState.Unavailable) { hostPlayerIntegrity2.State = PlayerIntegrityState.Unavailable; hostPlayerIntegrity2.Summary = "本机清单失败:" + _collector.Error; _snapshotDirty = true; } } internal void TickClient() { if (_masterActor > 0 && _collector.IsReady && !_clientHelloSent) { _clientHelloSent = IntegrityWire.SendProtocolHello(_collector.Result.Fingerprint, _collector.Result.Entries.Count); if (_clientHelloSent) { Plugin.Log.LogInfo((object)$"Joined player proactively submitted manifest summary to host: {_collector.Result.Entries.Count} entries, fp={Prefix(_collector.Result.Fingerprint, 8)}."); } } } internal void RequestPlayer(HostPlayerIntegrity player) { player.Attempts++; player.LastRequestUtc = DateTime.UtcNow; player.PendingSinceUtc = ((player.PendingSinceUtc == DateTime.MinValue) ? DateTime.UtcNow : player.PendingSinceUtc); bool flag = IntegrityWire.SendManifestRequest(player.ActorNumber, _hostState.Epoch, _collector.Result.Fingerprint); Plugin.Log.LogInfo((object)$"Requested manifest from Player {player.ActorNumber} ({player.Nickname}), attempt {player.Attempts}, sent={flag}."); } internal void OnPhotonEvent(EventData photonEvent) { if (!_roomActive || photonEvent == null || !IsCurrentMember(photonEvent.Sender)) { return; } try { switch (photonEvent.Code) { case 180: if (PhotonNetwork.IsMasterClient && photonEvent.Sender != PhotonNetwork.LocalPlayer.ActorNumber) { HandleProtocolHello(photonEvent); } break; case 181: if (!PhotonNetwork.IsMasterClient) { HandleManifestRequest(photonEvent); } break; case 182: if (PhotonNetwork.IsMasterClient) { HandleManifestReport(photonEvent); } break; case 183: if (PhotonNetwork.IsMasterClient) { HandleManifestChunk(photonEvent); } break; case 184: if (!PhotonNetwork.IsMasterClient) { HandleSnapshot(photonEvent); } break; case 185: if (PhotonNetwork.IsMasterClient) { HandleDetailRequest(photonEvent); } break; case 186: if (!PhotonNetwork.IsMasterClient) { HandleDetailResponse(photonEvent); } break; } } catch (Exception ex) { Plugin.Log.LogError((object)("Rejected malformed integrity event safely: " + ex)); if (PhotonNetwork.IsMasterClient && photonEvent.Sender != PhotonNetwork.LocalPlayer.ActorNumber) { HostPlayerIntegrity hostPlayerIntegrity = _hostState.Get(photonEvent.Sender); if (hostPlayerIntegrity != null) { SetUnavailable(hostPlayerIntegrity, "数据包异常"); } } } } internal void HandleProtocolHello(EventData photonEvent) { if (!_collector.IsReady) { return; } Player player = ((PhotonNetwork.PlayerList == null) ? null : ((IEnumerable<Player>)PhotonNetwork.PlayerList).FirstOrDefault((Func<Player, bool>)((Player x) => x.ActorNumber == photonEvent.Sender))); HostPlayerIntegrity hostPlayerIntegrity = _hostState.Get(photonEvent.Sender) ?? _hostState.Ensure(player); if (hostPlayerIntegrity == null) { return; } if (!IntegrityWire.TryReadProtocolHello(photonEvent, out var hello)) { Plugin.Log.LogWarning((object)$"Player {hostPlayerIntegrity.ActorNumber} ({hostPlayerIntegrity.Nickname}) did not provide a valid proactive manifest summary; host will request it."); ResetToPending(hostPlayerIntegrity); RequestPlayer(hostPlayerIntegrity); return; } hostPlayerIntegrity.ReportedFingerprint = hello.Fingerprint; hostPlayerIntegrity.ReportedEntryCount = hello.EntryCount; Plugin.Log.LogInfo((object)$"Player {hostPlayerIntegrity.ActorNumber} ({hostPlayerIntegrity.Nickname}) proactively submitted manifest summary: {hello.EntryCount} entries, fp={Prefix(hello.Fingerprint, 8)}."); if (string.Equals(hello.Fingerprint, _collector.Result.Fingerprint, StringComparison.OrdinalIgnoreCase)) { SetMatch(hostPlayerIntegrity); return; } hostPlayerIntegrity.State = PlayerIntegrityState.Pending; hostPlayerIntegrity.Summary = "客户端已提交摘要,正在索要完整清单"; hostPlayerIntegrity.Differences.Clear(); hostPlayerIntegrity.Attempts = 0; hostPlayerIntegrity.PendingSinceUtc = DateTime.UtcNow; hostPlayerIntegrity.LastRequestUtc = DateTime.MinValue; _snapshotDirty = true; RequestPlayer(hostPlayerIntegrity); } internal void HandleManifestRequest(EventData photonEvent) { if (!IntegrityWire.TryReadManifestRequest(photonEvent, out var epoch, out var hostFingerprint)) { return; } if (_epoch != epoch) { _epoch = epoch; _clientState.Reset(epoch); _assemblers.Clear(); } if (!_collector.IsReady) { Plugin.Log.LogWarning((object)"Received host request before local manifest was ready."); return; } bool flag = IntegrityWire.SendManifestReport(_masterActor, epoch, _collector.Result.Fingerprint, _collector.Result.Entries.Count); bool flag2 = !string.IsNullOrEmpty(hostFingerprint) && string.Equals(hostFingerprint, _collector.Result.Fingerprint, StringComparison.OrdinalIgnoreCase); Plugin.Log.LogInfo((object)$"Manifest verification sent to host: {_collector.Result.Entries.Count} entries, sameFingerprint={flag2}, sent={flag}."); if (!flag2) { SendManifestChunks(epoch); } } internal void SendManifestChunks(long epoch) { ModManifest result = _collector.Result; int num = (result.Entries.Count + 10 - 1) / 10; if (num == 0) { return; } if (num > 32) { Plugin.Log.LogError((object)"Local manifest is too large to send safely."); return; } for (int i = 0; i < num; i++) { List<ModManifestEntry> entries = result.Entries.Skip(i * 10).Take(10).ToList(); IntegrityWire.SendManifestChunk(_masterActor, epoch, i, num, entries); } } internal void HandleManifestReport(EventData photonEvent) { if (!IntegrityWire.TryReadManifestReport(photonEvent, out var report)) { SetUnavailable(_hostState.Get(photonEvent.Sender), "清单报告格式无效"); } else { if (report.Epoch != _hostState.Epoch) { return; } HostPlayerIntegrity hostPlayerIntegrity = _hostState.Get(photonEvent.Sender); if (hostPlayerIntegrity != null && _collector.IsReady) { hostPlayerIntegrity.ReportedFingerprint = report.Fingerprint; hostPlayerIntegrity.ReportedEntryCount = report.EntryCount; if (string.Equals(report.Fingerprint, _collector.Result.Fingerprint, StringComparison.OrdinalIgnoreCase)) { SetMatch(hostPlayerIntegrity); return; } if (report.EntryCount == 0) { SetUnavailable(hostPlayerIntegrity, "指纹不一致但清单为空"); return; } _assemblers[photonEvent.Sender] = new ManifestChunkAssembler(); hostPlayerIntegrity.State = PlayerIntegrityState.Pending; hostPlayerIntegrity.Summary = "已收到指纹,正在接收差异清单"; hostPlayerIntegrity.PendingSinceUtc = DateTime.UtcNow; _snapshotDirty = true; } } } internal void HandleManifestChunk(EventData photonEvent) { if (!IntegrityWire.TryReadManifestChunk(photonEvent, out var chunk)) { SetUnavailable(_hostState.Get(photonEvent.Sender), "清单分块格式无效"); } else { if (chunk.Epoch != _hostState.Epoch) { return; } HostPlayerIntegrity hostPlayerIntegrity = _hostState.Get(photonEvent.Sender); if (hostPlayerIntegrity == null || hostPlayerIntegrity.ReportedEntryCount < 0) { return; } ModManifest manifest; string error; if (!_assemblers.TryGetValue(photonEvent.Sender, out var value)) { SetUnavailable(hostPlayerIntegrity, "收到未请求的清单分块"); } else if (!value.TryAdd(chunk, out manifest, out error)) { if (!string.IsNullOrEmpty(error)) { SetUnavailable(hostPlayerIntegrity, "清单分块异常:" + error); } } else if (manifest != null) { _assemblers.Remove(photonEvent.Sender); if (manifest.Entries.Count != hostPlayerIntegrity.ReportedEntryCount) { SetUnavailable(hostPlayerIntegrity, $"清单数量不一致:报告 {hostPlayerIntegrity.ReportedEntryCount},实际 {manifest.Entries.Count}"); } else if (!string.Equals(manifest.Fingerprint, hostPlayerIntegrity.ReportedFingerprint, StringComparison.OrdinalIgnoreCase)) { SetUnavailable(hostPlayerIntegrity, "清单指纹与报告不一致"); } else { ApplyComparison(hostPlayerIntegrity, ModManifestComparer.Compare(_collector.Result, manifest)); } } } } internal void HandleSnapshot(EventData photonEvent) { if (!IsCurrentMaster(photonEvent.Sender) || !IntegrityWire.TryReadSnapshot(photonEvent, out var snapshot)) { return; } if (_epoch == 0 || snapshot.Epoch != _epoch) { _epoch = snapshot.Epoch; _clientState.Reset(snapshot.Epoch); } if (_clientState.Apply(snapshot)) { int num = snapshot.Players.Count((IntegrityWire.SnapshotPlayerData x) => x.State != PlayerIntegrityState.Match && x.State != PlayerIntegrityState.Pending); Plugin.Log.LogInfo((object)$"Received host integrity broadcast: sequence={snapshot.Sequence}, players={snapshot.Players.Count}, problems={num}."); } } internal void HandleDetailRequest(EventData photonEvent) { if (IsCurrentMember(photonEvent.Sender) && IntegrityWire.TryReadDetailRequest(photonEvent, out var epoch, out var requestedActor) && epoch == _hostState.Epoch && IsCurrentMember(requestedActor)) { IntegrityWire.SnapshotData snapshotData = _hostState.ToSnapshot(); IntegrityWire.SnapshotPlayerData snapshotPlayerData = snapshotData.Players.FirstOrDefault((IntegrityWire.SnapshotPlayerData x) => x.ActorNumber == requestedActor); IntegrityWire.SnapshotData snapshotData2 = new IntegrityWire.SnapshotData(); snapshotData2.Epoch = snapshotData.Epoch; snapshotData2.Sequence = snapshotData.Sequence; IntegrityWire.SnapshotData snapshotData3 = snapshotData2; if (snapshotPlayerData != null) { snapshotData3.Players.Add(snapshotPlayerData); } bool flag = IntegrityWire.SendDetailResponse(snapshotData3, photonEvent.Sender); Plugin.Log.LogInfo((object)$"Sent targeted integrity details: requester={photonEvent.Sender}, player={requestedActor}, sent={flag}."); } } internal void HandleDetailResponse(EventData photonEvent) { if (IsCurrentMaster(photonEvent.Sender) && IntegrityWire.TryReadSnapshot(photonEvent, out var snapshot) && _clientState.MergeDetails(snapshot)) { int requestedActor = _detailRequestedActor; _detailRequestedActor = 0; IntegrityWire.SnapshotPlayerData snapshotPlayerData = _clientState.Players.FirstOrDefault((IntegrityWire.SnapshotPlayerData x) => x.ActorNumber == requestedActor); if (snapshotPlayerData != null) { OpenDetail(snapshotPlayerData); } } } internal void ApplyComparison(HostPlayerIntegrity player, List<IntegrityDifference> differences) { if (player == null) { return; } player.Differences = differences ?? new List<IntegrityDifference>(); if (player.Differences.Count == 0) { SetMatch(player); return; } player.State = GetPrimaryState(player.Differences); player.Summary = BuildSummary(player.Differences); player.MismatchSinceUtc = ((player.MismatchSinceUtc == DateTime.MinValue) ? DateTime.UtcNow : player.MismatchSinceUtc); Plugin.Log.LogWarning((object)$"Player {player.ActorNumber} ({player.Nickname}) mismatch: {player.Summary}"); foreach (IntegrityDifference item in player.Differences.Take(32)) { Plugin.Log.LogWarning((object)(" " + item.ToShortString() + " [" + item.Guid + "]")); } _snapshotDirty = true; } internal void SetMatch(HostPlayerIntegrity player) { if (player != null) { player.State = PlayerIntegrityState.Match; player.Summary = "MOD 一致"; player.Differences.Clear(); player.MismatchSinceUtc = DateTime.MinValue; Plugin.Log.LogInfo((object)$"Player {player.ActorNumber} ({player.Nickname}) MATCH"); _snapshotDirty = true; } } internal void SetUnavailable(HostPlayerIntegrity player, string reason) { if (player != null) { player.State = PlayerIntegrityState.Unavailable; player.Summary = "? " + (reason ?? "未响应"); player.Differences.Clear(); _snapshotDirty = true; Plugin.Log.LogWarning((object)$"Player {player.ActorNumber} ({player.Nickname}) UNAVAILABLE: {reason}"); } } internal bool PrefixStart(MenuPageLobby instance) { if (_allowNextStart) { _allowNextStart = false; return true; } if (!_config.StrictMode.Value || !PhotonNetwork.InRoom || !PhotonNetwork.IsMasterClient) { return true; } Plugin.Log.LogInfo((object)"Host Start button intercepted by strict-mode gate."); if (!TryBuildBlockingReason(out var reason)) { Plugin.Log.LogInfo((object)"Start gate passed: every current room player has a MATCH result."); return true; } _startInstance = instance; _startReason = reason; _startPromptOpen = true; Plugin.Log.LogWarning((object)("Start blocked: " + _startReason)); return false; } internal bool TryBuildBlockingReason(out string reason) { reason = string.Empty; if (!_roomActive || !_collector.IsReady || _collector.IsFailed) { reason = "校验器尚未准备完成,不能安全开始"; return true; } Player[] playerList = PhotonNetwork.PlayerList; if (playerList == null || playerList.Length == 0) { reason = "未能读取当前房间玩家,不能安全开始"; return true; } List<string> list = new List<string>(); foreach (Player item in playerList.OrderBy((Player x) => x.ActorNumber)) { HostPlayerIntegrity hostPlayerIntegrity = _hostState.Get(item.ActorNumber); string text = (string.IsNullOrEmpty(item.NickName) ? ("Actor " + item.ActorNumber) : item.NickName); if (hostPlayerIntegrity == null) { list.Add(text + ": 尚未开始校验"); } else if (hostPlayerIntegrity.State != PlayerIntegrityState.Match) { list.Add($"{hostPlayerIntegrity.Nickname}: {hostPlayerIntegrity.Summary}"); } } if (list.Count == 0) { return false; } reason = string.Join(";", list.ToArray()); return true; } internal void BroadcastSnapshot() { _hostState.NextSequence(); IntegrityWire.SnapshotData snapshotData = _hostState.ToSnapshot(); bool flag = IntegrityWire.SendSnapshot(snapshotData, 0); _snapshotDirty = false; _lastSnapshotTime = Time.unscaledTime; Plugin.Log.LogInfo((object)$"Host broadcast integrity results to the room: sequence={snapshotData.Sequence}, players={snapshotData.Players.Count}, sent={flag}."); } internal void ResetToPending(HostPlayerIntegrity player) { player.State = PlayerIntegrityState.Pending; player.Summary = "正在等待校验"; player.Differences.Clear(); player.Attempts = 0; player.PendingSinceUtc = DateTime.UtcNow; player.LastRequestUtc = DateTime.MinValue; player.ReportedFingerprint = string.Empty; player.ReportedEntryCount = -1; } internal bool IsCurrentMember(int actorNumber) { if (actorNumber <= 0 || PhotonNetwork.PlayerList == null) { return false; } return PhotonNetwork.PlayerList.Any((Player x) => x != null && x.ActorNumber == actorNumber); } internal bool IsCurrentMaster(int actorNumber) { if (PhotonNetwork.MasterClient != null) { return PhotonNetwork.MasterClient.ActorNumber == actorNumber; } return false; } internal static PlayerIntegrityState GetPrimaryState(List<IntegrityDifference> differences) { if (differences == null || differences.Count == 0) { return PlayerIntegrityState.Match; } HashSet<IntegrityDifferenceType> hashSet = new HashSet<IntegrityDifferenceType>(differences.Select((IntegrityDifference x) => x.Type)); if (hashSet.Count > 1) { return PlayerIntegrityState.MixedMismatch; } return differences[0].Type switch { IntegrityDifferenceType.Missing => PlayerIntegrityState.Missing, IntegrityDifferenceType.Extra => PlayerIntegrityState.Extra, IntegrityDifferenceType.VersionMismatch => PlayerIntegrityState.VersionMismatch, _ => PlayerIntegrityState.ContentMismatch, }; } internal static string BuildSummary(List<IntegrityDifference> differences) { int num = differences.Count((IntegrityDifference x) => x.Type == IntegrityDifferenceType.Missing); int num2 = differences.Count((IntegrityDifference x) => x.Type == IntegrityDifferenceType.Extra); int num3 = differences.Count((IntegrityDifference x) => x.Type == IntegrityDifferenceType.VersionMismatch); int num4 = differences.Count((IntegrityDifference x) => x.Type == IntegrityDifferenceType.ContentMismatch); return $"✕ 不一致:缺少 {num},额外 {num2},版本 {num3},内容 {num4}"; } internal static bool IsMismatch(HostPlayerIntegrity player) { if (player != null && player.State != PlayerIntegrityState.Match && player.State != PlayerIntegrityState.Pending) { return player.State != PlayerIntegrityState.Unavailable; } return false; } internal void TryKick(int actorNumber) { try { Player val = ((IEnumerable<Player>)PhotonNetwork.PlayerList).FirstOrDefault((Func<Player, bool>)((Player x) => x.ActorNumber == actorNumber)); if (val != null) { MethodInfo methodInfo = AccessTools.Method(typeof(PhotonNetwork), "CloseConnection", new Type[1] { typeof(Player) }, (Type[])null); if (methodInfo != null) { methodInfo.Invoke(null, new object[1] { val }); Plugin.Log.LogWarning((object)("Auto-kicked Player " + actorNumber + " after confirmed mismatch.")); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Auto-kick failed: " + ex.Message)); } } internal void DrawGui() { if (_initialized) { if (_detailPromptOpen) { DrawDetailPrompt(); } if (_startPromptOpen) { DrawStartPrompt(); } } } internal void HandleStatusClicked(int actorNumber) { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) if (!_roomActive || actorNumber <= 0) { return; } IntegrityWire.SnapshotPlayerData snapshotPlayerData = (PhotonNetwork.IsMasterClient ? _hostState.ToSnapshot().Players.FirstOrDefault((IntegrityWire.SnapshotPlayerData x) => x.ActorNumber == actorNumber) : _clientState.Players.FirstOrDefault((IntegrityWire.SnapshotPlayerData x) => x.ActorNumber == actorNumber)); if (snapshotPlayerData == null) { _detailTitle = "MOD 校验状态"; _detailText = "该玩家仍在等待房主建立校验状态。"; _detailScroll = Vector2.zero; PresentDetailPrompt(); } else if (!PhotonNetwork.IsMasterClient && IsDetailedMismatch(snapshotPlayerData.State) && (snapshotPlayerData.Differences == null || snapshotPlayerData.Differences.Count == 0)) { _detailRequestedActor = actorNumber; _detailTitle = snapshotPlayerData.Nickname + " - 正在获取详情"; _detailText = "正在向房主索取该玩家的具体 MOD 差异……"; _detailScroll = Vector2.zero; if (!IntegrityWire.SendDetailRequest(_epoch, actorNumber)) { _detailText = "未能向房主发送详情请求,请稍后重试。"; PresentDetailPrompt(); } } else { OpenDetail(snapshotPlayerData); } } internal void OpenDetail(IntegrityWire.SnapshotPlayerData player) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) if (player != null) { _detailRequestedActor = 0; _detailScroll = Vector2.zero; switch (player.State) { case PlayerIntegrityState.Match: _detailTitle = player.Nickname + " - MOD 校验通过"; _detailText = "该玩家的插件、版本、DLL 内容和资源文件均与房主一致。"; break; case PlayerIntegrityState.Pending: _detailTitle = player.Nickname + " - 正在校验"; _detailText = "正在等待该玩家提交 MOD 清单,或正在接收完整差异数据。"; break; case PlayerIntegrityState.Unavailable: _detailTitle = player.Nickname + " - 无法校验"; _detailText = (player.Summary ?? "客户端未响应") + "\n\n可能原因:没有安装/启动 MOD同步检查器、双方校验器版本不兼容,或网络请求没有送达。"; break; default: _detailTitle = player.Nickname + " - MOD 不一致"; _detailText = BuildDetailText(player); break; } PresentDetailPrompt(); } } internal void PresentDetailPrompt() { if (!_detailPopupScheduled) { _detailPromptOpen = false; _detailPopupScheduled = true; if (!Plugin.RunAtEndOfFrame(PresentDetailPromptNow)) { PresentDetailPromptNow(); } } } internal void PresentDetailPromptNow() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) _detailPopupScheduled = false; try { if ((Object)(object)MenuManager.instance != (Object)null) { MenuManager.instance.PagePopUp(_detailTitle ?? "MOD 校验状态", new Color(0.2f, 0.85f, 1f), Clip(_detailText ?? string.Empty, 3600), "关闭", false); Plugin.Log.LogInfo((object)("Opened native MOD integrity detail popup: " + _detailTitle)); return; } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Native detail popup failed; using IMGUI fallback: " + ex.Message)); } _detailPromptOpen = true; } internal static string BuildDetailText(IntegrityWire.SnapshotPlayerData player) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine(player.Summary ?? "MOD 不一致"); stringBuilder.AppendLine(); if (player.Differences == null || player.Differences.Count == 0) { stringBuilder.Append("房主尚未返回逐项差异,请关闭后再次点击状态重试。"); return stringBuilder.ToString(); } foreach (IntegrityDifference difference in player.Differences) { stringBuilder.AppendLine(FormatDifference(difference)); } int num = player.MissingCount + player.ExtraCount + player.VersionCount + player.ContentCount; if (num > player.Differences.Count) { stringBuilder.AppendLine(); stringBuilder.AppendFormat("当前显示前 {0} 项,共 {1} 项;完整记录请查看房主 LogOutput.log。", player.Differences.Count, num); } return stringBuilder.ToString(); } internal static string FormatDifference(IntegrityDifference difference) { if (difference == null) { return string.Empty; } return difference.Type switch { IntegrityDifferenceType.Missing => $"缺少:{difference.Name} 房主版本 {difference.HostVersion}", IntegrityDifferenceType.Extra => $"额外:{difference.Name} 玩家版本 {difference.ClientVersion}", IntegrityDifferenceType.VersionMismatch => $"版本不同:{difference.Name} 房主 {difference.HostVersion} / 玩家 {difference.ClientVersion}", _ => $"内容不同:{difference.Name} 版本 {difference.HostVersion}", }; } internal static bool IsDetailedMismatch(PlayerIntegrityState state) { if (state != PlayerIntegrityState.Match && state != PlayerIntegrityState.Pending) { return state != PlayerIntegrityState.Unavailable; } return false; } internal void DrawDetailPrompt() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) float num = Math.Min(680f, Math.Max(440f, (float)Screen.width - 80f)); float num2 = Math.Min(520f, Math.Max(320f, (float)Screen.height - 100f)); Rect val = default(Rect); ((Rect)(ref val))..ctor(((float)Screen.width - num) / 2f, ((float)Screen.height - num2) / 2f, num, num2); GUI.Box(val, _detailTitle); int num3 = (string.IsNullOrEmpty(_detailText) ? 1 : _detailText.Split(new char[1] { '\n' }).Length); float num4 = Math.Max(num2 - 92f, (float)num3 * 24f + 20f); _detailScroll = GUI.BeginScrollView(new Rect(((Rect)(ref val)).x + 16f, ((Rect)(ref val)).y + 34f, ((Rect)(ref val)).width - 32f, ((Rect)(ref val)).height - 88f), _detailScroll, new Rect(0f, 0f, ((Rect)(ref val)).width - 56f, num4)); GUI.TextArea(new Rect(0f, 0f, ((Rect)(ref val)).width - 56f, num4), _detailText ?? string.Empty); GUI.EndScrollView(); if (GUI.Button(new Rect(((Rect)(ref val)).x + ((Rect)(ref val)).width - 136f, ((Rect)(ref val)).y + ((Rect)(ref val)).height - 44f, 120f, 30f), "关闭")) { _detailPromptOpen = false; _detailRequestedActor = 0; } } internal void DrawStartPrompt() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) Rect val = default(Rect); ((Rect)(ref val))..ctor(Math.Max(24f, (float)Screen.width / 2f - 270f), Math.Max(24f, (float)Screen.height / 2f - 150f), 540f, 300f); GUI.Box(val, "检测到 MOD 环境不一致"); GUI.Label(new Rect(((Rect)(ref val)).x + 18f, ((Rect)(ref val)).y + 38f, ((Rect)(ref val)).width - 36f, 160f), Clip(_startReason, 700)); if (_config.AllowHostForceStart.Value && GUI.Button(new Rect(((Rect)(ref val)).x + 270f, ((Rect)(ref val)).y + 244f, 230f, 34f), "仍然开始(强制)")) { _startPromptOpen = false; _allowNextStart = true; InvokeOriginalStart(); } if (GUI.Button(new Rect(((Rect)(ref val)).x + 18f, ((Rect)(ref val)).y + 244f, 230f, 34f), "返回检查")) { _startPromptOpen = false; } } internal void InvokeOriginalStart() { if ((Object)(object)_startInstance == (Object)null) { return; } try { MethodInfo methodInfo = AccessTools.Method(typeof(MenuPageLobby), "ButtonStart", (Type[])null, (Type[])null); if (methodInfo != null) { methodInfo.Invoke(_startInstance, null); } } catch (Exception ex) { _allowNextStart = false; Plugin.Log.LogError((object)("Force-start invocation failed: " + ex)); } finally { _startInstance = null; } } internal static long NewEpoch() { return DateTime.UtcNow.Ticks; } internal static string Prefix(string value, int length) { if (string.IsNullOrEmpty(value)) { return string.Empty; } if (value.Length > length) { return value.Substring(0, length); } return value; } internal static string Clip(string value, int length) { if (string.IsNullOrEmpty(value)) { return string.Empty; } if (value.Length > length) { return value.Substring(0, length - 1) + "…"; } return value; } internal void Shutdown() { if (_playerListStatusUi != null) { _playerListStatusUi.StatusClicked -= HandleStatusClicked; _playerListStatusUi.Restore(); } if (_transport != null) { _transport.EventReceived -= ReceivePhotonEvent; _transport.Unregister(); } if (Instance == this) { Instance = null; } _initialized = false; } } public static class IntegrityWire { internal sealed class ManifestReportData { internal long Epoch; internal string Fingerprint; internal int EntryCount; } internal sealed class ProtocolHelloData { internal string Fingerprint; internal int EntryCount; } internal sealed class ManifestChunkData { internal long Epoch; internal int ChunkIndex; internal int ChunkCount; internal List<ModManifestEntry> Entries; } internal sealed class SnapshotData { internal long Epoch; internal int Sequence; internal List<SnapshotPlayerData> Players = new List<SnapshotPlayerData>(); } internal sealed class SnapshotPlayerData { internal int ActorNumber; internal string Nickname; internal PlayerIntegrityState State; internal string Summary; internal int MissingCount; internal int ExtraCount; internal int VersionCount; internal int ContentCount; internal List<IntegrityDifference> Differences = new List<IntegrityDifference>(); } internal static bool SendProtocolHello(string fingerprint, int entryCount) { return Raise(180, new object[3] { 2, Limit(fingerprint, 160), entryCount }, ToMaster()); } internal static bool SendManifestRequest(int actorNumber, long epoch, string hostFingerprint) { return Raise(181, new object[3] { 2, epoch, Limit(hostFingerprint, 160) }, ToActor(actorNumber)); } internal static bool SendManifestReport(int masterActor, long epoch, string fingerprint, int entryCount) { return Raise(182, new object[4] { 2, epoch, Limit(fingerprint, 160), entryCount }, ToActor(masterActor)); } internal static bool SendManifestChunk(int masterActor, long epoch, int index, int count, IList<ModManifestEntry> entries) { object[] array = new object[entries.Count]; for (int i = 0; i < entries.Count; i++) { ModManifestEntry modManifestEntry = entries[i]; array[i] = new object[4] { Limit(modManifestEntry.Guid, 128), Limit(modManifestEntry.Name, 256), Limit(modManifestEntry.Version, 64), Limit(modManifestEntry.ContentHash, 160) }; } return Raise(183, new object[5] { 2, epoch, index, count, array }, ToActor(masterActor)); } internal static bool SendSnapshot(SnapshotData snapshot, int actorNumber) { object[] array = new object[Math.Min(snapshot.Players.Count, 64)]; for (int i = 0; i < array.Length; i++) { SnapshotPlayerData snapshotPlayerData = snapshot.Players[i]; object[] array2 = new object[0]; array[i] = new object[9] { snapshotPlayerData.ActorNumber, Limit(snapshotPlayerData.Nickname, 64), snapshotPlayerData.State.ToWireString(), Limit(snapshotPlayerData.Summary, 512), array2, snapshotPlayerData.MissingCount, snapshotPlayerData.ExtraCount, snapshotPlayerData.VersionCount, snapshotPlayerData.ContentCount }; } object[] payload = new object[4] { 2, snapshot.Epoch, snapshot.Sequence, array }; RaiseEventOptions options = ((actorNumber > 0) ? ToActor(actorNumber) : ToAll()); return Raise(184, payload, options); } internal static bool SendDetailRequest(long epoch, int requestedActorNumber) { return Raise(185, new object[3] { 2, epoch, requestedActorNumber }, ToMaster()); } internal static bool SendDetailResponse(SnapshotData snapshot, int actorNumber) { object[] array = new object[Math.Min(snapshot.Players.Count, 64)]; for (int i = 0; i < array.Length; i++) { SnapshotPlayerData snapshotPlayerData = snapshot.Players[i]; int num = Math.Min(snapshotPlayerData.Differences.Count, 32); object[] array2 = new object[num]; for (int j = 0; j < num; j++) { array2[j] = ToWireDifference(snapshotPlayerData.Differences[j]); } array[i] = new object[9] { snapshotPlayerData.ActorNumber, Limit(snapshotPlayerData.Nickname, 64), snapshotPlayerData.State.ToWireString(), Limit(snapshotPlayerData.Summary, 512), array2, snapshotPlayerData.MissingCount, snapshotPlayerData.ExtraCount, snapshotPlayerData.VersionCount, snapshotPlayerData.ContentCount }; } return Raise(186, new object[4] { 2, snapshot.Epoch, snapshot.Sequence, array }, ToActor(actorNumber)); } internal static bool TryReadManifestReport(EventData photonEvent, out ManifestReportData report) { report = null; if (!TryPayload(photonEvent, out var data) || data.Length < 4 || !IsProtocol(data[0])) { return false; } if (!TryLong(data[1], out var result) || !TryInt(data[3], out var result2)) { return false; } if (result2 < 0 || result2 > 256) { return false; } if (!(data[2] is string { Length: <=160 } text)) { return false; } report = new ManifestReportData { Epoch = result, Fingerprint = text, EntryCount = result2 }; return true; } internal static bool TryReadProtocolHello(EventData photonEvent, out ProtocolHelloData hello) { hello = null; if (!TryPayload(photonEvent, out var data) || data.Length < 3 || !IsProtocol(data[0])) { return false; } if (!(data[1] is string { Length: <=160 } text) || !TryInt(data[2], out var result) || result < 0 || result > 256) { return false; } hello = new ProtocolHelloData { Fingerprint = text, EntryCount = result }; return true; } internal static bool TryReadManifestRequest(EventData photonEvent, out long epoch, out string hostFingerprint) { epoch = 0L; hostFingerprint = string.Empty; if (!TryPayload(photonEvent, out var data) || data.Length < 2 || !IsProtocol(data[0]) || !TryLong(data[1], out epoch)) { return false; } if (data.Length >= 3) { hostFingerprint = data[2] as string; if (hostFingerprint == null || hostFingerprint.Length > 160) { return false; } } return true; } internal static bool TryReadDetailRequest(EventData photonEvent, out long epoch, out int requestedActorNumber) { epoch = 0L; requestedActorNumber = 0; if (!TryPayload(photonEvent, out var data) || data.Length < 2 || !IsProtocol(data[0]) || !TryLong(data[1], out epoch)) { return false; } if (data.Length < 3 || !TryInt(data[2], out requestedActorNumber)) { return false; } return requestedActorNumber > 0; } internal static bool TryReadManifestChunk(EventData photonEvent, out ManifestChunkData chunk) { chunk = null; if (!TryPayload(photonEvent, out var data) || data.Length < 5 || !IsProtocol(data[0])) { return false; } if (!TryLong(data[1], out var result) || !TryInt(data[2], out var result2) || !TryInt(data[3], out var result3)) { return false; } if (result3 < 1 || result3 > 32 || result2 < 0 || result2 >= result3) { return false; } if (!(data[4] is object[] array) || array.Length > 10) { return false; } List<ModManifestEntry> list = new List<ModManifestEntry>(array.Length); for (int i = 0; i < array.Length; i++) { if (!(array[i] is object[] array2) || array2.Length < 4) { return false; } string text = array2[0] as string; string text2 = array2[1] as string; string text3 = array2[2] as string; string text4 = array2[3] as string; if (text == null || text2 == null || text3 == null || text4 == null) { return false; } if (text.Length > 128 || text2.Length > 256 || text3.Length > 64 || text4.Length > 160) { return false; } list.Add(new ModManifestEntry(text, text2, text3, text4)); } chunk = new ManifestChunkData { Epoch = result, ChunkIndex = result2, ChunkCount = result3, Entries = list }; return true; } internal static bool TryReadSnapshot(EventData photonEvent, out SnapshotData snapshot) { snapshot = null; if (!TryPayload(photonEvent, out var data) || data.Length < 4 || !IsProtocol(data[0])) { return false; } if (!TryLong(data[1], out var result) || !TryInt(data[2], out var result2)) { return false; } if (!(data[3] is object[] array) || array.Length > 64) { return false; } SnapshotData snapshotData = new SnapshotData(); snapshotData.Epoch = result; snapshotData.Sequence = result2; SnapshotData snapshotData2 = snapshotData; for (int i = 0; i < array.Length; i++) { if (!(array[i] is object[] array2) || array2.Length < 5) { return false; } if (!TryInt(array2[0], out var result3)) { return false; } string text = array2[1] as string; string text2 = array2[2] as string; string text3 = array2[3] as string; object[] array3 = array2[4] as object[]; if (text == null || text2 == null || text3 == null || array3 == null || text.Length > 64 || text3.Length > 512 || !PlayerIntegrityStateExtensions.TryParse(text2, out var state) || array3.Length > 32) { return false; } SnapshotPlayerData snapshotPlayerData = new SnapshotPlayerData(); snapshotPlayerData.ActorNumber = result3; snapshotPlayerData.Nickname = text; snapshotPlayerData.State = state; snapshotPlayerData.Summary = text3; SnapshotPlayerData snapshotPlayerData2 = snapshotPlayerData; if (array2.Length >= 9) { if (!TryInt(array2[5], out snapshotPlayerData2.MissingCount) || !TryInt(array2[6], out snapshotPlayerData2.ExtraCount) || !TryInt(array2[7], out snapshotPlayerData2.VersionCount) || !TryInt(array2[8], out snapshotPlayerData2.ContentCount)) { return false; } if (snapshotPlayerData2.MissingCount < 0 || snapshotPlayerData2.ExtraCount < 0 || snapshotPlayerData2.VersionCount < 0 || snapshotPlayerData2.ContentCount < 0) { return false; } } for (int j = 0; j < array3.Length; j++) { if (!TryReadDifference(array3[j], out var difference)) { return false; } snapshotPlayerData2.Differences.Add(difference); } if (array2.Length < 9) { snapshotPlayerData2.MissingCount = snapshotPlayerData2.Differences.Count((IntegrityDifference x) => x.Type == IntegrityDifferenceType.Missing); snapshotPlayerData2.ExtraCount = snapshotPlayerData2.Differences.Count((IntegrityDifference x) => x.Type == IntegrityDifferenceType.Extra); snapshotPlayerData2.VersionCount = snapshotPlayerData2.Differences.Count((IntegrityDifference x) => x.Type == IntegrityDifferenceType.VersionMismatch); snapshotPlayerData2.ContentCount = snapshotPlayerData2.Differences.Count((IntegrityDifference x) => x.Type == IntegrityDifferenceType.ContentMismatch); } snapshotData2.Players.Add(snapshotPlayerData2); } snapshot = snapshotData2; return true; } internal static object[] ToWireDifference(IntegrityDifference difference) { return new object[7] { difference.Type.ToWireString(), Limit(difference.Guid, 128), Limit(difference.Name, 256), Limit(difference.HostVersion, 64), Limit(difference.ClientVersion, 64), Limit(difference.HostHash, 160), Limit(difference.ClientHash, 160) }; } internal static bool TryReadDifference(object value, out IntegrityDifference difference) { difference = null; if (!(value is object[] array) || array.Length < 7) { return false; } if (!IntegrityDifferenceExtensions.TryParse(array[0] as string, out var type)) { return false; } string text = array[1] as string; string text2 = array[2] as string; string text3 = array[3] as string; string text4 = array[4] as string; string text5 = array[5] as string; string text6 = array[6] as string; if (text == null || text2 == null || text3 == null || text4 == null || text5 == null || text6 == null) { return false; } difference = new IntegrityDifference { Type = type, Guid = text, Name = text2, HostVersion = text3, ClientVersion = text4, HostHash = text5, ClientHash = text6 }; return true; } internal static RaiseEventOptions ToAll() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0008: Unknown result type (might be due to invalid IL or missing references) RaiseEventOptions val = new RaiseEventOptions(); val.Receivers = (ReceiverGroup)1; return val; } internal static RaiseEventOptions ToMaster() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0008: Unknown result type (might be due to invalid IL or missing references) RaiseEventOptions val = new RaiseEventOptions(); val.Receivers = (ReceiverGroup)2; return val; } internal static RaiseEventOptions ToActor(int actorNumber) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown RaiseEventOptions val = new RaiseEventOptions(); val.TargetActors = new int[1] { actorNumber }; return val; } internal static bool Raise(byte code, object[] payload, RaiseEventOptions options) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) try { return PhotonNetwork.RaiseEvent(code, (object)payload, options, SendOptions.SendReliable); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Photon event " + code + " failed: " + ex.Message)); return false; } } internal static bool TryPayload(EventData photonEvent, out object[] data) { data = ((photonEvent != null) ? (photonEvent.CustomData as object[]) : null); return data != null; } internal static bool IsProtocol(object value) { if (TryInt(value, out var result)) { return result == 2; } return false; } internal static bool TryInt(object value, out int result) { try { result = Convert.ToInt32(value); return true; } catch { result = 0; return false; } } internal static bool TryLong(object value, out long result) { try { result = Convert.ToInt64(value); return true; } catch { result = 0L; return false; } } internal static string Limit(string value, int maxLength) { if (value == null) { return string.Empty; } if (value.Length > maxLength) { return value.Substring(0, maxLength); } return value; } } public sealed class ManifestChunkAssembler { internal long _epoch; internal int _chunkCount; internal readonly Dictionary<int, List<ModManifestEntry>> _chunks = new Dictionary<int, List<ModManifestEntry>>(); internal bool TryAdd(IntegrityWire.ManifestChunkData chunk, out ModManifest manifest, out string error) { manifest = null; error = null; if (chunk == null) { error = "chunk-null"; return false; } if (_chunks.Count == 0) { _epoch = chunk.Epoch; _chunkCount = chunk.ChunkCount; } if (_epoch != chunk.Epoch || _chunkCount != chunk.ChunkCount) { error = "chunk-header-mismatch"; return false; } if (!_chunks.ContainsKey(chunk.ChunkIndex)) { _chunks.Add(chunk.ChunkIndex, chunk.Entries); } if (_chunks.Count != _chunkCount) { return true; } List<ModManifestEntry> list = new List<ModManifestEntry>(); for (int i = 0; i < _chunkCount; i++) { if (!_chunks.TryGetValue(i, out var value)) { error = "chunk-missing"; return false; } list.AddRange(value); if (list.Count > 256) { error = "manifest-too-large"; return false; } } if (!ModManifest.TryCreate(list, out manifest, out error)) { return false; } return true; } } public static class MessageCodes { internal const byte ProtocolHello = 180; internal const byte ManifestRequest = 181; internal const byte ManifestReport = 182; internal const byte ManifestChunk = 183; internal const byte IntegritySnapshot = 184; internal const byte IntegrityDetailRequest = 185; internal const byte IntegrityDetailResponse = 186; internal const int ProtocolVersion = 2; internal const int MaxManifestEntries = 256; internal const int MaxChunkEntries = 10; internal const int MaxManifestChunks = 32; internal const int MaxSnapshotPlayers = 64; internal const int MaxSnapshotDifferencesPerPlayer = 32; internal const int MaxGuidLength = 128; internal const int MaxNameLength = 256; internal const int MaxVersionLength = 64; internal const int MaxContentIdLength = 160; internal const int MaxNicknameLength = 64; internal const int MaxSummaryLength = 512; } public sealed class PhotonTransport : IOnEventCallback { internal Action<EventData> EventReceived; internal bool _registered; internal event Action<EventData> EventReceived; internal void Register() { if (_registered) { return; } try { PhotonNetwork.AddCallbackTarget((object)this); _registered = true; Plugin.Log.LogInfo((object)"Photon integrity callback registered."); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Photon callback registration failed: " + ex.Message)); } } internal void Update() { if (!_registered && PhotonNetwork.IsConnected) { Register(); } else if (_registered && !PhotonNetwork.IsConnected) { Unregister(); } } internal void Unregister() { if (_registered) { try { PhotonNetwork.RemoveCallbackTarget((object)this); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Photon callback removal failed: " + ex.Message)); } _registered = false; } } public void OnEvent(EventData photonEvent) { this.EventReceived?.Invoke(photonEvent); } } public static class StartGamePatch { internal static bool Prefix(MenuPageLobby __instance) { return ModSyncRuntime.Instance?.PrefixStart(__instance) ?? true; } } [BepInPlugin("com.codex.modsyncchecker", "MOD同步检查器", "1.2.23")] public sealed class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; internal static Plugin Instance; internal ModSyncRuntime _runtime; internal Harmony _harmony; internal void Awake() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; try { SyncConfig config = SyncConfig.Bind(((BaseUnityPlugin)this).Config); _runtime = new ModSyncRuntime(); _runtime.Initialize(config); _harmony = new Harmony("com.codex.modsyncchecker"); MethodInfo methodInfo = AccessTools.Method(typeof(MenuPageLobby), "ButtonStart", (Type[])null, (Type[])null); if (methodInfo == null) { Log.LogError((object)"Start gate target MenuPageLobby.ButtonStart was not found."); } else { Harmony harmony = _harmony; HarmonyMethod val = new HarmonyMethod(typeof(StartGamePatch), "Prefix", (Type[])null); val.priority = 800; harmony.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"Start gate patch target installed: MenuPageLobby.ButtonStart."); } ((MonoBehaviour)this).StartCoroutine(RuntimeCoroutine()); Log.LogInfo((object)"Runtime coroutine scheduled; it will start after the BepInEx chainloader frame."); ManualLogSource log = Log; SyncUpgrades.Install(_harmony, config, _runtime); log.LogInfo((object)"ModSyncChecker loaded. Host-based integrity checks are ready."); } catch (Exception ex) { Log.LogError((object)("ModSyncChecker failed to initialize: " + ex)); } } internal void Update() { if (_runtime != null) { _runtime.Tick(); } } internal void OnGUI() { if (_runtime != null) { _runtime.DrawGui(); } } internal void LateUpdate() { if (_runtime != null) { _runtime.RefreshPlayerListUi(); _runtime.HandlePlayerListInput(); } } internal IEnumerator RuntimeCoroutine() { yield return null; Log.LogInfo((object)"Runtime coroutine entered successfully."); while (true) { if (_runtime != null) { _runtime.Tick(); } yield return null; } } internal static bool RunAtEndOfFrame(Action action) { if ((Object)(object)Instance == (Object)null || action == null) { return false; } ((MonoBehaviour)Instance).StartCoroutine(Instance.InvokeAtEndOfFrame(action)); return true; } internal IEnumerator InvokeAtEndOfFrame(Action action) { yield return (object)new WaitForEndOfFrame(); action?.Invoke(); } internal void OnEnable() { if (Log != null) { Log.LogInfo((object)"Plugin Unity behaviour enabled."); } } internal void Start() { if (Log != null) { Log.LogInfo((object)"Plugin Unity Start callback received."); } } internal void OnDisable() { if (Log != null) { Log.LogWarning((object)"Plugin Unity behaviour disabled; event-driven fallbacks remain installed."); } } internal void OnDestroy() { if (Log != null) { Log.LogWarning((object)"Plugin Unity behaviour destroyed."); } if (_harmony != null) { try { _harmony.UnpatchSelf(); } catch (Exception ex) { Log.LogWarning((object)("Failed to unpatch: " + ex.Message)); } } if (_runtime != null) { _runtime.Shutdown(); } _runtime = null; if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } public static class PluginInfo { internal const string Guid = "com.codex.modsyncchecker"; internal const string Name = "MOD同步检查器"; internal const string Version = "1.2.21"; } public sealed class ClientIntegrityState { internal long Epoch { get; set; } internal int Sequence { get; set; } internal List<IntegrityWire.SnapshotPlayerData> Players { get; set; } internal ClientIntegrityState() { Players = new List<IntegrityWire.SnapshotPlayerData>(); } internal void Reset(long epoch) { Epoch = epoch; Sequence = 0; Players.Clear(); } internal bool Apply(IntegrityWire.SnapshotData snapshot) { if (snapshot == null || snapshot.Epoch != Epoch) { return false; } if (snapshot.Sequence <= Sequence) { return false; } Sequence = snapshot.Sequence; Players = snapshot.Players; return true; } internal bool MergeDetails(IntegrityWire.SnapshotData snapshot) { if (snapshot == null || snapshot.Epoch != Epoch || snapshot.Sequence < Sequence) { return false; } bool result = false; foreach (IntegrityWire.SnapshotPlayerData detail in snapshot.Players) { if (detail != null) { int num = Players.FindIndex((IntegrityWire.SnapshotPlayerData x) => x != null && x.ActorNumber == detail.ActorNumber); if (num >= 0) { Players[num] = detail; } else { Players.Add(detail); } result = true; } } if (snapshot.Sequence > Sequence) { Sequence = snapshot.Sequence; } return result; } } public enum PlayerIntegrityState { Pending, Match, Missing, Extra, VersionMismatch, ContentMismatch, MixedMismatch, Unavailable } public static class PlayerIntegrityStateExtensions { internal static string ToWireString(this PlayerIntegrityState state) { return state switch { PlayerIntegrityState.Match => "MATCH", PlayerIntegrityState.Missing => "MISSING", PlayerIntegrityState.Extra => "EXTRA", PlayerIntegrityState.VersionMismatch => "VERSION_MISMATCH", PlayerIntegrityState.ContentMismatch => "CONTENT_MISMATCH", PlayerIntegrityState.MixedMismatch => "MISMATCH", PlayerIntegrityState.Unavailable => "UNAVAILABLE", _ => "PENDING", }; } internal static bool TryParse(string value, out PlayerIntegrityState state) { switch (value) { case "MATCH": state = PlayerIntegrityState.Match; return true; case "MISSING": state = PlayerIntegrityState.Missing; return true; case "EXTRA": state = PlayerIntegrityState.Extra; return true; case "VERSION_MISMATCH": state = PlayerIntegrityState.VersionMismatch; return true; case "CONTENT_MISMATCH": state = PlayerIntegrityState.ContentMismatch; return true; case "MISMATCH": state = PlayerIntegrityState.MixedMismatch; return true; case "UNAVAILABLE": state = PlayerIntegrityState.Unavailable; return true; case "PENDING": state = PlayerIntegrityState.Pending; return true; default: state = PlayerIntegrityState.Unavailable; return false; } } } public static class IntegrityDifferenceExtensions { internal static string ToWireString(this IntegrityDifferenceType type) { return type switch { IntegrityDifferenceType.Missing => "MISSING", IntegrityDifferenceType.Extra => "EXTRA", IntegrityDifferenceType.VersionMismatch => "VERSION_MISMATCH", _ => "CONTENT_MISMATCH", }; } internal static bool TryParse(string value, out IntegrityDifferenceType type) { switch (value) { case "MISSING": type = IntegrityDifferenceType.Missing; return true; case "EXTRA": type = IntegrityDifferenceType.Extra; return true; case "VERSION_MISMATCH": type = IntegrityDifferenceType.VersionMismatch; return true; case "CONTENT_MISMATCH": type = IntegrityDifferenceType.ContentMismatch; return true; default: type = IntegrityDifferenceType.ContentMismatch; return false; } } } public sealed class HostPlayerIntegrity { internal int ActorNumber; internal string Nickname; internal PlayerIntegrityState State; internal string Summary; internal List<IntegrityDifference> Differences = new List<IntegrityDifference>(); internal DateTime PendingSinceUtc; internal DateTime LastRequestUtc; internal int Attempts; internal string ReportedFingerprint; internal int ReportedEntryCount; internal DateTime MismatchSinceUtc; internal HostPlayerIntegrity(int actorNumber, string nickname, long epoch) { ActorNumber = actorNumber; Nickname = nickname ?? string.Empty; State = PlayerIntegrityState.Pending; Summary = "正在等待校验"; PendingSinceUtc = DateTime.UtcNow; LastRequestUtc = DateTime.MinValue; ReportedFingerprint = string.Empty; ReportedEntryCount = -1; MismatchSinceUtc = DateTime.MinValue; } } public sealed class HostIntegrityState { internal readonly Dictionary<int, HostPlayerIntegrity> _players = new Dictionary<int, HostPlayerIntegrity>(); internal long Epoch { get; set; } internal int Sequence { get; set; } internal IEnumerable<HostPlayerIntegrity> Players => _players.Values.OrderBy((HostPlayerIntegrity x) => x.ActorNumber); internal void Reset(long epoch) { Epoch = epoch; Sequence = 0; _players.Clear(); } internal HostPlayerIntegrity Ensure(Player player) { if (player == null) { return null; } if (!_players.TryGetValue(player.ActorNumber, out var value)) { value = new HostPlayerIntegrity(player.ActorNumber, SafeNickname(player), Epoch); _players.Add(player.ActorNumber, value); } else { value.Nickname = SafeNickname(player); } return value; } internal HostPlayerIntegrity Get(int actorNumber) { if (!_players.TryGetValue(actorNumber, out var value)) { return null; } return value; } internal void RemoveExcept(HashSet<int> actors) { foreach (int item in _players.Keys.ToList()) { if (!actors.Contains(item)) { _players.Remove(item); } } } internal int NextSequence() { Sequence++; return Sequence; } internal IntegrityWire.SnapshotData ToSnapshot() { IntegrityWire.SnapshotData snapshotData = new IntegrityWire.SnapshotData(); snapshotData.Epoch = Epoch; snapshotData.Sequence = Sequence; IntegrityWire.SnapshotData snapshotData2 = snapshotData; foreach (HostPlayerIntegrity player in Players) { int missingCount = player.Differences.Count((IntegrityDifference x) => x.Type == IntegrityDifferenceType.Missing); int extraCount = player.Differences.Count((IntegrityDifference x) => x.Type == IntegrityDifferenceType.Extra); int versionCount = player.Differences.Count((IntegrityDifference x) => x.Type == IntegrityDifferenceType.VersionMismatch); int contentCount = player.Differences.Count((IntegrityDifference x) => x.Type == IntegrityDifferenceType.ContentMismatch); snapshotData2.Players.Add(new IntegrityWire.SnapshotPlayerData { ActorNumber = player.ActorNumber, Nickname = player.Nickname, State = player.State, Summary = player.Summary, MissingCount = missingCount, ExtraCount = extraCount, VersionCount = versionCount, ContentCount = contentCount, Differences = new List<IntegrityDifference>(player.Differences) }); } return snapshotData2; } internal static string SafeNickname(Player player) { string text = player.NickName; if (string.IsNullOrEmpty(text)) { text = "Actor " + player.ActorNumber; } if (text.Length > 64) { return text.Substring(0, 64); } return text; } } public sealed class LobbyPlayerListStatusUi { internal sealed class TrackedRow { internal MenuPlayerListed Row; internal TextMeshProUGUI PingText; internal int ActorNumber; internal GameObject ButtonObject; internal RectTransform ButtonRect; internal Image HoverImage; internal Transform ButtonParent; internal bool IsPointerOver; internal bool LayoutLogged; } internal Action<int> StatusClicked; internal static readonly string[] OwnMarkers = new string[8] { "[一致]", "[校验中]", "[无响应]", "[缺失]", "[额外]", "[版本]", "[内容]", "[不一致]" }; internal static readonly FieldInfo LobbyMenuPageField = AccessTools.Field(typeof(MenuPageLobby), "menuPage"); internal static readonly FieldInfo MenuPageActiveField = AccessTools.Field(typeof(MenuPage), "pageActive"); internal static readonly FieldInfo LobbyInstanceField = AccessTools.Field(typeof(MenuPageLobby), "instance"); internal static readonly FieldInfo LobbyPlayerRowsField = AccessTools.Field(typeof(MenuPageLobby), "menuPlayerListedList"); internal readonly FieldInfo _playerAvatarField = AccessTools.Field(typeof(MenuPlayerListed), "playerAvatar"); internal readonly FieldInfo _pingTextField = AccessTools.Field(typeof(MenuPlayerListed), "pingText"); internal readonly Dictionary<int, TrackedRow> _tracked = new Dictionary<int, TrackedRow>(); internal readonly Dictionary<int, IntegrityWire.SnapshotPlayerData> _statusByActor = new Dictionary<int, IntegrityWire.SnapshotPlayerData>(); internal float _nextDiscoveryTime; internal float _lastClickTime = -10f; internal int _lastClickedActor; internal bool _activationLogged; internal bool _inputBackendLogged; internal bool _firstNativeHitLogged; internal float _nextMissLogTime; internal MenuPageLobby _activeLobbyPage; internal bool _isShowing; internal event Action<int> StatusClicked; internal void Refresh(IList<IntegrityWire.SnapshotPlayerData> statuses, bool enabled) { MenuPageLobby val = ResolveLobbyPage(); if (!enabled || !IsActiveLobbyPage(val)) { if (_isShowing || _tracked.Count > 0) { Restore(); } return; } _activeLobbyPage = val; _isShowing = true; try { _statusByActor.Clear(); if (statuses != null) { foreach (IntegrityWire.SnapshotPlayerData status in statuses) { if (status != null && status.ActorNumber > 0) { _statusByActor[status.ActorNumber] = status; } } } if (_tracked.Count == 0 || Time.unscaledTime >= _nextDiscoveryTime) { DiscoverRows(); } foreach (TrackedRow value in _tracked.Values) { RefreshRow(value); } if (!_activationLogged && _tracked.Count > 0) { _activationLogged = true; Plugin.Log.LogInfo((object)$"Per-player ping-local status controls active on {_tracked.Count} row(s)."); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Lobby row status refresh failed safely: " + ex)); _nextDiscoveryTime = Time.unscaledTime + 1f; } } internal void HandleInput() { try { UpdatePointerTarget(); HandlePointerClick(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Lobby row status input failed safely: " + ex)); } } internal void Restore() { foreach (TrackedRow value in _tracked.Values) { if (value != null && (Object)(object)value.PingText != (Object)null) { ((TMP_Text)value.PingText).text = StripOwnMarker(((TMP_Text)value.PingText).text); } DestroyStatusButton(value); } _tracked.Clear(); _statusByActor.Clear(); _nextDiscoveryTime = 0f; _activationLogged = false; _inputBackendLogged = false; _firstNativeHitLogged = false; _nextMissLogTime = 0f; _isShowing = false; } internal void DiscoverRows() { _nextDiscoveryTime = Time.unscaledTime + 0.5f; HashSet<int> hashSet = new HashSet<int>(); IList<MenuPlayerListed> list = null; if ((Object)(object)_activeLobbyPage != (Object)null && LobbyPlayerRowsField != null) { list = LobbyPlayerRowsField.GetValue(_activeLobbyPage) as IList<MenuPlayerListed>; } if (list != null) { foreach (MenuPlayerListed item in list) { if ((Object)(object)item == (Object)null || _pingTextField == null || !((Component)item).gameObject.activeInHierarchy || (Object)(object)((Component)item).GetComponentInParent<MenuPageLobby>() != (Object)(object)_activeLobbyPage) { continue; } int num = ResolveActorNumber(item); object? value = _pingTextField.GetValue(item); TextMeshProUGUI val = (TextMeshProUGUI)((value is TextMeshProUGUI) ? value : null); if (num > 0 && !((Object)(object)val == (Object)null)) { int instanceID = ((Object)item).GetInstanceID(); hashSet.Add(instanceID); if (!_tracked.TryGetValue(instanceID, out var value2)) { value2 = new TrackedRow(); _tracked.Add(instanceID, value2); } value2.Row = item; value2.PingText = val; value2.ActorNumber = num; } } } List<int> list2 = new List<int>(); foreach (KeyValuePair<int, TrackedRow> item2 in _tracked) { if (!hashSet.Contains(item2.Key) || item2.Value == null || (Object)(object)item2.Value.Row == (Object)null || (Object)(object)item2.Value.PingText == (Object)null) { list2.Add(item2.Key); } } foreach (int item3 in list2) { if (_tracked.TryGetValue(item3, out var value3)) { DestroyStatusButton(value3); } _tracked.Remove(item3); } } internal MenuPageLobby ResolveLobbyPage() { MenuPageLobby val = (MenuPageLobby)((LobbyInstanceField != null) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val != (Object)null) { _activeLobbyPage = val; return val; } return _activeLobbyPage; } internal static bool IsActiveLobbyPage(MenuPageLobby page) { if ((Object)(object)page == (Object)null || !((Component)page).gameObject.activeInHierarchy) { return false; } MenuPage val = (MenuPage)((LobbyMenuPageField != null) ? ((object)/*isinst with value type is only supported in some contexts*/) : ((object)((Component)page).GetComponent<MenuPage>())); if ((Object)(object)val != (Object)null && MenuPageActiveField != null) { return (bool)MenuPageActiveField.GetValue(val); } return false; } internal void RefreshRow(TrackedRow tracked) { if (tracked != null && !((Object)(object)tracked.Row == (Object)null) && !((Object)(object)tracked.PingText == (Object)null) && tracked.ActorNumber > 0) { IntegrityWire.SnapshotPlayerData value; string text = (_statusByActor.TryGetValue(tracked.ActorNumber, out value) ? BuildMarker(value) : "[校验中]"); string text2 = StripOwnMarker(((TMP_Text)tracked.PingText).text); string text3 = text + " " + text2; if (!string.Equals(text3, ((TMP_Text)tracked.PingText).text, StringComparison.Ordinal)) { ((TMP_Text)tracked.PingText).text = text3; } EnsureStatusButton(tracked); PositionStatusButton(tracked, text); } } internal void EnsureStatusButton(TrackedRow tracked) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) RectTransform rectTransform = ((TMP_Text)tracked.PingText).rectTransform; if (!((Object)(object)rectTransform == (Object)null) && (!((Object)(object)tracked.ButtonObject != (Object)null) || !((Object)(object)tracked.ButtonParent == (Object)(object)rectTransform))) { DestroyStatusButton(tracked); GameObject val = new GameObject("ModSyncChecker Status Player " + tracked.ActorNumber, new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }); val.transform.SetParent((Transform)(object)rectTransform, false); val.transform.SetAsLastSibling(); Image component = val.GetComponent<Image>(); ((Graphic)component).color = new Color(0f, 0f, 0f, 0.001f); ((Graphic)component).raycastTarget = true; tracked.ButtonObject = val; tracked.ButtonRect = val.GetComponent<RectTransform>(); tracked.HoverImage = component; tracked.ButtonParent = (Transform)(object)rectTransform; Plugin.Log.LogInfo((object)$"Ping-local status control added to player row: actor={tracked.ActorNumber}, row={((Object)tracked.Row).name}."); } } internal static void PositionStatusButton(TrackedRow tracked, string marker) { //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing refer