mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-27 06:20:25 +00:00
Fix memcard sav cloning
Closes #2267 , Thanks @PMArkive && @Subject21J !
This commit is contained in:
parent
bd00680545
commit
0d5ee9489b
3 changed files with 60 additions and 25 deletions
|
@ -109,6 +109,18 @@ namespace PKHeX.Core
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override byte[] GetFinalData()
|
protected override byte[] GetFinalData()
|
||||||
|
{
|
||||||
|
var newFile = GetInnerData();
|
||||||
|
|
||||||
|
// Return the gci if Memory Card is not being exported
|
||||||
|
if (!IsMemoryCardSave)
|
||||||
|
return newFile;
|
||||||
|
|
||||||
|
MC.SelectedSaveData = newFile;
|
||||||
|
return MC.Data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private byte[] GetInnerData()
|
||||||
{
|
{
|
||||||
StrategyMemo.FinalData.CopyTo(Data, Memo);
|
StrategyMemo.FinalData.CopyTo(Data, Memo);
|
||||||
SetChecksums();
|
SetChecksums();
|
||||||
|
@ -120,17 +132,17 @@ namespace PKHeX.Core
|
||||||
// Put save slot back in original save data
|
// Put save slot back in original save data
|
||||||
byte[] newFile = MC != null ? MC.SelectedSaveData : (byte[])BAK.Clone();
|
byte[] newFile = MC != null ? MC.SelectedSaveData : (byte[])BAK.Clone();
|
||||||
Array.Copy(newSAV, 0, newFile, SLOT_START + (SaveIndex * SLOT_SIZE), newSAV.Length);
|
Array.Copy(newSAV, 0, newFile, SLOT_START + (SaveIndex * SLOT_SIZE), newSAV.Length);
|
||||||
|
|
||||||
// Return the gci if Memory Card is not being exported
|
|
||||||
if (!IsMemoryCardSave)
|
|
||||||
return newFile;
|
return newFile;
|
||||||
|
|
||||||
MC.SelectedSaveData = newFile;
|
|
||||||
return MC.Data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configuration
|
// Configuration
|
||||||
public override SaveFile Clone() => new SAV3Colosseum(Write()) {Header = (byte[]) Header.Clone()};
|
public override SaveFile Clone()
|
||||||
|
{
|
||||||
|
var data = GetInnerData();
|
||||||
|
var sav = IsMemoryCardSave ? new SAV3Colosseum(data, MC) : new SAV3Colosseum(data);
|
||||||
|
sav.Header = (byte[])Header.Clone();
|
||||||
|
return sav;
|
||||||
|
}
|
||||||
|
|
||||||
public override int SIZE_STORED => PKX.SIZE_3CSTORED;
|
public override int SIZE_STORED => PKX.SIZE_3CSTORED;
|
||||||
protected override int SIZE_PARTY => PKX.SIZE_3CSTORED; // unused
|
protected override int SIZE_PARTY => PKX.SIZE_3CSTORED; // unused
|
||||||
|
|
|
@ -62,14 +62,7 @@ namespace PKHeX.Core
|
||||||
|
|
||||||
protected override byte[] GetFinalData()
|
protected override byte[] GetFinalData()
|
||||||
{
|
{
|
||||||
// Copy Box data back
|
var newFile = GetInnerData();
|
||||||
const int copySize = BLOCK_SIZE - 0x10;
|
|
||||||
foreach (var b in Blocks)
|
|
||||||
Array.Copy(Data, (int)(Box + (b.ID * copySize)), Data, b.Offset + 0xC, copySize);
|
|
||||||
|
|
||||||
SetChecksums();
|
|
||||||
|
|
||||||
byte[] newFile = GetData(0, Data.Length - SIZE_RESERVED);
|
|
||||||
|
|
||||||
// Return the gci if Memory Card is not being exported
|
// Return the gci if Memory Card is not being exported
|
||||||
if (!IsMemoryCardSave)
|
if (!IsMemoryCardSave)
|
||||||
|
@ -79,8 +72,26 @@ namespace PKHeX.Core
|
||||||
return MC.Data;
|
return MC.Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private byte[] GetInnerData()
|
||||||
|
{
|
||||||
|
// Copy Box data back
|
||||||
|
const int copySize = BLOCK_SIZE - 0x10;
|
||||||
|
foreach (var b in Blocks)
|
||||||
|
Array.Copy(Data, (int) (Box + (b.ID * copySize)), Data, b.Offset + 0xC, copySize);
|
||||||
|
|
||||||
|
SetChecksums();
|
||||||
|
|
||||||
|
return GetData(0, Data.Length - SIZE_RESERVED);
|
||||||
|
}
|
||||||
|
|
||||||
// Configuration
|
// Configuration
|
||||||
public override SaveFile Clone() => new SAV3RSBox(Write()) {Header = (byte[]) Header.Clone()};
|
public override SaveFile Clone()
|
||||||
|
{
|
||||||
|
var data = GetInnerData();
|
||||||
|
var sav = IsMemoryCardSave ? new SAV3RSBox(data, MC) : new SAV3RSBox(data);
|
||||||
|
sav.Header = (byte[])Header.Clone();
|
||||||
|
return sav;
|
||||||
|
}
|
||||||
|
|
||||||
public override int SIZE_STORED => PKX.SIZE_3STORED + 4;
|
public override int SIZE_STORED => PKX.SIZE_3STORED + 4;
|
||||||
protected override int SIZE_PARTY => PKX.SIZE_3PARTY; // unused
|
protected override int SIZE_PARTY => PKX.SIZE_3PARTY; // unused
|
||||||
|
|
|
@ -115,6 +115,18 @@ namespace PKHeX.Core
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override byte[] GetFinalData()
|
protected override byte[] GetFinalData()
|
||||||
|
{
|
||||||
|
var newFile = GetInnerData();
|
||||||
|
|
||||||
|
// Return the gci if Memory Card is not being exported
|
||||||
|
if (!IsMemoryCardSave)
|
||||||
|
return newFile;
|
||||||
|
|
||||||
|
MC.SelectedSaveData = newFile;
|
||||||
|
return MC.Data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private byte[] GetInnerData()
|
||||||
{
|
{
|
||||||
// Set Memo Back
|
// Set Memo Back
|
||||||
StrategyMemo.FinalData.CopyTo(Data, Memo);
|
StrategyMemo.FinalData.CopyTo(Data, Memo);
|
||||||
|
@ -130,17 +142,17 @@ namespace PKHeX.Core
|
||||||
// Put save slot back in original save data
|
// Put save slot back in original save data
|
||||||
byte[] newFile = MC != null ? MC.SelectedSaveData : (byte[])BAK.Clone();
|
byte[] newFile = MC != null ? MC.SelectedSaveData : (byte[])BAK.Clone();
|
||||||
Array.Copy(newSAV, 0, newFile, SLOT_START + (SaveIndex * SLOT_SIZE), newSAV.Length);
|
Array.Copy(newSAV, 0, newFile, SLOT_START + (SaveIndex * SLOT_SIZE), newSAV.Length);
|
||||||
|
|
||||||
// Return the gci if Memory Card is not being exported
|
|
||||||
if (!IsMemoryCardSave)
|
|
||||||
return newFile;
|
return newFile;
|
||||||
|
|
||||||
MC.SelectedSaveData = newFile;
|
|
||||||
return MC.Data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configuration
|
// Configuration
|
||||||
public override SaveFile Clone() => new SAV3XD(Write()) {Header = (byte[]) Header.Clone()};
|
public override SaveFile Clone()
|
||||||
|
{
|
||||||
|
var data = GetInnerData();
|
||||||
|
var sav = IsMemoryCardSave ? new SAV3XD(data, MC) : new SAV3XD(data);
|
||||||
|
sav.Header = (byte[]) Header.Clone();
|
||||||
|
return sav;
|
||||||
|
}
|
||||||
|
|
||||||
public override int SIZE_STORED => PKX.SIZE_3XSTORED;
|
public override int SIZE_STORED => PKX.SIZE_3XSTORED;
|
||||||
protected override int SIZE_PARTY => PKX.SIZE_3XSTORED; // unused
|
protected override int SIZE_PARTY => PKX.SIZE_3XSTORED; // unused
|
||||||
|
|
Loading…
Reference in a new issue