diff --git a/src/OWML.Common/Interfaces/IOwmlConfig.cs b/src/OWML.Common/Interfaces/IOwmlConfig.cs index b8cda403..a1d996ba 100644 --- a/src/OWML.Common/Interfaces/IOwmlConfig.cs +++ b/src/OWML.Common/Interfaces/IOwmlConfig.cs @@ -22,6 +22,8 @@ public interface IOwmlConfig bool ForceExe { get; set; } + bool IncrementalGC { get; set; } + int SocketPort { get; set; } } } diff --git a/src/OWML.Common/OwmlConfig.cs b/src/OWML.Common/OwmlConfig.cs index 09e1ff39..2b79d451 100644 --- a/src/OWML.Common/OwmlConfig.cs +++ b/src/OWML.Common/OwmlConfig.cs @@ -14,6 +14,9 @@ public class OwmlConfig : IOwmlConfig [JsonProperty("forceExe")] public bool ForceExe { get; set; } + [JsonProperty("incrementalGC")] + public bool IncrementalGC { get; set; } + [JsonIgnore] public bool IsSpaced => Directory.Exists(Path.Combine(GamePath, "Outer Wilds_Data")); diff --git a/src/OWML.Launcher/OWML.DefaultConfig.json b/src/OWML.Launcher/OWML.DefaultConfig.json index a10adb2c..33b29871 100644 --- a/src/OWML.Launcher/OWML.DefaultConfig.json +++ b/src/OWML.Launcher/OWML.DefaultConfig.json @@ -2,5 +2,6 @@ "gamePath": "C:/Program Files (x86)/Steam/steamapps/common/Outer Wilds", "debugMode": false, "forceExe": false, + "incrementalGC": false, "socketPort": 0 } diff --git a/src/OWML.Launcher/OWML.Manifest.json b/src/OWML.Launcher/OWML.Manifest.json index 268c6508..7c040f16 100644 --- a/src/OWML.Launcher/OWML.Manifest.json +++ b/src/OWML.Launcher/OWML.Manifest.json @@ -3,7 +3,7 @@ "author": "Alek", "name": "OWML", "uniqueName": "Alek.OWML", - "version": "2.7.4", + "version": "2.7.5", "minGameVersion": "1.1.13.393", - "maxGameVersion": "1.1.13.450" + "maxGameVersion": "1.1.13.456" } diff --git a/src/OWML.Launcher/game-versions.json b/src/OWML.Launcher/game-versions.json index d2bc2126..55619cfa 100644 --- a/src/OWML.Launcher/game-versions.json +++ b/src/OWML.Launcher/game-versions.json @@ -1,5 +1,5 @@ { - "steam": "1.1.13.450", - "epic": "1.1.13.450", - "gamepass": "1.1.13.450" + "steam": "1.1.13.456", + "epic": "1.1.13.456", + "gamepass": "1.1.13.456" } diff --git a/src/OWML.Patcher/OWPatcher.cs b/src/OWML.Patcher/OWPatcher.cs index a7e2adb2..af63274e 100644 --- a/src/OWML.Patcher/OWPatcher.cs +++ b/src/OWML.Patcher/OWPatcher.cs @@ -15,6 +15,7 @@ public class OWPatcher : IOWPatcher private const string PatchClass = "PermanentManager"; private const string PatchMethod = "Awake"; + private const string IncGCProperty = "gc-max-time-slice=3"; public OWPatcher(IOwmlConfig owmlConfig, IModConsole writer) { @@ -27,6 +28,7 @@ public void PatchGame() CopyOWMLFiles(); CopyLibFiles(); PatchAssembly(); + UpdateIncrementalGC(); } private void CopyOWMLFiles() @@ -136,6 +138,29 @@ private void PatchAssembly() Save(patcher); } + private void UpdateIncrementalGC() + { + _writer.WriteLine("Updating incremental GC..."); + + var incGCEnabled = _owmlConfig.IncrementalGC; + + var bootConfigPath = Path.Combine(_owmlConfig.DataPath, "boot.config"); + var bootConfigText = File.ReadAllText(bootConfigPath); + + var alreadyEnabled = bootConfigText.Contains(IncGCProperty + Environment.NewLine); + + if (alreadyEnabled && !incGCEnabled) + { + _writer.WriteLine("- Disabling incremental GC"); + File.WriteAllText(bootConfigPath, bootConfigText.Replace(IncGCProperty + Environment.NewLine, "")); + } + else if (!alreadyEnabled && incGCEnabled) + { + _writer.WriteLine("- Enabling incremental GC"); + File.AppendAllText(bootConfigPath, IncGCProperty + Environment.NewLine); + } + } + private List GetPatchedInstructions(List instructions) => instructions.Where(x => x.Operand != null && x.Operand.ToString().Contains(nameof(ModLoader.ModLoader))).ToList();