Read correct duplex data

This commit is contained in:
Alex Barney 2018-07-24 18:50:41 -05:00
parent a6a9392047
commit 46cfb2f948
3 changed files with 8 additions and 7 deletions

View file

@ -245,7 +245,7 @@ namespace hactoolnet
File.WriteAllBytes(Path.Combine(dir, "L1_4_Layer1Hash"), save.JournalLayer1Hash);
File.WriteAllBytes(Path.Combine(dir, "L1_5_Layer2Hash"), save.JournalLayer2Hash);
File.WriteAllBytes(Path.Combine(dir, "L1_6_Layer3Hash"), save.JournalLayer3Hash);
File.WriteAllBytes(Path.Combine(dir, "L1_7_FAT"), save.JournalStuff);
File.WriteAllBytes(Path.Combine(dir, "L1_7_FAT"), save.JournalFat);
save.JournalStream.Position = 0;
using (var outFile = new FileStream(Path.Combine(dir, "L2_0_SaveData"), FileMode.Create, FileAccess.Write))

View file

@ -111,7 +111,7 @@ namespace libhac.Savefile
public long Layer3HashSize { get; set; }
public long Field148 { get; set; }
public long Field150 { get; set; }
public long Field158 { get; set; }
public long DuplexIndex { get; set; }
public FsLayout(BinaryReader reader)
{
@ -156,7 +156,7 @@ namespace libhac.Savefile
Layer3HashSize = reader.ReadInt64();
Field148 = reader.ReadInt64();
Field150 = reader.ReadInt64();
Field158 = reader.ReadInt64();
DuplexIndex = reader.ReadInt64();
}
}

View file

@ -26,7 +26,7 @@ namespace libhac.Savefile
public byte[] JournalLayer1Hash { get; }
public byte[] JournalLayer2Hash { get; }
public byte[] JournalLayer3Hash { get; }
public byte[] JournalStuff { get; }
public byte[] JournalFat { get; }
public FileEntry[] Files { get; private set; }
private Dictionary<string, FileEntry> FileDict { get; }
@ -56,7 +56,8 @@ namespace libhac.Savefile
FileRemap.Position = layout.DuplexDataOffsetB;
FileRemap.Read(DuplexDataB, 0, DuplexDataB.Length);
var duplexData = new SubStream(FileRemap, layout.DuplexDataOffsetB, layout.DuplexDataSize);
var duplexDataOffset = layout.DuplexIndex == 0 ? layout.DuplexDataOffsetA : layout.DuplexDataOffsetB;
var duplexData = new SubStream(FileRemap, duplexDataOffset, layout.DuplexDataSize);
MetaRemap = new RemapStream(duplexData, Header.MetaMapEntries, Header.MetaRemap.MapSegmentCount);
JournalTable = new byte[layout.JournalTableSize];
@ -66,7 +67,7 @@ namespace libhac.Savefile
JournalLayer1Hash = new byte[layout.Layer1HashSize];
JournalLayer2Hash = new byte[layout.Layer2HashSize];
JournalLayer3Hash = new byte[layout.Layer3HashSize];
JournalStuff = new byte[layout.Field150];
JournalFat = new byte[layout.Field150];
MetaRemap.Position = layout.JournalTableOffset;
MetaRemap.Read(JournalTable, 0, JournalTable.Length);
@ -83,7 +84,7 @@ namespace libhac.Savefile
MetaRemap.Position = layout.Layer3HashOffset;
MetaRemap.Read(JournalLayer3Hash, 0, JournalLayer3Hash.Length);
MetaRemap.Position = layout.Field148;
MetaRemap.Read(JournalStuff, 0, JournalStuff.Length);
MetaRemap.Read(JournalFat, 0, JournalFat.Length);
var journalMap = JournalStream.ReadMappingEntries(JournalTable, JournalBitmapUpdatedPhysical,
JournalBitmapUpdatedVirtual, JournalBitmapUnassigned, Header.Journal.MappingEntryCount);