mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-09-11 03:28:07 -05:00
Fix memcard sav cloning
Closes #2267 , Thanks @PMArkive && @Subject21J !
This commit is contained in:
@@ -109,6 +109,18 @@ private void InitializeData()
|
||||
}
|
||||
|
||||
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);
|
||||
SetChecksums();
|
||||
@@ -120,17 +132,17 @@ protected override byte[] GetFinalData()
|
||||
// Put save slot back in original save data
|
||||
byte[] newFile = MC != null ? MC.SelectedSaveData : (byte[])BAK.Clone();
|
||||
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;
|
||||
|
||||
MC.SelectedSaveData = newFile;
|
||||
return MC.Data;
|
||||
return newFile;
|
||||
}
|
||||
|
||||
// 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;
|
||||
protected override int SIZE_PARTY => PKX.SIZE_3CSTORED; // unused
|
||||
|
||||
@@ -62,14 +62,7 @@ public SAV3RSBox(byte[] data = null)
|
||||
|
||||
protected override byte[] GetFinalData()
|
||||
{
|
||||
// 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();
|
||||
|
||||
byte[] newFile = GetData(0, Data.Length - SIZE_RESERVED);
|
||||
var newFile = GetInnerData();
|
||||
|
||||
// Return the gci if Memory Card is not being exported
|
||||
if (!IsMemoryCardSave)
|
||||
@@ -79,8 +72,26 @@ protected override byte[] GetFinalData()
|
||||
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
|
||||
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;
|
||||
protected override int SIZE_PARTY => PKX.SIZE_3PARTY; // unused
|
||||
|
||||
@@ -115,6 +115,18 @@ public SAV3XD(byte[] data = null)
|
||||
}
|
||||
|
||||
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
|
||||
StrategyMemo.FinalData.CopyTo(Data, Memo);
|
||||
@@ -130,17 +142,17 @@ protected override byte[] GetFinalData()
|
||||
// Put save slot back in original save data
|
||||
byte[] newFile = MC != null ? MC.SelectedSaveData : (byte[])BAK.Clone();
|
||||
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;
|
||||
|
||||
MC.SelectedSaveData = newFile;
|
||||
return MC.Data;
|
||||
return newFile;
|
||||
}
|
||||
|
||||
// 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;
|
||||
protected override int SIZE_PARTY => PKX.SIZE_3XSTORED; // unused
|
||||
|
||||
Reference in New Issue
Block a user