From b0cbe204a92f22e18c7f68a27be899e1388355ac Mon Sep 17 00:00:00 2001 From: goyuken Date: Sat, 27 Apr 2013 17:43:15 +0000 Subject: [PATCH] XMLGame: fix reboot core in the case of hawkfile embedded assets --- BizHawk.MultiClient/HawkFile.cs | 10 +++++++++- BizHawk.MultiClient/XmlGame.cs | 9 +++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/BizHawk.MultiClient/HawkFile.cs b/BizHawk.MultiClient/HawkFile.cs index 1d68e284d4..cb865b4d76 100644 --- a/BizHawk.MultiClient/HawkFile.cs +++ b/BizHawk.MultiClient/HawkFile.cs @@ -84,6 +84,13 @@ namespace BizHawk.MultiClient /// public bool IsArchive { get { return extractor != null; } } + int? BoundIndex = null; + + public int? GetBoundIndex() + { + return BoundIndex; + } + public class ArchiveItem { @@ -246,7 +253,7 @@ namespace BizHawk.MultiClient boundStream.Position = 0; memberPath = FixArchiveFilename(extractor.ArchiveFileNames[archiveIndex]); //TODO - maybe go through our own list of names? maybe not, its indexes dont match.. Console.WriteLine("HawkFile bound " + CanonicalFullPath); - + BoundIndex = archiveIndex; return this; } @@ -258,6 +265,7 @@ namespace BizHawk.MultiClient if (boundStream != null && boundStream != rootStream) boundStream.Close(); boundStream = null; memberPath = null; + BoundIndex = null; } /// diff --git a/BizHawk.MultiClient/XmlGame.cs b/BizHawk.MultiClient/XmlGame.cs index f9377884c5..d274cb9fd8 100644 --- a/BizHawk.MultiClient/XmlGame.cs +++ b/BizHawk.MultiClient/XmlGame.cs @@ -34,6 +34,8 @@ namespace BizHawk.MultiClient { MemoryStream HashStream = new MemoryStream(); + int? OriginalIndex = null; + foreach (XmlNode a in n.ChildNodes) { string name = a.Name; @@ -45,6 +47,8 @@ namespace BizHawk.MultiClient var ai = f.FindArchiveMember(filename.Substring(1)); if (ai != null) { + if (OriginalIndex == null) + OriginalIndex = f.GetBoundIndex(); f.Unbind(); f.BindArchiveMember(ai); data = Util.ReadAllBytes(f.GetStream()); @@ -78,6 +82,11 @@ namespace BizHawk.MultiClient } ret.GI.Hash = Util.Hash_SHA1(HashStream.GetBuffer(), 0, (int)HashStream.Length); HashStream.Close(); + if (OriginalIndex != null) + { + f.Unbind(); + f.BindArchiveMember((int)OriginalIndex); + } } else {