mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-10 06:34:19 +00:00
Crystal (International) Checksum 2 Fix (#3939)
* Correct invalid OverallChecksumPosition2 offset for International Crystal * Update SAV2 Checksum validation to check against both Checksum values
This commit is contained in:
parent
2ea6ee4e10
commit
b340e2327a
2 changed files with 11 additions and 6 deletions
|
@ -308,18 +308,23 @@ public sealed class SAV2 : SaveFile, ILangDeviantSave, IEventFlagArray, IEventWo
|
|||
WriteUInt16LittleEndian(Data.AsSpan(Offsets.OverallChecksumPosition2), accum);
|
||||
}
|
||||
|
||||
public override bool ChecksumsValid
|
||||
public override bool ChecksumsValid => !ChecksumInfo.Contains("Invalid");
|
||||
|
||||
public override string ChecksumInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
ushort accum = GetChecksum();
|
||||
ushort actual = ReadUInt16LittleEndian(Data.AsSpan(Offsets.OverallChecksumPosition));
|
||||
return accum == actual;
|
||||
ushort actual2 = ReadUInt16LittleEndian(Data.AsSpan(Offsets.OverallChecksumPosition2));
|
||||
|
||||
bool checksum1Valid = (accum == actual);
|
||||
bool checksum2Valid = (accum == actual2);
|
||||
static string valid(bool s) => s ? "Valid" : "Invalid";
|
||||
return $"Checksum 1 {valid(checksum1Valid)}, Checksum 2 {valid(checksum2Valid)}.";
|
||||
}
|
||||
}
|
||||
|
||||
public override string ChecksumInfo => ChecksumsValid ? "Checksum valid." : "Checksum invalid";
|
||||
|
||||
// Trainer Info
|
||||
public override GameVersion Version { get; protected set; }
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
|
||||
namespace PKHeX.Core;
|
||||
|
||||
|
@ -100,7 +100,7 @@ internal sealed class SAV2Offsets
|
|||
Gender = 0x3E3D;
|
||||
AccumulatedChecksumEnd = 0x2B82;
|
||||
OverallChecksumPosition = 0x2D0D;
|
||||
OverallChecksumPosition2 = 0x7F0D;
|
||||
OverallChecksumPosition2 = 0x1F0D;
|
||||
|
||||
PouchTMHM = 0x23E7;
|
||||
PouchItem = 0x2420;
|
||||
|
|
Loading…
Reference in a new issue