From 1db95efa728cf125780b0885aa6876060172a156 Mon Sep 17 00:00:00 2001 From: nattthebear Date: Tue, 6 Jun 2017 20:05:30 -0400 Subject: [PATCH] Change the exception message for certain waterbox loadstate failures to indicate possible differences in app version / rom / syncsettings as the culprit --- BizHawk.Emulation.Cores/Waterbox/Heap.cs | 5 +++-- BizHawk.Emulation.Cores/Waterbox/PeWrapper.cs | 13 ++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/BizHawk.Emulation.Cores/Waterbox/Heap.cs b/BizHawk.Emulation.Cores/Waterbox/Heap.cs index 13d870a28e..1c5a876621 100644 --- a/BizHawk.Emulation.Cores/Waterbox/Heap.cs +++ b/BizHawk.Emulation.Cores/Waterbox/Heap.cs @@ -103,6 +103,7 @@ namespace BizHawk.Emulation.Cores.Waterbox { var name = br.ReadString(); if (name != Name) + // probable cause: internal error throw new InvalidOperationException(string.Format("Name did not match for heap {0}", Name)); var used = br.ReadUInt64(); if (used > Memory.Size) @@ -112,7 +113,7 @@ namespace BizHawk.Emulation.Cores.Waterbox var hash = br.ReadBytes(Memory.XorHash.Length); if (!hash.SequenceEqual(Memory.XorHash)) { - throw new InvalidOperationException(string.Format("Hash did not match for heap {0}. Is this the same rom?", Name)); + throw new InvalidOperationException(string.Format("Hash did not match for heap {0}. Is this the same rom with the same SyncSettings?", Name)); } Memory.Protect(Memory.Start, Memory.Size, MemoryBlock.Protection.None); @@ -126,7 +127,7 @@ namespace BizHawk.Emulation.Cores.Waterbox var hash = br.ReadBytes(_hash.Length); if (!hash.SequenceEqual(_hash)) { - throw new InvalidOperationException(string.Format("Hash did not match for heap {0}. Is this the same rom?", Name)); + throw new InvalidOperationException(string.Format("Hash did not match for heap {0}. Is this the same rom with the same SyncSettings?", Name)); } } } diff --git a/BizHawk.Emulation.Cores/Waterbox/PeWrapper.cs b/BizHawk.Emulation.Cores/Waterbox/PeWrapper.cs index f91960f482..5968b4582d 100644 --- a/BizHawk.Emulation.Cores/Waterbox/PeWrapper.cs +++ b/BizHawk.Emulation.Cores/Waterbox/PeWrapper.cs @@ -394,15 +394,22 @@ namespace BizHawk.Emulation.Cores.Waterbox public void LoadStateBinary(BinaryReader br) { if (!_importsSealed) + // operations happening in the wrong order. probable cause: internal logic error. make sure frontend calls Seal throw new InvalidOperationException(".idata sections must be closed before loading state"); if (br.ReadUInt64() != MAGIC) - throw new InvalidOperationException("Magic not magic enough!"); + // file id is missing. probable cause: garbage savestate + throw new InvalidOperationException("Savestate corrupted!"); if (!br.ReadBytes(_fileHash.Length).SequenceEqual(_fileHash)) - throw new InvalidOperationException("Elf changed disguise!"); + // the .dll file that is loaded now has a different hash than the .dll that created the savestate + throw new InvalidOperationException("Core consistency check failed. Is this a savestate from a different version?"); if (!br.ReadBytes(Memory.XorHash.Length).SequenceEqual(Memory.XorHash)) - throw new InvalidOperationException("Elf is super slippery!"); + // the post-Seal memory state is different. probable cause: different rom or different version of rom, + // different syncsettings + throw new InvalidOperationException("Memory consistency check failed. Is this savestate from different SyncSettings?"); if (br.ReadUInt64() != Start) + // dll loaded somewhere else. probable cause: internal logic error. + // unlikely to get this far if the previous checks pssed throw new InvalidOperationException("Trickys elves moved on you!"); Memory.Protect(Memory.Start, Memory.Size, MemoryBlock.Protection.RW);