diff --git a/CringeLauncher/Utils/ThreadPoolScheduler.cs b/CringeLauncher/Utils/ThreadPoolScheduler.cs index 8d1ded7..0a641af 100644 --- a/CringeLauncher/Utils/ThreadPoolScheduler.cs +++ b/CringeLauncher/Utils/ThreadPoolScheduler.cs @@ -1,5 +1,6 @@ using System.Diagnostics; using System.Reflection; +using System.Reflection.Emit; using HarmonyLib; using Havok; using ParallelTasks; @@ -33,6 +34,30 @@ public class ThreadPoolScheduler : IWorkScheduler public int ThreadCount { get; } = ThreadPool.ThreadCount; } +[HarmonyPatch] +internal class KeenThreadingPatch +{ + private static MethodBase TargetMethod() + { + var type = Type.GetType( + "VRage.Render11.Resources.Textures.MyTextureStreamingManager+MyStreamedTextureBase, VRage.Render11"); + + return AccessTools.FirstConstructor(type, _ => true); + } + + private static IEnumerable Transpiler(IEnumerable instructions) + { + var property = AccessTools.Property(typeof(Environment), nameof(Environment.ProcessorCount)); + + return instructions.Manipulator(i => i.Calls(property.GetMethod), + i => + { + i.opcode = OpCodes.Ldc_I4; + i.operand = 1024; + }); + } +} + [HarmonyPatch] internal class ThreadPoolWorkItemTask(CringeTask task) : IThreadPoolWorkItem {