diff --git a/Saves/SAV3.cs b/Saves/SAV3.cs index 25af3a2e77c..1dfd3f71944 100644 --- a/Saves/SAV3.cs +++ b/Saves/SAV3.cs @@ -57,7 +57,7 @@ public SAV3(byte[] data = null, GameVersion versionOverride = GameVersion.Any) // Set up PC data buffer beyond end of save file. Box = Data.Length; - Array.Resize(ref Data, Data.Length + 0x10000); // More than enough empty space. + Array.Resize(ref Data, Data.Length + SIZE_RESERVED); // More than enough empty space. // Copy chunk to the allocated location for (int i = 5; i < 14; i++) @@ -109,6 +109,22 @@ public SAV3(byte[] data = null, GameVersion versionOverride = GameVersion.Any) resetBoxes(); } + private const int SIZE_RESERVED = 0x10000; // unpacked box data + public override byte[] Write(bool DSV) + { + // Copy Box data back + for (int i = 5; i < 14; i++) + { + int blockIndex = Array.IndexOf(BlockOrder, i); + if (blockIndex == -1) // block empty + continue; + Array.Copy(Data, Box + (i - 5) * 0xF80, Data, blockIndex * 0x1000 + ABO, chunkLength[i]); + } + + setChecksums(); + return Data.Take(Data.Length - SIZE_RESERVED).ToArray(); + } + private readonly int ActiveSAV; private int ABO => ActiveSAV*0xE000; private readonly int[] BlockOrder; diff --git a/Saves/SaveFile.cs b/Saves/SaveFile.cs index 7c11b60006b..069bf2e8c40 100644 --- a/Saves/SaveFile.cs +++ b/Saves/SaveFile.cs @@ -32,7 +32,7 @@ public abstract class SaveFile public ushort[] HeldItems { get; protected set; } // General SAV Properties - public byte[] Write(bool DSV) + public virtual byte[] Write(bool DSV) { setChecksums(); if (Footer.Length > 0 && DSV)