mirror of
https://github.com/kwsch/PKHeX
synced 2024-09-20 14:21:59 +00:00
parent
5bcccc6d92
commit
cd8797da30
6 changed files with 12 additions and 7 deletions
|
@ -12,7 +12,7 @@ public sealed class GameDataPA8 : IGameDataSide, IScaledSizeAbsolute
|
|||
private const int SIZE = HomeCrypto.SIZE_1GAME_PA8;
|
||||
private const HomeGameDataFormat Format = HomeGameDataFormat.PA8;
|
||||
|
||||
public GameDataPA8 Clone() => new(Data.AsSpan(Offset, SIZE).ToArray());
|
||||
public GameDataPA8 Clone() => new(Data.AsSpan(Offset - 3, SIZE).ToArray());
|
||||
|
||||
public GameDataPA8()
|
||||
{
|
||||
|
|
|
@ -12,7 +12,7 @@ public sealed class GameDataPB7 : IGameDataSide, IScaledSizeAbsolute, IMemoryOT
|
|||
private const int SIZE = HomeCrypto.SIZE_1GAME_PB7;
|
||||
private const HomeGameDataFormat Format = HomeGameDataFormat.PB7;
|
||||
|
||||
public GameDataPB7 Clone() => new(Data.AsSpan(Offset, SIZE).ToArray());
|
||||
public GameDataPB7 Clone() => new(Data.AsSpan(Offset - 3, SIZE).ToArray());
|
||||
|
||||
public GameDataPB7()
|
||||
{
|
||||
|
|
|
@ -12,7 +12,7 @@ public sealed class GameDataPB8 : IGameDataSide
|
|||
private const int SIZE = HomeCrypto.SIZE_1GAME_PB8;
|
||||
private const HomeGameDataFormat Format = HomeGameDataFormat.PB8;
|
||||
|
||||
public GameDataPB8 Clone() => new(Data.AsSpan(Offset, SIZE).ToArray());
|
||||
public GameDataPB8 Clone() => new(Data.AsSpan(Offset - 3, SIZE).ToArray());
|
||||
|
||||
public GameDataPB8()
|
||||
{
|
||||
|
|
|
@ -12,7 +12,7 @@ public sealed class GameDataPK8 : IGameDataSide, IGigantamax, IDynamaxLevel, ISo
|
|||
private const int SIZE = HomeCrypto.SIZE_1GAME_PK8;
|
||||
private const HomeGameDataFormat Format = HomeGameDataFormat.PK8;
|
||||
|
||||
public GameDataPK8 Clone() => new(Data.AsSpan(Offset, SIZE).ToArray());
|
||||
public GameDataPK8 Clone() => new(Data.AsSpan(Offset - 3, SIZE).ToArray());
|
||||
|
||||
public GameDataPK8()
|
||||
{
|
||||
|
|
|
@ -119,12 +119,12 @@ public static class HomeCrypto
|
|||
if (ReadUInt16LittleEndian(data[SIZE_1HEADER..]) != SIZE_1CORE)
|
||||
return true; // Core length should be constant if decrypted.
|
||||
|
||||
var core = data.Slice(SIZE_1HEADER + 4, SIZE_1CORE);
|
||||
if (ReadUInt16LittleEndian(core[0x9D..]) != 0)
|
||||
var core = data.Slice(SIZE_1HEADER + 2, SIZE_1CORE);
|
||||
if (ReadUInt16LittleEndian(core[0xB5..]) != 0)
|
||||
return true; // OT_Name final terminator should be 0 if decrypted.
|
||||
if (ReadUInt16LittleEndian(core[0x60..]) != 0)
|
||||
return true; // Nickname final terminator should be 0 if decrypted.
|
||||
if (ReadUInt16LittleEndian(core[0x70..]) != 0)
|
||||
if (ReadUInt16LittleEndian(core[0x88..]) != 0)
|
||||
return true; // HT_Name final terminator should be 0 if decrypted.
|
||||
|
||||
//// Fall back to checksum.
|
||||
|
|
|
@ -41,6 +41,11 @@ public static class HomeTests
|
|||
for (int i = 0; i < decrypted.Length; i++)
|
||||
decrypted[i].Should().Be(ph1.Data[i]);
|
||||
|
||||
bool check = HomeCrypto.GetIsEncrypted1(decrypted);
|
||||
check.Should().BeFalse();
|
||||
|
||||
ph1.Clone().Should().NotBeNull();
|
||||
|
||||
var write = ph1.Rebuild();
|
||||
write.Length.Should().Be(decrypted.Length);
|
||||
for (int i = 0; i < decrypted.Length; i++)
|
||||
|
|
Loading…
Reference in a new issue