XMLGame: fix reboot core in the case of hawkfile embedded assets

This commit is contained in:
goyuken 2013-04-27 17:43:15 +00:00
parent 086c8bcad2
commit b0cbe204a9
2 changed files with 18 additions and 1 deletions

View File

@ -84,6 +84,13 @@ namespace BizHawk.MultiClient
/// </summary>
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;
}
/// <summary>

View File

@ -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
{