diff --git a/NHSE.Core/Save/Meta/HorizonSave.cs b/NHSE.Core/Save/Meta/HorizonSave.cs index 50492e3..b503252 100644 --- a/NHSE.Core/Save/Meta/HorizonSave.cs +++ b/NHSE.Core/Save/Meta/HorizonSave.cs @@ -57,5 +57,27 @@ public void ChangeIdentity(byte[] original, byte[] updated) foreach (var pair in Players.SelectMany(z => z)) pair.Data.ReplaceOccurrences(original, updated); } + + public bool ValidateSizes() + { + var info = Main.Info.GetKnownRevisionIndex(); + if (info < 0) + return false; + var sizes = RevisionChecker.SizeInfo[info]; + if (Main.Data.Length != sizes.Main) + return false; + foreach (var p in Players) + { + if (p.Personal.Data.Length != sizes.Personal) + return false; + if (p.Photo.Data.Length != sizes.PhotoStudioIsland) + return false; + if (p.PostBox.Data.Length != sizes.PostBox) + return false; + if (p.Profile.Data.Length != sizes.Profile) + return false; + } + return true; + } } } diff --git a/NHSE.WinForms/Main.cs b/NHSE.WinForms/Main.cs index bb70397..d3944a9 100644 --- a/NHSE.WinForms/Main.cs +++ b/NHSE.WinForms/Main.cs @@ -27,7 +27,18 @@ public Main() Open(args[i]); } - private static void Open(HorizonSave file) => new Editor(file).Show(); + private static void Open(HorizonSave file) + { + bool sized = file.ValidateSizes(); + if (!sized) + { + const string sizeBad = "Save file sizes appear to be incorrect."; + if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, sizeBad, "Continue?") != DialogResult.Yes) + return; + } + + new Editor(file).Show(); + } private void Main_DragEnter(object sender, DragEventArgs e) {