Skip to content

Commit

Permalink
hack to fix globalgamemanagers for 1.0.5 (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
amazingalek authored Feb 5, 2020
1 parent 2468d6d commit 0dcf243
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion OWML.Patcher/VrPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private void PatchGlobalManager(bool enableVR)
return;
}

if (!File.Exists(backupPath))
if (!File.Exists(backupPath) || !OriginalIsSameSizeAsBackupOrVrVersion(originalPath, backupPath, vrPath))
{
_writer.WriteLine("Taking backup of globalgamemanagers.");
File.Copy(originalPath, backupPath, true);
Expand All @@ -84,6 +84,19 @@ 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.ReadAllBytes(vrPath).Length;
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

0 comments on commit 0dcf243

Please sign in to comment.