mirror of
https://github.com/kwsch/NHSE.git
synced 2026-08-28 05:44:40 -05:00
Verify sizes on load
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user