using System; using System.Buffers; using System.Buffers.Binary; using System.Buffers.Text; using System.CodeDom.Compiler; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.Immutable; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Tracing; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Linq.Expressions; using System.Net; using System.Net.Sockets; using System.Numerics; using System.Numerics.Hashing; using System.Reflection; using System.Reflection.Emit; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using System.Xml; using System.Xml.Serialization; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using FxResources.System.Buffers; using FxResources.System.Collections.Immutable; using FxResources.System.Memory; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using ProtoBuf; using ProtoBuf.Compiler; using ProtoBuf.Extensions; using ProtoBuf.Internal; using ProtoBuf.Internal.Serializers; using ProtoBuf.Meta; using ProtoBuf.Serializers; using ProtoBuf.WellKnownTypes; using ServerSync; using Splatform; using Steamworks; using TMPro; using UnityEngine; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.Tokens; using YamlDotNet.Helpers; using YamlDotNet.Serialization; using YamlDotNet.Serialization.BufferedDeserialization; using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators; using YamlDotNet.Serialization.Callbacks; using YamlDotNet.Serialization.Converters; using YamlDotNet.Serialization.EventEmitters; using YamlDotNet.Serialization.NamingConventions; using YamlDotNet.Serialization.NodeDeserializers; using YamlDotNet.Serialization.NodeTypeResolvers; using YamlDotNet.Serialization.ObjectFactories; using YamlDotNet.Serialization.ObjectGraphTraversalStrategies; using YamlDotNet.Serialization.ObjectGraphVisitors; using YamlDotNet.Serialization.Schemas; using YamlDotNet.Serialization.TypeInspectors; using YamlDotNet.Serialization.TypeResolvers; using YamlDotNet.Serialization.Utilities; using YamlDotNet.Serialization.ValueDeserializers; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("ServerCharacters")] [assembly: AssemblyDescription("https://valheim.thunderstore.io/package/Smoothbrain/ServerCharacters")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyProduct("ServerCharacters")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("B6DC411F-BB68-4745-BA9E-ADFEAF8C7F0E")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyCompany("")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class <17692631-e0d9-4bdb-8b7e-e1cff9bf39d5>NullableContextAttribute : Attribute { public readonly byte Flag; public <17692631-e0d9-4bdb-8b7e-e1cff9bf39d5>NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace ServerCharacters { public static class ClientSide { [HarmonyPatch(typeof(Skills), "ResetSkill")] public class SaveLastSkillReset { public static SkillType last = (SkillType)999; [UsedImplicitly] public static void Finalizer(SkillType skillType) { //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) last = skillType; } } [HarmonyPatch(typeof(Console), "Print")] public class SilenceConsole { public static bool silence; [UsedImplicitly] public static bool Prefix() { return !silence; } } [HarmonyPatch(typeof(Terminal), "InitTerminal")] public class AddChatCommands { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func, SkillType> <>9__0_3; public static Func, Skill> <>9__0_4; public static ConsoleEvent <>9__0_0; public static ConsoleOptionsFetcher <>9__0_1; internal void b__0_0(ConsoleEventArgs args) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Invalid comparison between Unknown and I4 //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Invalid comparison between Unknown and I4 //IL_081e: Unknown result type (might be due to invalid IL or missing references) <>c__DisplayClass0_0 <>c__DisplayClass0_ = new <>c__DisplayClass0_0 { args = args }; if (!ServerCharacters.configSync.IsAdmin) { <>c__DisplayClass0_.args.Context.AddString("You are not an admin on this server."); } else if (<>c__DisplayClass0_.args.Length >= 3 && <>c__DisplayClass0_.args[1] == "resetskill") { if ((int)g__GetSkillType|0_2(<>c__DisplayClass0_.args[2]) == 999) { <>c__DisplayClass0_.args.Context.AddString(<>c__DisplayClass0_.args[2] + " is not a valid skill."); } else if (<>c__DisplayClass0_.args.Length > 3) { string text = <>c__DisplayClass0_.args[3]; int num = 4; if (text.StartsWith("\"", StringComparison.Ordinal)) { text = text.Substring(1); while (num < <>c__DisplayClass0_.args.Length && !text.EndsWith("\"", StringComparison.Ordinal)) { text = text + " " + <>c__DisplayClass0_.args[num++]; } text = text.Substring(0, text.Length - 1); } ZNet.instance.GetServerPeer().m_rpc.Invoke("ServerCharacters ResetSkill", new object[3] { <>c__DisplayClass0_.args[2], text, (<>c__DisplayClass0_.args.Length > num) ? <>c__DisplayClass0_.args[num] : "0" }); <>c__DisplayClass0_.args.Context.AddString(<>c__DisplayClass0_.args[2] + " has been reset for " + text + "."); } else { ZNet.instance.GetServerPeer().m_rpc.Invoke("ServerCharacters ResetSkill", new object[3] { <>c__DisplayClass0_.args[2], "", "0" }); <>c__DisplayClass0_.args.Context.AddString(<>c__DisplayClass0_.args[2] + " has been reset for everyone."); } } else if (<>c__DisplayClass0_.args.Length >= 3 && <>c__DisplayClass0_.args[1] == "raiseskill") { if ((int)g__GetSkillType|0_2(<>c__DisplayClass0_.args[2]) == 999) { <>c__DisplayClass0_.args.Context.AddString(<>c__DisplayClass0_.args[2] + " is not a valid skill."); } else if (<>c__DisplayClass0_.args.Length > 4) { string text2 = <>c__DisplayClass0_.args[4]; int num2 = 5; if (text2.StartsWith("\"", StringComparison.Ordinal)) { text2 = text2.Substring(1); while (num2 < <>c__DisplayClass0_.args.Length && !text2.EndsWith("\"", StringComparison.Ordinal)) { text2 = text2 + " " + <>c__DisplayClass0_.args[num2++]; } text2 = text2.Substring(0, text2.Length - 1); } ZNet.instance.GetServerPeer().m_rpc.Invoke("ServerCharacters RaiseSkill", new object[4] { <>c__DisplayClass0_.args[2], int.Parse(<>c__DisplayClass0_.args[3]), text2, (<>c__DisplayClass0_.args.Length > num2) ? <>c__DisplayClass0_.args[num2] : "0" }); <>c__DisplayClass0_.args.Context.AddString(<>c__DisplayClass0_.args[2] + " has been raised by " + <>c__DisplayClass0_.args[3] + " for " + text2 + "."); } else { ZNet.instance.GetServerPeer().m_rpc.Invoke("ServerCharacters RaiseSkill", new object[4] { <>c__DisplayClass0_.args[2], int.Parse(<>c__DisplayClass0_.args[3]), "", "0" }); <>c__DisplayClass0_.args.Context.AddString(<>c__DisplayClass0_.args[2] + " has been raised by " + <>c__DisplayClass0_.args[3] + " for everyone."); } } else if (<>c__DisplayClass0_.args.Length >= 3 && <>c__DisplayClass0_.args[1] == "giveitem") { if (ObjectDB.instance.GetItemPrefab(<>c__DisplayClass0_.args[2]) == null) { <>c__DisplayClass0_.args.Context.AddString(<>c__DisplayClass0_.args[2] + " is not a valid item."); } else if (<>c__DisplayClass0_.args.Length > 4) { string text3 = <>c__DisplayClass0_.args[4]; int num3 = 5; if (text3.StartsWith("\"", StringComparison.Ordinal)) { text3 = text3.Substring(1); while (num3 < <>c__DisplayClass0_.args.Length && !text3.EndsWith("\"", StringComparison.Ordinal)) { text3 = text3 + " " + <>c__DisplayClass0_.args[num3++]; } text3 = text3.Substring(0, text3.Length - 1); } ZNet.instance.GetServerPeer().m_rpc.Invoke("ServerCharacters GiveItem", new object[4] { <>c__DisplayClass0_.args[2], int.Parse(<>c__DisplayClass0_.args[3]), text3, (<>c__DisplayClass0_.args.Length > num3) ? <>c__DisplayClass0_.args[num3] : "0" }); <>c__DisplayClass0_.args.Context.AddString(<>c__DisplayClass0_.args[3] + "x " + <>c__DisplayClass0_.args[2] + " has been given to " + text3 + ", if their inventory isn't full."); } else { <>c__DisplayClass0_.args.Context.AddString("Please specify a target player."); } } else if (<>c__DisplayClass0_.args.Length >= 3 && <>c__DisplayClass0_.args[1] == "teleport") { string text4 = <>c__DisplayClass0_.args[2]; int num4 = 3; if (text4.StartsWith("\"", StringComparison.Ordinal)) { text4 = text4.Substring(1); while (num4 < <>c__DisplayClass0_.args.Length && !text4.EndsWith("\"", StringComparison.Ordinal)) { text4 = text4 + " " + <>c__DisplayClass0_.args[num4++]; } text4 = text4.Substring(0, text4.Length - 1); } ZNet.instance.GetServerPeer().m_rpc.Invoke("ServerCharacters GetPlayerPos", new object[2] { text4, (<>c__DisplayClass0_.args.Length > num4) ? <>c__DisplayClass0_.args[num4] : "0" }); ((MonoBehaviour)ServerCharacters.selfReference).StartCoroutine(<>c__DisplayClass0_.g__AwaitResponse|5()); } else if (<>c__DisplayClass0_.args.Length >= 3 && <>c__DisplayClass0_.args[1] == "summon") { string text5 = <>c__DisplayClass0_.args[2]; int num5 = 3; if (text5.StartsWith("\"", StringComparison.Ordinal)) { text5 = text5.Substring(1); while (num5 < <>c__DisplayClass0_.args.Length && !text5.EndsWith("\"", StringComparison.Ordinal)) { text5 = text5 + " " + <>c__DisplayClass0_.args[num5++]; } text5 = text5.Substring(0, text5.Length - 1); } ZNet.instance.GetServerPeer().m_rpc.Invoke("ServerCharacters SendOwnPos", new object[3] { text5, (<>c__DisplayClass0_.args.Length > num5) ? <>c__DisplayClass0_.args[num5] : "0", ((Component)Player.m_localPlayer).transform.position }); ((MonoBehaviour)ServerCharacters.selfReference).StartCoroutine(<>c__DisplayClass0_.g__AwaitResponse|7()); } else { <>c__DisplayClass0_.args.Context.AddString("ServerCharacters console commands - use 'ServerCharacters' followed by one of the following options."); <>c__DisplayClass0_.args.Context.AddString("resetskill [skillname] [playername] [id] - resets the skill for the specified player. Steam / Xbox ID is optional and only required, if multiple players have the same name. If no name is provided, the skill is reset for every character on the server, online and offline."); <>c__DisplayClass0_.args.Context.AddString("raiseskill [skillname] [level] [playername] [id] - raises the skill for the specified player by the specified level. Steam / Xbox ID is optional and only required, if multiple players have the same name. If no name is provided, the skill is raised for every character on the server, online and offline."); <>c__DisplayClass0_.args.Context.AddString("teleport [playername] [steamid] - teleports you to the specified player. Quote names with a space. Steam / Xbox ID is optional and only required, if multiple players have the same name."); <>c__DisplayClass0_.args.Context.AddString("summon [playername] [steamid] - teleports the specified player to you. Quote names with a space. Steam / Xbox ID is optional and only required, if multiple players have the same name."); <>c__DisplayClass0_.args.Context.AddString("giveitem [itemname] [quantity] [playername] [id] - adds the specified item to the specified players inventory in the specified quantity. Quote names with a space. Steam / Xbox ID is optional and only required, if multiple players have the same name. Will fail, if their inventory is full."); } } internal SkillType b__0_3(KeyValuePair kv) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return kv.Key; } internal Skill b__0_4(KeyValuePair kv) { //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) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown return new Skill(kv.Value.m_info) { m_accumulator = kv.Value.m_accumulator, m_level = kv.Value.m_level }; } internal List b__0_1() { return new List { "resetskill", "teleport", "summon", "raiseskill", "giveitem" }; } } [CompilerGenerated] private sealed class <>c__DisplayClass0_0 { public ConsoleEventArgs args; } private static void Postfix() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0050: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown object obj = <>c.<>9__0_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Invalid comparison between Unknown and I4 //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Invalid comparison between Unknown and I4 //IL_081e: Unknown result type (might be due to invalid IL or missing references) <>c__DisplayClass0_0 CS$<>8__locals0 = new <>c__DisplayClass0_0(); CS$<>8__locals0.args = args; if (!ServerCharacters.configSync.IsAdmin) { CS$<>8__locals0.args.Context.AddString("You are not an admin on this server."); } else if (CS$<>8__locals0.args.Length >= 3 && CS$<>8__locals0.args[1] == "resetskill") { if ((int)GetSkillType(CS$<>8__locals0.args[2]) == 999) { CS$<>8__locals0.args.Context.AddString(CS$<>8__locals0.args[2] + " is not a valid skill."); } else if (CS$<>8__locals0.args.Length > 3) { string text = CS$<>8__locals0.args[3]; int num = 4; if (text.StartsWith("\"", StringComparison.Ordinal)) { text = text.Substring(1); while (num < CS$<>8__locals0.args.Length && !text.EndsWith("\"", StringComparison.Ordinal)) { text = text + " " + CS$<>8__locals0.args[num++]; } text = text.Substring(0, text.Length - 1); } ZNet.instance.GetServerPeer().m_rpc.Invoke("ServerCharacters ResetSkill", new object[3] { CS$<>8__locals0.args[2], text, (CS$<>8__locals0.args.Length > num) ? CS$<>8__locals0.args[num] : "0" }); CS$<>8__locals0.args.Context.AddString(CS$<>8__locals0.args[2] + " has been reset for " + text + "."); } else { ZNet.instance.GetServerPeer().m_rpc.Invoke("ServerCharacters ResetSkill", new object[3] { CS$<>8__locals0.args[2], "", "0" }); CS$<>8__locals0.args.Context.AddString(CS$<>8__locals0.args[2] + " has been reset for everyone."); } } else if (CS$<>8__locals0.args.Length >= 3 && CS$<>8__locals0.args[1] == "raiseskill") { if ((int)GetSkillType(CS$<>8__locals0.args[2]) == 999) { CS$<>8__locals0.args.Context.AddString(CS$<>8__locals0.args[2] + " is not a valid skill."); } else if (CS$<>8__locals0.args.Length > 4) { string text2 = CS$<>8__locals0.args[4]; int num2 = 5; if (text2.StartsWith("\"", StringComparison.Ordinal)) { text2 = text2.Substring(1); while (num2 < CS$<>8__locals0.args.Length && !text2.EndsWith("\"", StringComparison.Ordinal)) { text2 = text2 + " " + CS$<>8__locals0.args[num2++]; } text2 = text2.Substring(0, text2.Length - 1); } ZNet.instance.GetServerPeer().m_rpc.Invoke("ServerCharacters RaiseSkill", new object[4] { CS$<>8__locals0.args[2], int.Parse(CS$<>8__locals0.args[3]), text2, (CS$<>8__locals0.args.Length > num2) ? CS$<>8__locals0.args[num2] : "0" }); CS$<>8__locals0.args.Context.AddString(CS$<>8__locals0.args[2] + " has been raised by " + CS$<>8__locals0.args[3] + " for " + text2 + "."); } else { ZNet.instance.GetServerPeer().m_rpc.Invoke("ServerCharacters RaiseSkill", new object[4] { CS$<>8__locals0.args[2], int.Parse(CS$<>8__locals0.args[3]), "", "0" }); CS$<>8__locals0.args.Context.AddString(CS$<>8__locals0.args[2] + " has been raised by " + CS$<>8__locals0.args[3] + " for everyone."); } } else if (CS$<>8__locals0.args.Length >= 3 && CS$<>8__locals0.args[1] == "giveitem") { if (ObjectDB.instance.GetItemPrefab(CS$<>8__locals0.args[2]) == null) { CS$<>8__locals0.args.Context.AddString(CS$<>8__locals0.args[2] + " is not a valid item."); } else if (CS$<>8__locals0.args.Length > 4) { string text3 = CS$<>8__locals0.args[4]; int num3 = 5; if (text3.StartsWith("\"", StringComparison.Ordinal)) { text3 = text3.Substring(1); while (num3 < CS$<>8__locals0.args.Length && !text3.EndsWith("\"", StringComparison.Ordinal)) { text3 = text3 + " " + CS$<>8__locals0.args[num3++]; } text3 = text3.Substring(0, text3.Length - 1); } ZNet.instance.GetServerPeer().m_rpc.Invoke("ServerCharacters GiveItem", new object[4] { CS$<>8__locals0.args[2], int.Parse(CS$<>8__locals0.args[3]), text3, (CS$<>8__locals0.args.Length > num3) ? CS$<>8__locals0.args[num3] : "0" }); CS$<>8__locals0.args.Context.AddString(CS$<>8__locals0.args[3] + "x " + CS$<>8__locals0.args[2] + " has been given to " + text3 + ", if their inventory isn't full."); } else { CS$<>8__locals0.args.Context.AddString("Please specify a target player."); } } else if (CS$<>8__locals0.args.Length >= 3 && CS$<>8__locals0.args[1] == "teleport") { string text4 = CS$<>8__locals0.args[2]; int num4 = 3; if (text4.StartsWith("\"", StringComparison.Ordinal)) { text4 = text4.Substring(1); while (num4 < CS$<>8__locals0.args.Length && !text4.EndsWith("\"", StringComparison.Ordinal)) { text4 = text4 + " " + CS$<>8__locals0.args[num4++]; } text4 = text4.Substring(0, text4.Length - 1); } ZNet.instance.GetServerPeer().m_rpc.Invoke("ServerCharacters GetPlayerPos", new object[2] { text4, (CS$<>8__locals0.args.Length > num4) ? CS$<>8__locals0.args[num4] : "0" }); ((MonoBehaviour)ServerCharacters.selfReference).StartCoroutine(AwaitResponse()); } else if (CS$<>8__locals0.args.Length >= 3 && CS$<>8__locals0.args[1] == "summon") { string text5 = CS$<>8__locals0.args[2]; int num5 = 3; if (text5.StartsWith("\"", StringComparison.Ordinal)) { text5 = text5.Substring(1); while (num5 < CS$<>8__locals0.args.Length && !text5.EndsWith("\"", StringComparison.Ordinal)) { text5 = text5 + " " + CS$<>8__locals0.args[num5++]; } text5 = text5.Substring(0, text5.Length - 1); } ZNet.instance.GetServerPeer().m_rpc.Invoke("ServerCharacters SendOwnPos", new object[3] { text5, (CS$<>8__locals0.args.Length > num5) ? CS$<>8__locals0.args[num5] : "0", ((Component)Player.m_localPlayer).transform.position }); ((MonoBehaviour)ServerCharacters.selfReference).StartCoroutine(AwaitResponse()); } else { CS$<>8__locals0.args.Context.AddString("ServerCharacters console commands - use 'ServerCharacters' followed by one of the following options."); CS$<>8__locals0.args.Context.AddString("resetskill [skillname] [playername] [id] - resets the skill for the specified player. Steam / Xbox ID is optional and only required, if multiple players have the same name. If no name is provided, the skill is reset for every character on the server, online and offline."); CS$<>8__locals0.args.Context.AddString("raiseskill [skillname] [level] [playername] [id] - raises the skill for the specified player by the specified level. Steam / Xbox ID is optional and only required, if multiple players have the same name. If no name is provided, the skill is raised for every character on the server, online and offline."); CS$<>8__locals0.args.Context.AddString("teleport [playername] [steamid] - teleports you to the specified player. Quote names with a space. Steam / Xbox ID is optional and only required, if multiple players have the same name."); CS$<>8__locals0.args.Context.AddString("summon [playername] [steamid] - teleports the specified player to you. Quote names with a space. Steam / Xbox ID is optional and only required, if multiple players have the same name."); CS$<>8__locals0.args.Context.AddString("giveitem [itemname] [quantity] [playername] [id] - adds the specified item to the specified players inventory in the specified quantity. Quote names with a space. Steam / Xbox ID is optional and only required, if multiple players have the same name. Will fail, if their inventory is full."); } [<17692631-e0d9-4bdb-8b7e-e1cff9bf39d5>NullableContext(1)] [IteratorStateMachine(typeof(<>c__DisplayClass0_0.<g__AwaitResponse|5>d))] IEnumerator AwaitResponse() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <>c__DisplayClass0_0.<g__AwaitResponse|5>d(0) { <>4__this = CS$<>8__locals0 }; } [<17692631-e0d9-4bdb-8b7e-e1cff9bf39d5>NullableContext(1)] [IteratorStateMachine(typeof(<>c__DisplayClass0_0.<g__AwaitResponse|7>d))] IEnumerator AwaitResponse() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <>c__DisplayClass0_0.<g__AwaitResponse|7>d(0) { <>4__this = CS$<>8__locals0 }; } }; <>c.<>9__0_0 = val; obj = (object)val; } object obj2 = <>c.<>9__0_1; if (obj2 == null) { ConsoleOptionsFetcher val2 = () => new List { "resetskill", "teleport", "summon", "raiseskill", "giveitem" }; <>c.<>9__0_1 = val2; obj2 = (object)val2; } new ConsoleCommand("ServerCharacters", "Manages the ServerCharacters commands.", (ConsoleEvent)obj, false, false, false, false, false, (ConsoleOptionsFetcher)obj2, false, false, false); [<17692631-e0d9-4bdb-8b7e-e1cff9bf39d5>NullableContext(1)] static SkillType GetSkillType(string name) { //IL_005a: 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) Dictionary skillData = ((Character)Player.m_localPlayer).GetSkills().m_skillData; Dictionary src = ((IEnumerable>)skillData).ToDictionary((Func, SkillType>)((KeyValuePair kv) => kv.Key), (Func, Skill>)((KeyValuePair kv) => new Skill(kv.Value.m_info) { m_accumulator = kv.Value.m_accumulator, m_level = kv.Value.m_level })); SaveLastSkillReset.last = (SkillType)999; try { SilenceConsole.silence = true; ((Character)Player.m_localPlayer).GetSkills().CheatResetSkill(name); } finally { SilenceConsole.silence = false; } Utils.OverwriteDict(src, skillData); return SaveLastSkillReset.last; } } [<17692631-e0d9-4bdb-8b7e-e1cff9bf39d5>NullableContext(1)] [CompilerGenerated] internal static SkillType g__GetSkillType|0_2(string name) { //IL_005a: 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) Dictionary skillData = ((Character)Player.m_localPlayer).GetSkills().m_skillData; Dictionary src = ((IEnumerable>)skillData).ToDictionary((Func, SkillType>)((KeyValuePair kv) => kv.Key), (Func, Skill>)((KeyValuePair kv) => new Skill(kv.Value.m_info) { m_accumulator = kv.Value.m_accumulator, m_level = kv.Value.m_level })); SaveLastSkillReset.last = (SkillType)999; try { SilenceConsole.silence = true; ((Character)Player.m_localPlayer).GetSkills().CheatResetSkill(name); } finally { SilenceConsole.silence = false; } Utils.OverwriteDict(src, skillData); return SaveLastSkillReset.last; } } [HarmonyPatch(typeof(PlayerProfile), "SavePlayerData")] private static class PatchPlayerProfilePlayerSave { [UsedImplicitly] private static void Prefix() { if (serverCharacter && doEmergencyBackup && playerSnapShotLast != null) { Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Humanoid)localPlayer).m_inventory.m_inventory = playerSnapShotLast.inventory; Utils.OverwriteDict(playerSnapShotLast.knownStations, localPlayer.m_knownStations); Utils.OverwriteDict(playerSnapShotLast.knownTexts, localPlayer.m_knownTexts); } } } } [<17692631-e0d9-4bdb-8b7e-e1cff9bf39d5>NullableContext(1)] [Nullable(0)] [HarmonyPatch(typeof(PlayerProfile), "SavePlayerToDisk")] private static class PatchPlayerProfileSave_Client { [CompilerGenerated] private sealed class <>c__DisplayClass0_0 { [Nullable(0)] public byte[] packageArray; } private static readonly MethodInfo ArrayWriter = AccessTools.DeclaredMethod(typeof(BinaryWriter), "Write", new Type[1] { typeof(byte[]) }, (Type[])null); private static readonly MethodInfo ServerCharacterSaver = AccessTools.DeclaredMethod(typeof(PatchPlayerProfileSave_Client), "SaveCharacterToServer", (Type[])null, (Type[])null); private static byte[] SaveCharacterToServer(byte[] packageArray, PlayerProfile profile) { <>c__DisplayClass0_0 CS$<>8__locals0 = new <>c__DisplayClass0_0(); CS$<>8__locals0.packageArray = packageArray; if (serverCharacter && doEmergencyBackup && serverEncryptionKey != null) { string characterSavePath = Utils.CharacterSavePath; char directorySeparatorChar = Path.DirectorySeparatorChar; File.WriteAllBytes(characterSavePath + directorySeparatorChar + profile.m_filename + ".fch.signature", generateProfileSignature(CS$<>8__locals0.packageArray, serverEncryptionKey)); string characterSavePath2 = Utils.CharacterSavePath; directorySeparatorChar = Path.DirectorySeparatorChar; File.WriteAllBytes(characterSavePath2 + directorySeparatorChar + profile.m_filename + ".fch.serverbackup", CS$<>8__locals0.packageArray); doEmergencyBackup = false; } if (serverCharacter && !currentlySaving) { ZNet instance = ZNet.instance; if (instance != null) { ZNetPeer serverPeer = instance.GetServerPeer(); if (((serverPeer != null) ? new bool?(serverPeer.IsReady()) : null).GetValueOrDefault()) { if (forceSynchronousSaving) { foreach (bool item in Shared.sendCompressedDataToPeer(ZNet.instance.GetServerPeer(), (iDied && ServerCharacters.hardcoreMode.GetToggle()) ? "ServerCharacters PlayerDied" : "ServerCharacters PlayerProfile", CS$<>8__locals0.packageArray)) { if (!item) { Thread.Sleep(10); } } } else { currentlySaving = true; ((MonoBehaviour)ZNet.instance).StartCoroutine(saveAsync()); } return CS$<>8__locals0.packageArray; } } } return CS$<>8__locals0.packageArray; [IteratorStateMachine(typeof(<>c__DisplayClass0_0.<g__saveAsync|0>d))] IEnumerator saveAsync() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <>c__DisplayClass0_0.<g__saveAsync|0>d(0) { <>4__this = CS$<>8__locals0 }; } } [UsedImplicitly] private static IEnumerable Transpiler(MethodBase method, IEnumerable instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch(new CodeInstruction(OpCodes.Callvirt, (object)ArrayWriter), (string)null) }).Insert((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Call, (object)ServerCharacterSaver) }).Instructions(); } } [<17692631-e0d9-4bdb-8b7e-e1cff9bf39d5>NullableContext(1)] [Nullable(0)] [HarmonyPatch] private class EnableSocketLinger { [CompilerGenerated] private sealed class d__4 : IEnumerable, IEnumerable, IEnumerator, IDisposable, IEnumerator { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; [Nullable(new byte[] { 0, 1 })] private IEnumerable codeInstructions; [Nullable(new byte[] { 0, 1 })] public IEnumerable <>3__codeInstructions; [Nullable(new byte[] { 0, 1 })] private IEnumerator <>7__wrap1; [Nullable(0)] private CodeInstruction 5__3; CodeInstruction IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] [return: Nullable(0)] get { return <>2__current; } } [DebuggerHidden] public d__4(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 2u) { try { } finally { <>m__Finally1(); } } <>7__wrap1 = null; 5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>7__wrap1 = codeInstructions.GetEnumerator(); <>1__state = -3; goto IL_00f1; case 1: <>1__state = -3; <>2__current = new CodeInstruction(OpCodes.Ldc_I4_1, (object)null); <>1__state = 2; return true; case 2: <>1__state = -3; goto IL_00cb; case 3: { <>1__state = -3; 5__3 = null; goto IL_00f1; } IL_00f1: if (<>7__wrap1.MoveNext()) { 5__3 = <>7__wrap1.Current; if (5__3.opcode == OpCodes.Call && CodeInstructionExtensions.OperandIs(5__3, (MemberInfo)socketClose)) { <>2__current = new CodeInstruction(OpCodes.Pop, (object)null); <>1__state = 1; return true; } goto IL_00cb; } <>m__Finally1(); <>7__wrap1 = null; return false; IL_00cb: <>2__current = 5__3; <>1__state = 3; return true; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap1 != null) { <>7__wrap1.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] [return: Nullable(0)] IEnumerator IEnumerable.GetEnumerator() { d__4 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__4(0); } d__.codeInstructions = <>3__codeInstructions; return d__; } [DebuggerHidden] [return: Nullable(0)] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } private static MethodInfo socketClose => AccessTools.Method(typeof(SteamNetworkingSockets), "CloseConnection", (Type[])null, (Type[])null); private static void dummy() { } private static MethodInfo TargetMethod() { Type type = Type.GetType("ZSteamSocket, assembly_valheim"); if ((object)type == null) { return AccessTools.DeclaredMethod(typeof(EnableSocketLinger), "dummy", (Type[])null, (Type[])null); } return AccessTools.DeclaredMethod(type, "Close", (Type[])null, (Type[])null); } [IteratorStateMachine(typeof(d__4))] private static IEnumerable Transpiler(IEnumerable codeInstructions) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__4(-2) { <>3__codeInstructions = codeInstructions }; } } [HarmonyPatch(typeof(Game), "Shutdown")] private static class PatchGameShutdown { [UsedImplicitly] private static void Prefix() { forceSynchronousSaving = true; } [UsedImplicitly] private static void Finalizer() { serverCharacter = false; forceSynchronousSaving = false; } } [HarmonyPatch(typeof(Player), "Save")] private static class StorePoisonDebuff { [<17692631-e0d9-4bdb-8b7e-e1cff9bf39d5>NullableContext(1)] private static void Prefix(Player __instance) { if (ServerCharacters.storePoison.GetToggle()) { StatusEffect statusEffect = ((Character)__instance).m_seman.GetStatusEffect(StringExtensionMethods.GetStableHashCode("Poison")); SE_Poison val = (SE_Poison)(object)((statusEffect is SE_Poison) ? statusEffect : null); if (val != null && !((Character)__instance).IsDead()) { __instance.m_customData["ServerCharacters PoisonDamage"] = val.m_damageLeft.ToString(CultureInfo.InvariantCulture); __instance.m_customData["ServerCharacters PoisonDamageHit"] = val.m_damagePerHit.ToString(CultureInfo.InvariantCulture); __instance.m_customData["ServerCharacters PoisonTTL"] = ((StatusEffect)val).m_ttl.ToString(CultureInfo.InvariantCulture); } else { __instance.m_customData.Remove("ServerCharacters PoisonDamage"); __instance.m_customData.Remove("ServerCharacters PoisonDamageHit"); __instance.m_customData.Remove("ServerCharacters PoisonTTL"); } } } } [HarmonyPatch(typeof(Player), "Load")] private static class LoadPoisonDebuff { [<17692631-e0d9-4bdb-8b7e-e1cff9bf39d5>NullableContext(1)] private static void Postfix(Player __instance) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) if (((Character)__instance).m_nview.m_zdo != null && ServerCharacters.storePoison.GetToggle() && __instance.m_customData.TryGetValue("ServerCharacters PoisonDamage", out var value) && value != "") { SE_Poison val = (SE_Poison)((Character)__instance).m_seman.AddStatusEffect(StringExtensionMethods.GetStableHashCode("Poison"), false, 0, 0f); val.m_damageLeft = float.Parse(__instance.m_customData["ServerCharacters PoisonDamage"], CultureInfo.InvariantCulture); val.m_damagePerHit = float.Parse(__instance.m_customData["ServerCharacters PoisonDamageHit"], CultureInfo.InvariantCulture); ((StatusEffect)val).m_ttl = float.Parse(__instance.m_customData["ServerCharacters PoisonTTL"], CultureInfo.InvariantCulture); } } } [<17692631-e0d9-4bdb-8b7e-e1cff9bf39d5>NullableContext(1)] [Nullable(0)] [HarmonyPatch(typeof(ZNet), "OnNewConnection")] private static class PatchZNetOnNewConnection { [UsedImplicitly] private static void Postfix(ZNet __instance, ZNetPeer peer) { //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Expected O, but got Unknown if (ZNet.instance.IsServer()) { return; } peer.m_rpc.Register("ServerCharacters PlayerProfile", Shared.receiveCompressedFromPeer(onReceivedProfile)); peer.m_rpc.Register("ServerCharacters KeyExchange", (Action)receiveEncryptionKeyFromServer); peer.m_rpc.Register("ServerCharacters IngameMessage", (Action)onReceivedIngameMessage); peer.m_rpc.Register("ServerCharacters KickMessage", (Action)onReceivedKickMessage); peer.m_rpc.Register("ServerCharacters ResetSkill", (Action)onReceivedResetSkill); peer.m_rpc.Register("ServerCharacters RaiseSkill", (Action)onReceivedRaiseSkill); peer.m_rpc.Register("ServerCharacters GetPlayerPos", (Action)onReceivedPlayerPos); peer.m_rpc.Register("ServerCharacters GiveItem", (Action)onReceivedGiveItem); peer.m_rpc.Register("ServerCharacters SendOwnPos", (Action)onReceivedOwnPos); peer.m_rpc.Register("ServerCharacters TeleportTo", (Action)onReceivedTeleportTo); string characterSavePath = Utils.CharacterSavePath; char directorySeparatorChar = Path.DirectorySeparatorChar; string path = characterSavePath + directorySeparatorChar + Game.instance.m_playerProfile.m_filename + ".fch.signature"; string characterSavePath2 = Utils.CharacterSavePath; directorySeparatorChar = Path.DirectorySeparatorChar; string path2 = characterSavePath2 + directorySeparatorChar + Game.instance.m_playerProfile.m_filename + ".fch.serverbackup"; if (!File.Exists(path) || !File.Exists(path2)) { return; } Utils.Log("Found emergency backup and signature for character '" + Game.instance.m_playerProfile.m_filename + "'. Trying to restore the backup."); ZPackage val = new ZPackage(); val.Write(File.ReadAllBytes(path2)); val.Write(File.ReadAllBytes(path)); foreach (bool item in Shared.sendCompressedDataToPeer(peer, "ServerCharacters CheckSignature", val.GetArray())) { if (!item) { Thread.Sleep(10); } } } private static void onReceivedOwnPos(ZRpc peerRpc, Vector3 pos) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (awaitingPos != null) { awaitingPos.SetResult(pos); awaitingPos = null; } } private static void onReceivedTeleportTo(ZRpc peerRpc, Vector3 pos) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Character)Player.m_localPlayer).TeleportTo(pos, Quaternion.identity, true); } private static void onReceivedPlayerPos(ZRpc peerRpc, Vector3 pos) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (awaitingPos != null) { awaitingPos.SetResult(pos); awaitingPos = null; } } private static void onReceivedGiveItem(ZRpc peerRpc, string itemName, int itemQuantity) { string text = (((Humanoid)Player.m_localPlayer).m_inventory.AddItem(ObjectDB.instance.GetItemPrefab(itemName), itemQuantity) ? $"An admin added {itemQuantity}x {itemName} to your inventory." : $"An admin tried to add {itemQuantity}x {itemName} to your inventory, but it is full."); ((Terminal)Chat.instance).AddString(text); Chat.instance.m_hideTimer = 0f; MessageHud.instance.ShowMessage((MessageType)2, text, 0, (Sprite)null, false); } private static void onReceivedResetSkill(ZRpc peerRpc, string skill) { Player.m_localPlayer.m_skills.CheatResetSkill(skill); string text = "An admin reset your skill " + skill; ((Terminal)Chat.instance).AddString(text); Chat.instance.m_hideTimer = 0f; MessageHud.instance.ShowMessage((MessageType)2, text, 0, (Sprite)null, false); } private static void onReceivedRaiseSkill(ZRpc peerRpc, string skill, int level) { Player.m_localPlayer.m_skills.CheatRaiseSkill(skill, (float)level, true); string text = $"An admin raised your skill {skill} by {level}"; ((Terminal)Chat.instance).AddString(text); Chat.instance.m_hideTimer = 0f; MessageHud.instance.ShowMessage((MessageType)2, text, 0, (Sprite)null, false); } private static void onReceivedIngameMessage(ZRpc peerRpc, string message) { ((Terminal)Chat.instance).AddString(message); Chat.instance.m_hideTimer = 0f; MessageHud.instance.ShowMessage((MessageType)2, message, 0, (Sprite)null, false); } private static void onReceivedKickMessage(ZRpc peerRpc, string message) { connectionError = message; } private static void onReceivedProfile(ZRpc peerRpc, byte[] profileData) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (profileData.Length == 0) { if (Game.instance.m_playerProfile.m_worldData.Count != 0) { Game.instance.Logout(true, true); ZNet.m_connectionStatus = (ConnectionStatus)5; connectionError = "Please create a new character, before connecting to this server, to avoid loss of data."; } else { serverCharacter = true; acquireCharacterFromTemplate = true; } return; } PlayerProfile val = new PlayerProfile(Game.instance.m_playerProfile.m_filename, (FileSource)0); if (!val.LoadPlayerProfileFromBytes(profileData) || Shared.CharacterNameIsForbidden(val.m_playerName)) { Game.instance.Logout(true, true); ZNet.m_connectionStatus = (ConnectionStatus)5; connectionError = "The saved data on the server was corrupt, please contact your server admin or create a new character."; } else { serverCharacter = true; Game.instance.m_playerProfile = val; cleanEmergencyBackup(); } } } [HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")] private static class DetectBackupOnlyMode { [UsedImplicitly] [<17692631-e0d9-4bdb-8b7e-e1cff9bf39d5>NullableContext(1)] private static void Postfix(ZNet __instance) { if (ServerCharacters.backupOnlyMode.GetToggle() && !__instance.IsServer()) { serverCharacter = true; } } } [HarmonyPatch(typeof(Game), "SpawnPlayer")] private class InitializePlayerFromTemplate { [UsedImplicitly] private static void Postfix() { //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) if (ServerCharacters.backupOnlyMode.GetToggle()) { cleanEmergencyBackup(); } bool num; if (!ServerCharacters.backupOnlyMode.GetToggle()) { num = !acquireCharacterFromTemplate; } else { if (Game.instance.GetPlayerProfile().HaveLogoutPoint()) { return; } num = Game.instance.GetPlayerProfile().HaveCustomSpawnPoint(); } if (num) { return; } acquireCharacterFromTemplate = false; ((Humanoid)Player.m_localPlayer).m_inventory.RemoveAll(); Player.m_localPlayer.m_skills.m_skillData.Clear(); Player.m_localPlayer.m_knownMaterial.Clear(); Player.m_localPlayer.m_knownRecipes.Clear(); Player.m_localPlayer.m_knownStations.Clear(); Player.m_localPlayer.m_knownTexts.Clear(); Player.m_localPlayer.m_uniques.Clear(); Player.m_localPlayer.m_trophies.Clear(); Player.m_localPlayer.m_customData.Clear(); ((Humanoid)Player.m_localPlayer).GiveDefaultItems(); try { PlayerTemplate playerTemplate = new DeserializerBuilder().IgnoreFields().Build().Deserialize(ServerCharacters.playerTemplate.Value); if (playerTemplate != null) { foreach (KeyValuePair skill in playerTemplate.skills) { ((Character)Player.m_localPlayer).GetSkills().CheatRaiseSkill(skill.Key, skill.Value, true); } Inventory inventory = ((Humanoid)Player.m_localPlayer).m_inventory; foreach (KeyValuePair item in playerTemplate.items) { inventory.AddItem(item.Key, item.Value, 1, 0, 0L, "", false); } List spawn = playerTemplate.spawn; if (spawn != null && spawn.Count > 0) { State state = Random.state; Random.InitState(((object)(PlatformUserID)(ref UserInfo.GetLocalUser().UserId)).GetHashCode()); int index = Random.Range(0, spawn.Count - 1); Random.state = state; ((Component)Player.m_localPlayer).transform.position = new Vector3((float)spawn[index].x, (float)spawn[index].y, (float)spawn[index].z); } } } catch (SerializationException) { } Game.instance.SavePlayerProfile(true); if (!(ServerCharacters.firstLoginMessage.Value != "")) { return; } foreach (Player allPlayer in Player.GetAllPlayers()) { ((Character)allPlayer).Message((MessageType)2, ServerCharacters.firstLoginMessage.Value.Replace("{name}", ((Character)Player.m_localPlayer).GetHoverName()), 0, (Sprite)null); } } } [HarmonyPatch(typeof(Valkyrie), "Awake")] private class ChangeValkyrieTarget { [<17692631-e0d9-4bdb-8b7e-e1cff9bf39d5>NullableContext(1)] private static void Prefix(Valkyrie __instance) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) if (!((Component)__instance).GetComponent().IsOwner()) { return; } try { PlayerTemplate playerTemplate = new DeserializerBuilder().IgnoreFields().Build().Deserialize(ServerCharacters.playerTemplate.Value); if (playerTemplate != null) { List spawn = playerTemplate.spawn; if (spawn != null && spawn.Count > 0) { State state = Random.state; Random.InitState(((object)(PlatformUserID)(ref UserInfo.GetLocalUser().UserId)).GetHashCode()); int index = Random.Range(0, spawn.Count - 1); Random.state = state; ((Component)Player.m_localPlayer).transform.position = new Vector3((float)spawn[index].x, (float)spawn[index].y, (float)spawn[index].z); } } } catch (SerializationException) { } } } [HarmonyPatch(typeof(Player), "OnSpawned")] private static class DisableValkyrieAndIntro { private static void Postfix(bool spawnValkyrie) { if (spawnValkyrie) { switch (ServerCharacters.newCharacterIntro.Value) { case Intro.Disabled: Game.instance.SkipIntro(); break; case Intro.Valkyrie: Game.instance.m_inIntro = (Game.instance.m_queuedIntro = false); TextViewer.instance.HideIntro(); break; } } } } [HarmonyPatch(typeof(Game), "FindSpawnPoint")] private class ReplaceSpawnPoint { private static bool CheckCustomSpawnPoint(out Vector3 pos) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) try { PlayerTemplate playerTemplate = new DeserializerBuilder().IgnoreFields().Build().Deserialize(ServerCharacters.playerTemplate.Value); if (playerTemplate == null) { pos = Vector3.zero; return false; } List spawn = playerTemplate.spawn; if (spawn != null && spawn.Count > 0) { State state = Random.state; Random.InitState(((object)(PlatformUserID)(ref UserInfo.GetLocalUser().UserId)).GetHashCode()); int index = Random.Range(0, spawn.Count - 1); Random.state = state; pos = new Vector3((float)spawn[index].x, (float)spawn[index].y, (float)spawn[index].z); return true; } } catch (SerializationException) { } pos = Vector3.zero; return false; } [<17692631-e0d9-4bdb-8b7e-e1cff9bf39d5>NullableContext(1)] private static IEnumerable Transpiler(IEnumerable _instructions, ILGenerator ilg) { //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Expected O, but got Unknown //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Expected O, but got Unknown //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(ZoneSystem), "GetLocationIcon", (Type[])null, (Type[])null); FieldInfo fieldInfo = AccessTools.DeclaredField(typeof(Game), "m_StartLocation"); List list = _instructions.ToList(); for (int i = 0; i < list.Count; i++) { if (i < list.Count - 4 && list[i].opcode == OpCodes.Callvirt && CodeInstructionExtensions.OperandIs(list[i], (MemberInfo)methodInfo) && list[i - 2].opcode == OpCodes.Ldfld && CodeInstructionExtensions.OperandIs(list[i - 2], (MemberInfo)fieldInfo)) { int num = i; MethodInfo methodInfo2 = AccessTools.DeclaredPropertyGetter(typeof(ZoneSystem), "instance"); while (list[num].opcode != OpCodes.Call || !CodeInstructionExtensions.OperandIs(list[num], (MemberInfo)methodInfo2)) { num--; } CodeInstruction obj = list.Skip(i).SkipWhile((CodeInstruction instr) => instr.opcode.FlowControl != FlowControl.Cond_Branch).Skip(1) .First(); Label label = ilg.DefineLabel(); obj.labels.Add(label); List