diff --git a/OWML.Patcher/VrPatcher.cs b/OWML.Patcher/VrPatcher.cs index f24b365e0..edb554108 100644 --- a/OWML.Patcher/VrPatcher.cs +++ b/OWML.Patcher/VrPatcher.cs @@ -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); @@ -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);