Skip to content

Commit

Permalink
Fix tiered backup support
Browse files Browse the repository at this point in the history
  • Loading branch information
Equinox- committed Mar 19, 2024
1 parent ef4bccb commit 90480d7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Meds.Wrapper/Shim/NoDoubleReplicationPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
{
Expand Down
12 changes: 11 additions & 1 deletion Meds.Wrapper/Shim/TieredBackups.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,19 @@ public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructio
}
}

[HarmonyPatch(typeof(MySessionBackup), "MakeBackup")]
[HarmonyPatch]
[AlwaysPatch]
public static class TieredBackupsHookRetention
{

public static IEnumerable<MethodBase> 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<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
foreach (var instruction in instructions)
Expand Down

0 comments on commit 90480d7

Please sign in to comment.