Skip to content

Commit

Permalink
patches for multiple versions (#70)
Browse files Browse the repository at this point in the history
VR support for 1.0.5
Co-authored-by: Ricardo Lopes <[email protected]>
  • Loading branch information
amazingalek authored Feb 9, 2020
1 parent ad51e58 commit 2a60362
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 26 deletions.
Binary file not shown.
File renamed without changes.
32 changes: 9 additions & 23 deletions OWML.Patcher/VrPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ namespace OWML.Patcher
{
public class VRPatcher
{
private const string TargetChecksum = "d3979abb3b0d2468c3e03e2ee862d5297f5885bd9fc8f3b16cb16805e010d097";

private readonly IOwmlConfig _owmlConfig;
private readonly IModConsole _writer;
private readonly SHA256 _sha;
Expand Down Expand Up @@ -49,17 +47,18 @@ private void CopyFiles()
private void PatchGlobalManager(bool enableVR)
{
var originalPath = _owmlConfig.DataPath + "/globalgamemanagers";
var backupPath = _owmlConfig.DataPath + "/globalgamemanagers.bak";
var vrPath = _owmlConfig.DataPath + "/globalgamemanagers.vr";
var patchPath = _owmlConfig.OWMLPath + "VR/patch";

if (!File.Exists(originalPath))
{
_writer.WriteLine("Error: can't find " + originalPath);
return;
}

if (!File.Exists(backupPath) || !OriginalIsSameSizeAsBackupOrVrVersion(originalPath, backupPath, vrPath))
var checksum = CalculateChecksum(originalPath);
var backupPath = $"{_owmlConfig.DataPath}/globalgamemanagers.{checksum}.bak";
var vrPath = $"{_owmlConfig.DataPath}/globalgamemanagers.{checksum}.vr";


if (!File.Exists(backupPath))
{
_writer.WriteLine("Taking backup of globalgamemanagers.");
File.Copy(originalPath, backupPath, true);
Expand All @@ -68,14 +67,14 @@ private void PatchGlobalManager(bool enableVR)
if (enableVR && !File.Exists(vrPath))
{
_writer.WriteLine("Patching globalgamemanagers for VR...");
var checksum = CalculateChecksum(originalPath);
if (checksum == TargetChecksum)
var patchPath = $"{_owmlConfig.OWMLPath}VR/{checksum}";
if (File.Exists(patchPath))
{
ApplyPatch(originalPath, vrPath, patchPath);
}
else
{
_writer.WriteLine($"Error: invalid checksum: {checksum}. Only Outer Wilds v1.0.4 is supported.");
_writer.WriteLine($"Error: invalid checksum: {checksum}. VR patch for this version of Outer Wilds is not yet supported by OWML.");
return;
}
}
Expand All @@ -84,19 +83,6 @@ private void PatchGlobalManager(bool enableVR)
File.Copy(copyFrom, originalPath, true);
}

private bool OriginalIsSameSizeAsBackupOrVrVersion(string originalPath, string backupPath, string vrPath)
{
var originalSize = File.ReadAllBytes(originalPath).Length;
var backupSize = File.ReadAllBytes(backupPath).Length;
var vrSize = File.Exists(vrPath) ? File.ReadAllBytes(vrPath).Length : 0;
var isSameSize = originalSize == backupSize || originalSize == vrSize;
if (!isSameSize)
{
_writer.WriteLine("Looks like new game version!");
}
return isSameSize;
}

private string CalculateChecksum(string filePath)
{
var bytes = File.ReadAllBytes(filePath);
Expand Down
4 changes: 1 addition & 3 deletions createrelease.bat
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ copy "OWML.Launcher\bin\Debug\OWML.Launcher.exe" "Release\OWML.Launcher.exe"
copy "OWML.Launcher\bin\Debug\OWML.Config.json" "Release\OWML.Config.json"
copy "OWML.Patcher\dnpatch\dnpatch.dll" "Release\dnpatch.dll"
copy "OWML.Patcher\dnpatch\dnlib.dll" "Release\dnlib.dll"
copy "OWML.Patcher\VR\openvr_api.dll" "Release\VR\openvr_api.dll"
copy "OWML.Patcher\VR\OVRPlugin.dll" "Release\VR\OVRPlugin.dll"
copy "OWML.Patcher\VR\patch" "Release\VR\patch"
copy "OWML.Patcher\VR\*" "Release\VR\"
copy "OWML.Patcher\VR\BsPatch.dll" "Release\BsPatch.dll"
copy "OWML.Patcher\VR\ICSharpCode.SharpZipLib.dll" "Release\ICSharpCode.SharpZipLib.dll"
copy "OWML.Launcher\bin\Debug\System.Runtime.Serialization.dll" "Release\System.Runtime.Serialization.dll"
Expand Down

0 comments on commit 2a60362

Please sign in to comment.