fix crash
All checks were successful
Build / Build Launcher (push) Successful in 1m7s

This commit is contained in:
zznty
2024-08-30 03:50:17 +07:00
parent a4a0cdefe5
commit bd63575630

View File

@@ -1,5 +1,6 @@
using System.Diagnostics; using System.Diagnostics;
using System.Reflection; using System.Reflection;
using System.Reflection.Emit;
using HarmonyLib; using HarmonyLib;
using Havok; using Havok;
using ParallelTasks; using ParallelTasks;
@@ -33,6 +34,30 @@ public class ThreadPoolScheduler : IWorkScheduler
public int ThreadCount { get; } = ThreadPool.ThreadCount; 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<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> 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] [HarmonyPatch]
internal class ThreadPoolWorkItemTask(CringeTask task) : IThreadPoolWorkItem internal class ThreadPoolWorkItemTask(CringeTask task) : IThreadPoolWorkItem
{ {