Skip to content

Commit

Permalink
Merge pull request #512 from ow-mods/dev
Browse files Browse the repository at this point in the history
2.7.5
  • Loading branch information
misternebula authored Nov 18, 2022
2 parents 352e7a1 + f0446fb commit 3ef0fb7
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/OWML.Common/Interfaces/IOwmlConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public interface IOwmlConfig

bool ForceExe { get; set; }

bool IncrementalGC { get; set; }

int SocketPort { get; set; }
}
}
3 changes: 3 additions & 0 deletions src/OWML.Common/OwmlConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));

Expand Down
1 change: 1 addition & 0 deletions src/OWML.Launcher/OWML.DefaultConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"gamePath": "C:/Program Files (x86)/Steam/steamapps/common/Outer Wilds",
"debugMode": false,
"forceExe": false,
"incrementalGC": false,
"socketPort": 0
}
4 changes: 2 additions & 2 deletions src/OWML.Launcher/OWML.Manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
6 changes: 3 additions & 3 deletions src/OWML.Launcher/game-versions.json
Original file line number Diff line number Diff line change
@@ -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"
}
25 changes: 25 additions & 0 deletions src/OWML.Patcher/OWPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -27,6 +28,7 @@ public void PatchGame()
CopyOWMLFiles();
CopyLibFiles();
PatchAssembly();
UpdateIncrementalGC();
}

private void CopyOWMLFiles()
Expand Down Expand Up @@ -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<Instruction> GetPatchedInstructions(List<Instruction> instructions) =>
instructions.Where(x => x.Operand != null && x.Operand.ToString().Contains(nameof(ModLoader.ModLoader))).ToList();

Expand Down

0 comments on commit 3ef0fb7

Please sign in to comment.