using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using Microsoft.CodeAnalysis; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("evu")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright (c) 2026 imevul")] [assembly: AssemblyDescription("Compatibility fixes for other Valheim mods.")] [assembly: AssemblyFileVersion("0.2.0.0")] [assembly: AssemblyInformationalVersion("0.2.0+ac059ef239dd58a46c4673283cd7d6ce2d5f5dbe")] [assembly: AssemblyProduct("EvuMiscCompat")] [assembly: AssemblyTitle("EvuMiscCompat.Core")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/EvuMods/EvuMiscCompat")] [assembly: AssemblyVersion("0.2.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] internal sealed class IsReadOnlyAttribute : Attribute { } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace EvuMiscCompat.Core { public enum IlOpKind { Other, Ldarg0, Ldarg1, Ldarg2, LdcI4_3, BneUn, Call, Brtrue } public readonly struct IlOp : IEquatable { public IlOpKind Kind { get; } public string? Name { get; } public IlOp(IlOpKind kind, string? name = null) { Kind = kind; Name = name; } public bool Equals(IlOp other) { if (Kind == other.Kind) { return Name == other.Name; } return false; } public override bool Equals(object? obj) { if (obj is IlOp other) { return Equals(other); } return false; } public override int GetHashCode() { return ((int)Kind * 397) ^ (Name?.GetHashCode() ?? 0); } } public static class DualWieldWindow { public const string OffhandMethod = "CheckDualOneHandedWeaponEquip"; public static List Repair(IReadOnlyList code) { List list = new List(code.Count + 5); for (int i = 0; i < code.Count; i++) { list.Add(code[i]); if (IsOneHandedBranch(code, i) && !HasOffhandFallthrough(code, i)) { string name = code[i].Name; list.Add(new IlOp(IlOpKind.Ldarg0)); list.Add(new IlOp(IlOpKind.Ldarg1)); list.Add(new IlOp(IlOpKind.Ldarg2)); list.Add(new IlOp(IlOpKind.Call, "CheckDualOneHandedWeaponEquip")); list.Add(new IlOp(IlOpKind.Brtrue, name)); } } return list; } private static bool IsOneHandedBranch(IReadOnlyList code, int index) { if (code[index].Kind != IlOpKind.BneUn) { return false; } if (index < 1 || code[index - 1].Kind != IlOpKind.LdcI4_3) { return false; } if (!IsVanillaWindow(code, index)) { return IsTrinketsWindow(code, index); } return true; } private static bool IsVanillaWindow(IReadOnlyList code, int branch) { if (branch >= 4 && code[branch - 4].Kind == IlOpKind.Ldarg1 && code[branch - 3].Kind == IlOpKind.Other) { return code[branch - 2].Kind == IlOpKind.Other; } return false; } private static bool IsTrinketsWindow(IReadOnlyList code, int branch) { if (branch >= 7 && code[branch - 7].Kind == IlOpKind.Ldarg1 && code[branch - 6].Kind == IlOpKind.Other && code[branch - 5].Kind == IlOpKind.Other && code[branch - 4].Kind == IlOpKind.Ldarg0 && code[branch - 3].Kind == IlOpKind.Ldarg1) { return code[branch - 2].Kind == IlOpKind.Call; } return false; } private static bool HasOffhandFallthrough(IReadOnlyList code, int branch) { if (branch + 5 >= code.Count) { return false; } if (code[branch + 1].Kind == IlOpKind.Ldarg0 && code[branch + 2].Kind == IlOpKind.Ldarg1 && code[branch + 3].Kind == IlOpKind.Ldarg2 && code[branch + 4].Kind == IlOpKind.Call && code[branch + 4].Name == "CheckDualOneHandedWeaponEquip" && code[branch + 5].Kind == IlOpKind.Brtrue) { return code[branch + 5].Name == code[branch].Name; } return false; } } }