From a4fbb7e0ddfee8253487e2cd3c5819bce9a265fb Mon Sep 17 00:00:00 2001 From: Kurt Date: Tue, 27 Dec 2016 15:05:06 -0800 Subject: [PATCH] Fix header interaction on savefile clone Probably should refactor this so all saves are handled the same way (header & footer checks) Closes #496 --- PKHeX/Saves/SAV3Colosseum.cs | 7 ++++++- PKHeX/Saves/SAV3RSBox.cs | 7 ++++++- PKHeX/Saves/SAV3XD.cs | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/PKHeX/Saves/SAV3Colosseum.cs b/PKHeX/Saves/SAV3Colosseum.cs index d9ad55fa2..11a55e109 100644 --- a/PKHeX/Saves/SAV3Colosseum.cs +++ b/PKHeX/Saves/SAV3Colosseum.cs @@ -115,7 +115,12 @@ namespace PKHeX } // Configuration - public override SaveFile Clone() { return new SAV3Colosseum(Write(DSV: false)); } + public override SaveFile Clone() + { + byte[] data = Write(DSV: false).Skip(Header.Length).ToArray(); + var sav = new SAV3Colosseum(data) { Header = (byte[])Header.Clone() }; + return sav; + } public override int SIZE_STORED => PKX.SIZE_3CSTORED; public override int SIZE_PARTY => PKX.SIZE_3CSTORED; // unused diff --git a/PKHeX/Saves/SAV3RSBox.cs b/PKHeX/Saves/SAV3RSBox.cs index 95d5cc8dc..b3237029e 100644 --- a/PKHeX/Saves/SAV3RSBox.cs +++ b/PKHeX/Saves/SAV3RSBox.cs @@ -67,7 +67,12 @@ namespace PKHeX } // Configuration - public override SaveFile Clone() { return new SAV3(Write(DSV: false), Version); } + public override SaveFile Clone() + { + byte[] data = Write(DSV: false).Skip(Header.Length).ToArray(); + var sav = new SAV3RSBox(data) {Header = (byte[]) Header.Clone()}; + return sav; + } public override int SIZE_STORED => PKX.SIZE_3STORED + 4; public override int SIZE_PARTY => PKX.SIZE_3PARTY; // unused diff --git a/PKHeX/Saves/SAV3XD.cs b/PKHeX/Saves/SAV3XD.cs index 5768c5385..330af4e03 100644 --- a/PKHeX/Saves/SAV3XD.cs +++ b/PKHeX/Saves/SAV3XD.cs @@ -128,7 +128,12 @@ namespace PKHeX } // Configuration - public override SaveFile Clone() { return new SAV3XD(Write(DSV: false)); } + public override SaveFile Clone() + { + byte[] data = Write(DSV: false).Skip(Header.Length).ToArray(); + var sav = new SAV3XD(data) {Header = (byte[]) Header.Clone()}; + return sav; + } public override int SIZE_STORED => PKX.SIZE_3XSTORED; public override int SIZE_PARTY => PKX.SIZE_3XSTORED; // unused