Added options to disable launcher/plugin auto updates
All checks were successful
Build / Compute Version (push) Successful in 6s
Build / Build Nuget package (CringeBootstrap.Abstractions) (push) Successful in 4m4s
Build / Build Nuget package (NuGet) (push) Successful in 4m7s
Build / Build Nuget package (SharedCringe) (push) Successful in 4m5s
Build / Build Nuget package (CringePlugins) (push) Successful in 4m25s
Build / Build Launcher (push) Successful in 5m12s

Also ran cleanup
This commit is contained in:
2025-06-06 01:35:09 -04:00
parent bc88f0c28a
commit 94fc8a55c0
48 changed files with 381 additions and 267 deletions

View File

@@ -16,15 +16,15 @@ public static class EosInitPatch
var ins = instructions.ToList();
var stIndex = ins.FindIndex(b => b.opcode == OpCodes.Stloc_1);
ins.InsertRange(stIndex, new []
{
ins.InsertRange(stIndex,
[
new CodeInstruction(OpCodes.Dup),
new(OpCodes.Ldc_I4_2), // PlatformFlags.DisableOverlay
new(OpCodes.Conv_I8),
CodeInstruction.Call("Epic.OnlineServices.Platform.Options:set_Flags"),
});
CodeInstruction.Call("Epic.OnlineServices.Platform.Options:set_Flags"),
]);
return ins;
}
}

View File

