using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using LevelGeneration; using Localization; using LogUtils; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("LongerCodes")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("LongerCodes")] [assembly: AssemblyTitle("LongerCodes")] [assembly: AssemblyVersion("1.0.0.0")] 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 NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace LongerCodes { internal static class DinoLogger { private static ManualLogSource logger = Logger.CreateLogSource("LongerCodes"); public static void Log(string format, params object[] args) { Log(string.Format(format, args)); } public static void Log(string str) { if (logger != null) { logger.Log((LogLevel)8, (object)str); } } public static void Warning(string format, params object[] args) { Warning(string.Format(format, args)); } public static void Warning(string str) { if (logger != null) { logger.Log((LogLevel)4, (object)str); } } public static void Error(string format, params object[] args) { Error(string.Format(format, args)); } public static void Error(string str) { if (logger != null) { logger.Log((LogLevel)2, (object)str); } } public static void Debug(string format, params object[] args) { Debug(string.Format(format, args)); } public static void Debug(string str) { if (logger != null) { logger.Log((LogLevel)32, (object)str); } } } [BepInPlugin("com.Brandont.LongerCodes", "LongerCodes", "1.1.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] internal sealed class EntryPoint : BasePlugin { public const string MODNAME = "LongerCodes"; public override void Load() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) new Harmony("LongerCodes").PatchAll(); ((BasePlugin)this).Log.LogMessage((object)"Loaded LongerCodes"); } } [HarmonyPatch] internal static class SerialGeneratorPatch { private static Random _random; public static LocalizedText StringToLocalized(string stringConvert) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown return new LocalizedText { Id = 0u, UntranslatedText = stringConvert }; } [HarmonyPatch(typeof(TerminalUplinkPuzzle), "GetCodesString")] [HarmonyPrefix] private static bool ReturnNewString(ref string __result, TerminalUplinkPuzzleRound round) { string text = "\n"; for (int i = 0; i < ((Il2CppArrayBase)(object)round.Codes).Length; i++) { text = text + "" + ((Il2CppArrayBase)(object)round.Prefixes)[i] + ":" + ((Il2CppArrayBase)(object)round.Codes)[i]; if (i < ((Il2CppArrayBase)(object)round.Codes).Length - 1) { text += (((i + 1) % 3 != 0) ? " | " : "\n"); } } __result = text; return false; } [HarmonyPatch(typeof(SerialGenerator), "Setup")] [HarmonyPrefix] private static void OverrideSerialGenerator() { SerialGenerator.m_codeWordPrefixes = Il2CppStringArray.op_Implicit(new string[84] { "A-01", "A-02", "A-03", "A-04", "A-05", "A-06", "A-07", "A-08", "A-09", "A-10", "A-11", "A-12", "B-01", "B-02", "B-03", "B-04", "B-05", "B-06", "B-07", "B-08", "B-09", "B-10", "B-11", "B-12", "C-01", "C-02", "C-03", "C-04", "C-05", "C-06", "C-07", "C-08", "C-09", "C-10", "C-11", "C-12", "W-01", "W-02", "W-03", "W-04", "W-05", "W-06", "W-07", "W-08", "W-09", "W-10", "W-11", "W-12", "X-01", "X-02", "X-03", "X-04", "X-05", "X-06", "X-07", "X-08", "X-09", "X-10", "X-11", "X-12", "Y-01", "Y-02", "Y-03", "Y-04", "Y-05", "Y-06", "Y-07", "Y-08", "Y-09", "Y-10", "Y-11", "Y-12", "Z-01", "Z-02", "Z-03", "Z-04", "Z-05", "Z-06", "Z-07", "Z-08", "Z-09", "Z-10", "Z-11", "Z-12" }); SerialGenerator.m_codeWords = Il2CppStringArray.op_Implicit(new string[240] { "abacus", "abject", "ablaze", "abroad", "abrupt", "absorb", "abused", "accept", "access", "accuse", "admire", "agreed", "alarms", "albeit", "alerts", "aligns", "beacon", "beaker", "beamed", "beaten", "beauty", "bedlam", "before", "behind", "belfry", "bended", "berate", "beside", "bestir", "betide", "bigger", "binged", "binned", "bisect", "bitten", "bladed", "blamed", "blazed", "blonde", "boated", "bodily", "boiled", "bolted", "borrow", "bouncy", "choice", "choose", "chosen", "church", "circle", "client", "closed", "closer", "coffee", "column", "combat", "coming", "common", "desert", "design", "desire", "detail", "detect", "device", "differ", "dinner", "direct", "eighth", "either", "eleven", "emerge", "empire", "employ", "enable", "ending", "energy", "engage", "engine", "enough", "ensure", "entire", "entity", "finger", "finish", "fiscal", "flight", "flying", "follow", "forced", "forest", "forget", "formal", "format", "former", "foster", "fought", "glowed", "gluten", "goggle", "gossip", "graded", "grains", "grassy", "grater", "gravel", "grease", "greedy", "groove", "grudge", "guided", "guitar", "gunner", "gurgle", "gabber", "harass", "hardly", "harmed", "hazard", "heated", "heaven", "herbal", "hereby", "heroes", "herpes", "hinder", "hinged", "hissed", "hoarse", "instep", "inward", "indent", "indium", "iodize", "infant", "influx", "jersey", "jetsam", "jigsaw", "jingle", "jogged", "joiner", "joking", "jumble", "jumble", "jumped", "junker", "leader", "league", "leaves", "legacy", "length", "lesson", "letter", "lights", "likely", "linked", "liquid", "listen", "little", "medium", "member", "memory", "mental", "merely", "merger", "method", "middle", "miller", "mining", "minute", "mirror", "mobile", "narrow", "nation", "native", "nature", "nearby", "nearly", "nights", "nobody", "normal", "notice", "notion", "number", "packed", "palace", "parent", "partly", "patent", "people", "period", "permit", "person", "phrase", "picked", "planet", "player", "raised", "random", "rarely", "rather", "rating", "reader", "really", "reason", "recall", "recent", "sexual", "should", "signal", "signed", "silent", "silver", "simple", "simply", "single", "sister", "slight", "smooth", "theory", "thirty", "though", "threat", "thrown", "ticket", "timely", "timing", "tissue", "toward", "unique", "useful", "vacant", "vacuum", "vigour", "walker", "wealth", "weekly", "weight", "winner", "winter" }); } [HarmonyPatch(typeof(SerialGenerator), "Setup")] [HarmonyPostfix] private static void IPV6Uplinks() { _random = new Random(Builder.SessionSeedRandom.Seed); SerialGenerator.m_ips = Il2CppStringArray.op_Implicit(new string[99]); for (int i = 0; i < ((Il2CppArrayBase)(object)SerialGenerator.m_ips).Length; i++) { string[] array = new string[4] { RandomHex(256, 4608), RandomHex(4096, 65535), RandomHex(0, 511), RandomHex(0, 16383) }; Shuffle(array); ((Il2CppArrayBase)(object)SerialGenerator.m_ips)[i] = RandomHex(8192, 16383) + "::" + string.Join(':', array); } } [HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "TerminalCorruptedUplinkConnect")] [HarmonyPrefix] private static bool NoUpperCase(LG_ComputerTerminalCommandInterpreter __instance, string param1, string param2) { if ((Object)(object)__instance.m_terminal.CorruptedUplinkReceiver == (Object)null) { DebugLog.LogPrefixError((Object)(object)__instance, "TerminalCorruptedUplinkConnect() critical failure because terminal does not have a CorruptedUplinkReceiver."); return false; } if (LG_ComputerTerminalManager.OngoingUplinkConnectionTerminalId != 0 && LG_ComputerTerminalManager.OngoingUplinkConnectionTerminalId != __instance.m_terminal.SyncID) { __instance.AddOngoingUplinkOutput(); return false; } LG_ComputerTerminalManager.OngoingUplinkConnectionTerminalId = __instance.m_terminal.SyncID; Debug.Log(Object.op_Implicit("TerminalCorruptedUplinkConnect, param1: " + param1 + " TerminalUplink: " + ((Object)__instance.m_terminal.UplinkPuzzle).ToString())); if (param1 == __instance.m_terminal.UplinkPuzzle.TerminalUplinkIP) { if (__instance.m_terminal.CorruptedUplinkReceiver.m_command.HasRegisteredCommand((TERM_Command)27)) { __instance.AddUplinkCorruptedOutput(); } else { __instance.AddUplinkCorruptedOutput(); __instance.AddOutput("", true); __instance.AddOutput((TerminalLineType)4, "Sending connection request to " + __instance.m_terminal.CorruptedUplinkReceiver.PublicName, 3f, (TerminalSoundType)0, (TerminalSoundType)0); __instance.AddOutput((TerminalLineType)0, "Connection request sent. Waiting for confirmation.", 0.6f, (TerminalSoundType)0, (TerminalSoundType)0); __instance.AddOutput("", true); __instance.AddOutput((TerminalLineType)0, "Please 'CONFIRM' connection on " + __instance.m_terminal.CorruptedUplinkReceiver.PublicName, 0.8f, (TerminalSoundType)0, (TerminalSoundType)0); __instance.m_terminal.CorruptedUplinkReceiver.m_command.AddCommand((TERM_Command)27, "CONFIRM", StringToLocalized("Confirm an established Uplink connection with this terminal and another."), (TERM_CommandRule)2); __instance.m_terminal.CorruptedUplinkReceiver.m_command.AddOutput((TerminalLineType)0, "Connection request from " + __instance.m_terminal.PublicName + ". Please type CONFIRM to continue.", 0f, (TerminalSoundType)0, (TerminalSoundType)0); } } else { __instance.AddUplinkWrongAddressError(param1); } return false; } private static string RandomHex(int min, int max) { return Builder.SessionSeedRandom.Range(min, max, "NO_TAG").ToString("x"); } private static void Shuffle(T[] array) { int num = array.Length; while (num > 1) { int num2 = _random.Next(0, num--); int num3 = num2; int num4 = num; T val = array[num]; T val2 = array[num2]; array[num3] = val; array[num4] = val2; } } } }