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 BetterZeeLog v1.15.0
BetterZeeLog.dll
Decompiled a week agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using ComfyLib; using HarmonyLib; using Microsoft.CodeAnalysis; using Splatform; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("BetterZeeLog")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("BetterZeeLog")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("d1094b63-ab04-4330-b85e-d68e855e2e04")] [assembly: AssemblyFileVersion("1.15.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.15.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ComfyLib { public static class CodeMatcherExtensions { public static CodeMatcher CreateLabelOffset(this CodeMatcher matcher, int offset, out Label label) { return matcher.CreateLabelAt(matcher.Pos + offset, ref label); } public static CodeMatcher DeclareLocal(this CodeMatcher matcher, ILGenerator generator, Type localType, out LocalBuilder localBuilder) { localBuilder = generator.DeclareLocal(localType); return matcher; } public static CodeMatcher ExtractLabels(this CodeMatcher matcher, out List<Label> labels) { labels = matcher.Labels.ToList(); matcher.Labels.Clear(); return matcher; } } public static class ConfigFileExtensions { internal sealed class ConfigurationManagerAttributes { public Action<ConfigEntryBase> CustomDrawer; public bool? Browsable; public bool? HideDefaultButton; public bool? HideSettingName; public bool? IsAdvanced; public int? Order; public bool? ReadOnly; } private static readonly Dictionary<string, int> _sectionToSettingOrder = new Dictionary<string, int>(); private static int GetSettingOrder(string section) { if (!_sectionToSettingOrder.TryGetValue(section, out var value)) { value = 0; } _sectionToSettingOrder[section] = value - 1; return value; } public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues, bool browsable = true, bool hideDefaultButton = false, bool hideSettingName = false, bool isAdvanced = false, bool readOnly = false) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, new object[1] { new ConfigurationManagerAttributes { Browsable = browsable, CustomDrawer = null, HideDefaultButton = hideDefaultButton, HideSettingName = hideSettingName, IsAdvanced = isAdvanced, Order = GetSettingOrder(section), ReadOnly = readOnly } })); } public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, Action<ConfigEntryBase> customDrawer = null, bool browsable = true, bool hideDefaultButton = false, bool hideSettingName = false, bool isAdvanced = false, bool readOnly = false) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Browsable = browsable, CustomDrawer = customDrawer, HideDefaultButton = hideDefaultButton, HideSettingName = hideSettingName, IsAdvanced = isAdvanced, Order = GetSettingOrder(section), ReadOnly = readOnly } })); } public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action settingChangedHandler) { configEntry.SettingChanged += delegate { settingChangedHandler(); }; } public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<T> settingChangedHandler) { configEntry.SettingChanged += delegate(object _, EventArgs eventArgs) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) settingChangedHandler((T)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue); }; } public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<ConfigEntry<T>> settingChangedHandler) { configEntry.SettingChanged += delegate(object _, EventArgs eventArgs) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) settingChangedHandler((ConfigEntry<T>)(object)((SettingChangedEventArgs)eventArgs).ChangedSetting); }; } } } namespace BetterZeeLog { [BepInPlugin("redseiko.valheim.betterzeelog", "BetterZeeLog", "1.15.0")] public sealed class BetterZeeLog : BaseUnityPlugin { public const string PluginGUID = "redseiko.valheim.betterzeelog"; public const string PluginName = "BetterZeeLog"; public const string PluginVersion = "1.15.0"; private void Awake() { PluginConfig.BindConfig(((BaseUnityPlugin)this).Config); if (PluginConfig.IsModEnabled.Value) { Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "redseiko.valheim.betterzeelog"); if (PluginConfig.RemoveStackTraceForNonErrorLogType.Value) { Application.SetStackTraceLogType((LogType)3, (StackTraceLogType)0); Application.SetStackTraceLogType((LogType)2, (StackTraceLogType)0); } } } } public static class PluginConfig { public static ConfigEntry<bool> IsModEnabled { get; private set; } public static ConfigEntry<bool> RemoveStackTraceForNonErrorLogType { get; private set; } public static ConfigEntry<bool> RemoveFailedToSendDataLogging { get; private set; } public static ConfigEntry<bool> RemoveContainerRequestOpenLogging { get; private set; } public static ConfigEntry<bool> CheckProjectFixedUpdateZeroVelocity { get; private set; } public static void BindConfig(ConfigFile config) { IsModEnabled = config.BindInOrder("_Global", "isModEnabled", defaultValue: true, "Globally enable or disable this mod (restart required)."); RemoveStackTraceForNonErrorLogType = config.BindInOrder("Logging", "removeStackTraceForNonErrorLogType", defaultValue: true, "Disables the stack track for 'Info' and 'Warning' log types."); RemoveFailedToSendDataLogging = config.BindInOrder("Logging", "removeFailedToSendDataLogging", defaultValue: true, "Removes (NOPs out) 'Failed to send data' logging in ZSteamSocket."); RemoveContainerRequestOpenLogging = config.BindInOrder("Logging", "removeContainerRequestOpenLogging", defaultValue: true, "Removes (NOPs out) 'Players wants to open/but im not the owner' logging in Container.RPC_RequestOpen()."); CheckProjectFixedUpdateZeroVelocity = config.BindInOrder("Quaternion.LookRotation", "checkProjectFixedUpdatedZeroVelocity", defaultValue: true, "Checks for zero `m_vel` in `Projectile.FixedUpdate()`."); } } [HarmonyPatch(typeof(Container))] internal static class ContainerPatch { [HarmonyTranspiler] [HarmonyPatch("RPC_RequestOpen")] private static IEnumerable<CodeInstruction> RPC_RequestOpenTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Expected O, but got Unknown //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Expected O, but got Unknown //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Expected O, but got Unknown //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Expected O, but got Unknown //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Expected O, but got Unknown //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Expected O, but got Unknown //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Expected O, but got Unknown //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Expected O, but got Unknown //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Expected O, but got Unknown Label label = default(Label); if (PluginConfig.RemoveContainerRequestOpenLogging.Value) { return new CodeMatcher(instructions, generator).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Container), "m_nview"), (string)null) }).ThrowIfNotMatch("Could not patch Container.RPC_RequestOpen()! (is-owner)", Array.Empty<CodeMatch>()) .CreateLabel(ref label) .Start() .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Br, (object)label) }) .MatchStartForward((CodeMatch[])(object)new CodeMatch[2] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Ldstr, (object)" but im not the owner")), CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ZLog), "Log", (Type[])null, (Type[])null))) }) .ThrowIfNotMatch("Could not patch Container.RPC_RequestOpen()! (not-owner-log)", Array.Empty<CodeMatch>()) .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null)) .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null)) .MatchStartForward((CodeMatch[])(object)new CodeMatch[2] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Ldstr, (object)" in use")), CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ZLog), "Log", (Type[])null, (Type[])null))) }) .ThrowIfNotMatch("Could not patch Container.RPC_RequestOpen()! (in-use-log)", Array.Empty<CodeMatch>()) .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null)) .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null)) .MatchStartForward((CodeMatch[])(object)new CodeMatch[2] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Ldstr, (object)" not yours")), CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ZLog), "Log", (Type[])null, (Type[])null))) }) .ThrowIfNotMatch("Could not patch Container.RPC_RequestOpen()! (not-yours-log)", Array.Empty<CodeMatch>()) .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null)) .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null)) .InstructionEnumeration(); } return instructions; } [HarmonyTranspiler] [HarmonyPatch("RPC_RequestStack")] private static IEnumerable<CodeInstruction> RPC_RequestStackTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Expected O, but got Unknown //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Expected O, but got Unknown //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Expected O, but got Unknown //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Expected O, but got Unknown //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Expected O, but got Unknown //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Expected O, but got Unknown //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Expected O, but got Unknown //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Expected O, but got Unknown //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Expected O, but got Unknown Label label = default(Label); if (PluginConfig.RemoveContainerRequestOpenLogging.Value) { return new CodeMatcher(instructions, generator).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Container), "m_nview"), (string)null) }).ThrowIfNotMatch("Could not patch Container.RPC_RequestStack()! (is-owner)", Array.Empty<CodeMatch>()) .CreateLabel(ref label) .Start() .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Br, (object)label) }) .MatchStartForward((CodeMatch[])(object)new CodeMatch[2] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Ldstr, (object)" but im not the owner")), CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ZLog), "Log", (Type[])null, (Type[])null))) }) .ThrowIfNotMatch("Could not patch Container.RPC_RequestStack()! (not-owner-log)", Array.Empty<CodeMatch>()) .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null)) .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null)) .MatchStartForward((CodeMatch[])(object)new CodeMatch[2] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Ldstr, (object)" in use")), CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ZLog), "Log", (Type[])null, (Type[])null))) }) .ThrowIfNotMatch("Could not patch Container.RPC_RequestStack()! (in-use-log)", Array.Empty<CodeMatch>()) .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null)) .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null)) .MatchStartForward((CodeMatch[])(object)new CodeMatch[2] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Ldstr, (object)" not yours")), CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ZLog), "Log", (Type[])null, (Type[])null))) }) .ThrowIfNotMatch("Could not patch Container.RPC_RequestStack()! (not-yours-log)", Array.Empty<CodeMatch>()) .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null)) .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null)) .InstructionEnumeration(); } return instructions; } [HarmonyTranspiler] [HarmonyPatch("RPC_RequestTakeAll")] private static IEnumerable<CodeInstruction> RPC_RequestTakeAllTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Expected O, but got Unknown //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Expected O, but got Unknown //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Expected O, but got Unknown //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Expected O, but got Unknown //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Expected O, but got Unknown //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Expected O, but got Unknown //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Expected O, but got Unknown //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Expected O, but got Unknown //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Expected O, but got Unknown Label label = default(Label); if (PluginConfig.RemoveContainerRequestOpenLogging.Value) { return new CodeMatcher(instructions, generator).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Container), "m_nview"), (string)null) }).ThrowIfNotMatch("Could not patch Container.RPC_RequestTakeAll()! (is-owner)", Array.Empty<CodeMatch>()) .CreateLabel(ref label) .Start() .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Br, (object)label) }) .MatchStartForward((CodeMatch[])(object)new CodeMatch[2] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Ldstr, (object)" but im not the owner")), CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ZLog), "Log", (Type[])null, (Type[])null))) }) .ThrowIfNotMatch("Could not patch Container.RPC_RequestTakeAll()! (not-owner-log)", Array.Empty<CodeMatch>()) .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null)) .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null)) .MatchStartForward((CodeMatch[])(object)new CodeMatch[2] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Ldstr, (object)" in use")), CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ZLog), "Log", (Type[])null, (Type[])null))) }) .ThrowIfNotMatch("Could not patch Container.RPC_RequestTakeAll()! (in-use-log)", Array.Empty<CodeMatch>()) .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null)) .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null)) .MatchStartForward((CodeMatch[])(object)new CodeMatch[2] { CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Ldstr, (object)" not yours")), CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ZLog), "Log", (Type[])null, (Type[])null))) }) .ThrowIfNotMatch("Could not patch Container.RPC_RequestTakeAll()! (not-yours-log)", Array.Empty<CodeMatch>()) .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null)) .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null)) .InstructionEnumeration(); } return instructions; } } [HarmonyPatch(typeof(FejdStartup))] internal static class FejdStartupPatch { [HarmonyPrefix] [HarmonyPatch("UpdateKeyboard")] private static bool UpdateKeyboardPrefix() { if (PluginConfig.IsModEnabled.Value && Console.IsVisible()) { return false; } return true; } } [HarmonyPatch(typeof(PlatformUserID))] internal static class PlatformUserIDPatch { [HarmonyTranspiler] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static IEnumerable<CodeInstruction> ConstructorTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown Label label; return new CodeMatcher(instructions, generator).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"PlatformUserID \"", (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"\" failed to parse!", (string)null) }).ThrowIfNotMatch("Could not patch PlatformUserID.Constructor()! (log-failed-to-parse)", Array.Empty<CodeMatch>()) .CreateLabelOffset(5, out label) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Br, (object)label) }) .InstructionEnumeration(); } } [HarmonyPatch(typeof(Projectile))] internal static class ProjectilePatch { [HarmonyTranspiler] [HarmonyPatch("FixedUpdate")] private static IEnumerable<CodeInstruction> FixedUpdateTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown if (PluginConfig.CheckProjectFixedUpdateZeroVelocity.Value) { return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Projectile), "m_vel"), (string)null), new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Quaternion), "LookRotation", new Type[1] { typeof(Vector3) }, (Type[])null), (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.PropertySetter(typeof(Transform), "rotation"), (string)null) }).ThrowIfNotMatch("Could not patch Projectile.FixedUpdate()! (look-rotation)", Array.Empty<CodeMatch>()) .Advance(1) .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ProjectilePatch), "LookRotationDelegate", (Type[])null, (Type[])null))) .InstructionEnumeration(); } return instructions; } private static Quaternion LookRotationDelegate(Vector3 velocity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (velocity == Vector3.zero) { return Quaternion.identity; } return Quaternion.LookRotation(velocity); } } [HarmonyPatch(typeof(UIGroupHandler))] internal static class UIGroupHandlerPatch { [HarmonyTranspiler] [HarmonyPatch("Update")] private static IEnumerable<CodeInstruction> Update1Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown return new CodeMatcher(instructions, generator).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(ZLog), "Log", (Type[])null, (Type[])null), (string)null) }).ThrowIfNotMatch("Could not patch UIGroupHandler.Update()! (log-right-stick)", Array.Empty<CodeMatch>()) .SetInstruction(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(UIGroupHandlerPatch), "LogDelegate", (Type[])null, (Type[])null))) .MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(ZLog), "Log", (Type[])null, (Type[])null), (string)null) }) .ThrowIfNotMatch("Could not patch UIGroupHandler.Update()! (log-default)", Array.Empty<CodeMatch>()) .SetInstruction(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(UIGroupHandlerPatch), "LogDelegate", (Type[])null, (Type[])null))) .InstructionEnumeration(); } private static void LogDelegate(object obj) { } } [HarmonyPatch(typeof(ZLog))] internal static class ZLogPatch { private static string DateTimeNowDelegate(string dateTimeNow) { return "[" + dateTimeNow + "] "; } [HarmonyPrefix] [HarmonyPatch("Log")] private static bool LogPrefix(ref object o) { if (o is string text && text.StartsWith("Console: ", StringComparison.Ordinal)) { return false; } return true; } [HarmonyTranspiler] [HarmonyPatch("Log")] private static IEnumerable<CodeInstruction> LogTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldstr, (object)": ", (string)null) }).ThrowIfNotMatch("Could not patch ZLog.Log()! (colon)", Array.Empty<CodeMatch>()) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<string, string>>((Func<string, string>)DateTimeNowDelegate) }) .SetOperandAndAdvance((object)string.Empty) .MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"\n", (string)null) }) .ThrowIfNotMatch("Could not patch ZLog.Log()! (newline)", Array.Empty<CodeMatch>()) .SetOperandAndAdvance((object)string.Empty) .InstructionEnumeration(); } [HarmonyTranspiler] [HarmonyPatch("LogWarning")] private static IEnumerable<CodeInstruction> LogWarningTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldstr, (object)": ", (string)null) }).ThrowIfNotMatch("Could not patch ZLog.LogWarning()! (colon)", Array.Empty<CodeMatch>()) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<string, string>>((Func<string, string>)DateTimeNowDelegate) }) .SetOperandAndAdvance((object)string.Empty) .MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"\n", (string)null) }) .ThrowIfNotMatch("Could not patch ZLog.LogWarning()! (newline)", Array.Empty<CodeMatch>()) .SetOperandAndAdvance((object)string.Empty) .InstructionEnumeration(); } [HarmonyTranspiler] [HarmonyPatch("LogError")] private static IEnumerable<CodeInstruction> LogErrorTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldstr, (object)": ", (string)null) }).ThrowIfNotMatch("Could not patch ZLog.LogError()! (colon)", Array.Empty<CodeMatch>()) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<string, string>>((Func<string, string>)DateTimeNowDelegate) }) .SetOperandAndAdvance((object)string.Empty) .MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"\n", (string)null) }) .ThrowIfNotMatch("Could not patch ZLog.LogError()! (newline)", Array.Empty<CodeMatch>()) .SetOperandAndAdvance((object)string.Empty) .InstructionEnumeration(); } [HarmonyTranspiler] [HarmonyPatch("DevLog")] private static IEnumerable<CodeInstruction> DevLogTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldstr, (object)": ", (string)null) }).ThrowIfNotMatch("Could not patch ZLog.DevLog()! (colon)", Array.Empty<CodeMatch>()) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<string, string>>((Func<string, string>)DateTimeNowDelegate) }) .SetOperandAndAdvance((object)string.Empty) .MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"\n", (string)null) }) .ThrowIfNotMatch("Could not patch ZLog.DevLog()! (newline)", Array.Empty<CodeMatch>()) .SetOperandAndAdvance((object)string.Empty) .InstructionEnumeration(); } } [HarmonyPatch(typeof(ZSteamSocket))] internal static class ZSteamSocketPatch { [HarmonyTranspiler] [HarmonyPatch("SendQueuedPackages")] private static IEnumerable<CodeInstruction> SendQueuedPackagesTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown List<Label> labels; if (PluginConfig.RemoveFailedToSendDataLogging.Value) { return new CodeMatcher(instructions, generator).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"Failed to send data ", (string)null) }).ThrowIfNotMatch("Could not patch ZSteamSocket.SendQueuedPackages()! (ldstr-Log)", Array.Empty<CodeMatch>()) .ExtractLabels(out labels) .MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(ZLog), "Log", (Type[])null, (Type[])null), (string)null) }) .ThrowIfNotMatch("Could not patch ZSteamSocket.SendQueuedPackages()! (zLog-Log)", Array.Empty<CodeMatch>()) .Advance(1) .AddLabels((IEnumerable<Label>)labels) .InstructionEnumeration(); } return instructions; } } }