From 90480d7870f4fe80fa263c1f308d32b09335db51 Mon Sep 17 00:00:00 2001 From: Westin Miller Date: Tue, 19 Mar 2024 16:44:02 -0700 Subject: [PATCH] Fix tiered backup support --- Meds.Wrapper/Shim/NoDoubleReplicationPatches.cs | 5 +++-- Meds.Wrapper/Shim/TieredBackups.cs | 12 +++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Meds.Wrapper/Shim/NoDoubleReplicationPatches.cs b/Meds.Wrapper/Shim/NoDoubleReplicationPatches.cs index 0fce12b..968dfb5 100644 --- a/Meds.Wrapper/Shim/NoDoubleReplicationPatches.cs +++ b/Meds.Wrapper/Shim/NoDoubleReplicationPatches.cs @@ -66,7 +66,8 @@ public static void Postfix(ref int __state) } [HarmonyPatch(typeof(MyProceduralEnvironmentProvider), nameof(MyProceduralEnvironmentProvider.GetObjectBuilder))] - [AlwaysPatch] + [AlwaysPatch(ByRequest = nameof(NoDoubleReplicationEnvironmentSectors))] + // This seems to be causing some issues where environment sectors don't synchronize in time. Not totally sure why. public static class NoDoubleReplicationEnvironmentSectors { public static bool Prefix(ref MyObjectBuilder_EnvironmentDataProvider __result) @@ -79,7 +80,7 @@ public static bool Prefix(ref MyObjectBuilder_EnvironmentDataProvider __result) } [HarmonyPatch(typeof(MyInventory), nameof(MyInventory.Serialize))] - // [AlwaysPatch] + [AlwaysPatch(ByRequest = nameof(NoDoubleReplicationInventory))] // For this to work correctly the client also needs to be updated so that it always sends the inventory changed event, even on the initial deserialization. public static class NoDoubleReplicationInventory { diff --git a/Meds.Wrapper/Shim/TieredBackups.cs b/Meds.Wrapper/Shim/TieredBackups.cs index 120625e..1d13f09 100644 --- a/Meds.Wrapper/Shim/TieredBackups.cs +++ b/Meds.Wrapper/Shim/TieredBackups.cs @@ -151,9 +151,19 @@ public static IEnumerable Transpiler(IEnumerable TargetMethods() + { + foreach (var method in AccessTools.GetDeclaredMethods(typeof(MySessionBackup))) + if (method.Name == "MakeBackup" && method.GetParameters().Length == 1 && + method.GetParameters()[0].ParameterType == AccessTools.Inner(typeof(MySessionBackup), "BackupArgs")) + yield return method; + } + public static IEnumerable Transpiler(IEnumerable instructions) { foreach (var instruction in instructions)