@@ -42,23 +42,26 @@ public static class IntrospectionPatches
//mods need to look for specific derived types
Debug.WriteLine($"Getting special types for {__instance.FullName}");
var module = __instance.GetMainModule();
__result = IntrospectionContext.Global.CollectDerivedTypes<MyObjectBuilder_Base>(module)
.Concat(IntrospectionContext.Global.CollectDerivedTypes<MyStatLogic>(module))
.Concat(IntrospectionContext.Global.CollectAttributedTypes<MyObjectBuilderDefinitionAttribute>(module))
.Concat(IntrospectionContext.Global.CollectDerivedTypes<MyComponentBase>(module))
.Concat(IntrospectionContext.Global.CollectAttributedTypes<MyComponentBuilderAttribute>(module))
.Concat(IntrospectionContext.Global.CollectDerivedTypes<IMyTextSurfaceScript>(module))
.Concat(IntrospectionContext.Global.CollectDerivedTypes<IMyUseObject>(module))
.Concat(IntrospectionContext.Global.CollectDerivedTypes<IMyHudStat>(module))
.Concat(IntrospectionContext.Global.CollectAttributedTypes<MySessionComponentDescriptor>(module))
.ToArray();
__result =
[
.. IntrospectionContext.Global.CollectDerivedTypes<MyObjectBuilder_Base>(module)
,
.. IntrospectionContext.Global.CollectDerivedTypes<MyStatLogic>(module),
.. IntrospectionContext.Global.CollectAttributedTypes<MyObjectBuilderDefinitionAttribute>(module),
.. IntrospectionContext.Global.CollectDerivedTypes<MyComponentBase>(module),
.. IntrospectionContext.Global.CollectAttributedTypes<MyComponentBuilderAttribute>(module),
.. IntrospectionContext.Global.CollectDerivedTypes<IMyTextSurfaceScript>(module),
.. IntrospectionContext.Global.CollectDerivedTypes<IMyUseObject>(module),
.. IntrospectionContext.Global.CollectDerivedTypes<IMyHudStat>(module),
.. IntrospectionContext.Global.CollectAttributedTypes<MySessionComponentDescriptor>(module),
];
return false;
}
Debug.WriteLine($"Blocking GetTypes for {__instance.FullName}");
__result = [];
return false;
}
@@ -74,10 +77,9 @@ public static class IntrospectionPatches
__result = [];
return false;
}
// static classes are abstract
__result = IntrospectionContext.Global.CollectAttributedTypes<HarmonyAttribute>(assembly.GetMainModule(), true)
.ToArray();
__result = [.. IntrospectionContext.Global.CollectAttributedTypes<HarmonyAttribute>(assembly.GetMainModule(), true)];
return false;
}
@@ -101,13 +103,13 @@ public static class IntrospectionPatches
.Concat(PluginsLifetime.Contexts.SelectMany(x => x.Assemblies)) ?? [];
return false;
}
[HarmonyPrefix, HarmonyPatch(typeof(MySession), "PrepareBaseSession", typeof(MyObjectBuilder_Checkpoint), typeof(MyObjectBuilder_Sector))]
private static void PrepareSessionPrefix()
{
// i hate keen for that in MyUseObjectFactory..cctor
// MyUseObjectFactory.RegisterAssemblyTypes(Assembly.LoadFrom(Path.Combine(MyFileSystem.ExePath, "Sandbox.Game.dll")));
MyUseObjectFactory.RegisterAssemblyTypes(MyPlugins.SandboxGameAssembly);
}
@@ -117,10 +119,10 @@ public static class IntrospectionPatches
foreach (var type in assemblies.SelectMany(b => IntrospectionContext.Global.CollectDerivedTypes<IPlugin>(b.GetMainModule())))
{
var instance = Activator.CreateInstance(type);
if (instance is IPlugin plugin)
___m_plugins.Add(plugin);
if (instance is IHandleInputPlugin handleInputPlugin)
___m_handleInputPlugins.Add(handleInputPlugin);
}
@@ -138,22 +140,22 @@ public static class IntrospectionPatches
if (assembly?.GetType($"Microsoft.Xml.Serialization.GeneratedAssembly.{typeName}Serializer") is not { } type)
return false;
__result = Activator.CreateInstance(type) as XmlSerializer;
return false;
}
[HarmonyPrefix, HarmonyPatch(typeof(MyXmlSerializerManager), nameof(MyXmlSerializerManager.RegisterFromAssembly))]
private static bool XmlManagerRegisterPrefix(Assembly assembly) => AssemblyLoadContext.GetLoadContext(assembly) is ICoreLoadContext;
[HarmonyPatch]
private static class GameAssembliesPatch
{
private static IEnumerable<MethodInfo> TargetMethods()
{
return AccessTools.GetDeclaredMethods(typeof(MyPlugins))
.Where(b => b.Name.StartsWith("Register") &&
.Where(b => b.Name.StartsWith("Register") &&
b.GetParameters() is [var param] && param.ParameterType == typeof(string));
}

View File

@@ -13,7 +13,7 @@ public static class PluginNamePatch
// to be just $"Plugin Init: {plugin}"
// so you could override .ToString
// doesn't change default behavior since base .ToString is .GetType().ToString()
return new CodeMatcher(instructions)
.SearchForward(b => b.Is(OpCodes.Ldstr, "Plugin Init: "))
.Advance(2)

View File

@@ -10,7 +10,7 @@ namespace CringeLauncher.Patches;
public static class ScriptCompilationSettingsPatch
{
private static readonly CSharpParseOptions Options = new(LanguageVersion.Latest, DocumentationMode.None);
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
var field = AccessTools.Field(typeof(MyScriptCompiler), nameof(MyScriptCompiler.m_conditionalParseOptions));

View File

@@ -14,7 +14,7 @@ public static class ScriptCompilerInitializationPatch
return AccessTools.Method(Type.GetType("VRage.Scripting.MyVRageScriptingInternal, VRage.Scripting", true),
"Initialize");
}
private static bool Prefix(Thread updateThread, Type[] referencedTypes, string[] symbols)
{
MyModWatchdog.Init(updateThread);

View File

@@ -18,10 +18,10 @@ public static class SwapChainPatch
WindowHandle = windowHandle;
MyPlatformRender.DisposeSwapChain();
MyPlatformRender.Log.WriteLine("CreateDeviceInternal create swapchain");
if (MyPlatformRender.m_swapchain != null)
return false;
var chainDescription = new SwapChainDescription
{
BufferCount = 2,
@@ -39,7 +39,7 @@ public static class SwapChainPatch
Usage = Usage.ShaderInput | Usage.RenderTargetOutput,
SwapEffect = SwapEffect.Discard
};
var factory = MyPlatformRender.GetFactory();
try
{
@@ -62,7 +62,7 @@ public static class SwapChainPatch
{
ImGuiHandler.Instance?.Init(WindowHandle, MyRender11.DeviceInstance, MyRender11.RC.DeviceContext);
}
[HarmonyPrefix, HarmonyPatch(typeof(MyBackbuffer), MethodType.Constructor, typeof(SharpDX.Direct3D11.Resource))]
private static bool SwapChainBBPrefix(MyBackbuffer __instance, SharpDX.Direct3D11.Resource swapChainBB)
{
@@ -73,13 +73,13 @@ public static class SwapChainPatch
Dimension = RenderTargetViewDimension.Texture2D,
});
__instance.m_srv = new ShaderResourceView(MyRender11.DeviceInstance, swapChainBB);
ImGuiHandler.Rtv = new RenderTargetView(MyRender11.DeviceInstance, swapChainBB, new()
{
Format = Format.R8G8B8A8_UNorm,
Dimension = RenderTargetViewDimension.Texture2D,
});
return false;
}
@@ -87,7 +87,7 @@ public static class SwapChainPatch
private static void SwapChainBBReleasePrefix(MyBackbuffer __instance)
{
if (ImGuiHandler.Rtv is null) return;
ImGuiHandler.Rtv.Dispose();
ImGuiHandler.Rtv = null;
}

View File

@@ -10,7 +10,7 @@ public static class WhitelistAllowPatch
private static void Prefix(ref MemberInfo[] members)
{
if (members.Any(b => b is null))
members = members.Where(b => b is { }).ToArray();
members = [.. members.Where(b => b is { })];
}
private static Exception? Finalizer(Exception __exception)

View File

@@ -14,7 +14,7 @@ public static class WhitelistPatch
private static void Prefix(MyScriptCompiler scriptCompiler)
{
var baseDir = new FileInfo(typeof(Type).Assembly.Location).DirectoryName!;
scriptCompiler.AddReferencedAssemblies(
typeof(Type).Assembly.Location,
typeof(LinkedList<>).Assembly.Location,

View File

@@ -9,7 +9,7 @@ public static class WhitelistTypeResolutionPatch
{
[HarmonyReversePatch]
private static INamedTypeSymbol ResolveTypeSymbol(MyScriptWhitelist.Batch batch, Type type) => throw null!;
// cant be assed to write a transpiler so heres a prefix
private static bool Prefix(MyScriptWhitelist.Batch __instance, Type type, ref INamedTypeSymbol __result)
{
@@ -26,18 +26,18 @@ public static class WhitelistTypeResolutionPatch
// if type is not generic or constructed generic, run regular lookup
if (!type.IsGenericType || !type.IsConstructedGenericType)
return ResolveTypeSymbol(batch, type);
var unconstructedSymbol = ResolveTypeSymbol(batch, type.GetGenericTypeDefinition());
var typeArguments = type.GetGenericArguments();
var typeSymbolArguments = new ITypeSymbol[typeArguments.Length];
for (var i = 0; i < typeArguments.Length; i++)
{
// recursively resolve (possibly) generic arguments
typeSymbolArguments[i] = ResolveGenericTypeSymbol(batch, typeArguments[i]);
}
return unconstructedSymbol.Construct(typeSymbolArguments);
}
}

View File

@@ -11,26 +11,26 @@ public static class XmlRootWriterPatch
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
var ins = instructions.ToList();
var index = ins.FindIndex(b =>
b.opcode == OpCodes.Ldstr && b.operand is "xsi:type");
ins[index].operand = "xsi";
ins.InsertRange(index + 1, new[]
{
ins.InsertRange(index + 1,
[
new CodeInstruction(OpCodes.Ldstr, "type"),
new CodeInstruction(OpCodes.Ldstr, "http://www.w3.org/2001/XMLSchema-instance")
});
]);
var instruction = ins[ins.FindIndex(b => b.opcode == OpCodes.Callvirt)];
instruction.operand = AccessTools.Method(typeof(XmlWriter), "WriteAttributeString", new[]
{
instruction.operand = AccessTools.Method(typeof(XmlWriter), "WriteAttributeString",
[
typeof(string),
typeof(string),
typeof(string),
typeof(string)
});
]);
return ins;
}
}