mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-22 03:53:08 +00:00
Fix Misc7 wormhole shiny property r/w
Redirect reader to r/w the Misc block property rather than the buffer directly
This commit is contained in:
parent
ee00a21f90
commit
b187633ec6
2 changed files with 21 additions and 9 deletions
|
@ -27,6 +27,11 @@ public sealed class Misc7(SAV7 sav, Memory<byte> raw) : SaveBlock<SAV7>(sav, raw
|
|||
}
|
||||
}
|
||||
|
||||
// 0x00C: 0x100 bytes of bitflags
|
||||
// 0x10C: u32
|
||||
// 0x110: u32
|
||||
// 0x114: 8 bytes of bitflags
|
||||
|
||||
public uint BP
|
||||
{
|
||||
get => ReadUInt32LittleEndian(Data[0x11C..]);
|
||||
|
@ -38,6 +43,10 @@ public sealed class Misc7(SAV7 sav, Memory<byte> raw) : SaveBlock<SAV7>(sav, raw
|
|||
}
|
||||
}
|
||||
|
||||
// 0x120: byte
|
||||
// 0x121: byte
|
||||
// 0x122: byte
|
||||
|
||||
public int DaysFromRefreshed
|
||||
{
|
||||
get => Data[0x123];
|
||||
|
@ -50,23 +59,25 @@ public sealed class Misc7(SAV7 sav, Memory<byte> raw) : SaveBlock<SAV7>(sav, raw
|
|||
set => Data[0x130] = (byte)((Data[0x130] & ~0x1F) | (value & 0x1F));
|
||||
}
|
||||
|
||||
// 0x134: byte
|
||||
|
||||
public bool IsWormholeShiny
|
||||
{
|
||||
get => Data[0x136] == 1;
|
||||
set => Data[0x136] = (byte)(value ? 1 : 0);
|
||||
get => Data[0x135] == 1;
|
||||
set => Data[0x135] = (byte)(value ? 1 : 0);
|
||||
}
|
||||
|
||||
// 0x136-0x137: alignment
|
||||
|
||||
public int GetSurfScore(int recordID)
|
||||
{
|
||||
if ((uint)recordID >= 4)
|
||||
recordID = 0;
|
||||
ArgumentOutOfRangeException.ThrowIfGreaterThan((uint)recordID, 3u);
|
||||
return ReadInt32LittleEndian(Data[(0x138 + (4 * recordID))..]);
|
||||
}
|
||||
|
||||
public void SetSurfScore(int recordID, int score)
|
||||
{
|
||||
if ((uint)recordID >= 4)
|
||||
recordID = 0;
|
||||
ArgumentOutOfRangeException.ThrowIfGreaterThan((uint)recordID, 3u);
|
||||
WriteInt32LittleEndian(Data[(0x138 + (4 * recordID))..], score);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,10 +10,11 @@ public sealed class WormholeInfoReader(SAV7 SAV)
|
|||
// https://projectpokemon.org/home/forums/topic/39433-gen-7-save-research-thread/?page=3&tab=comments#comment-239090
|
||||
public bool WormholeShininess // 0x4535 = Misc (0x4400 in US/UM) + 0x0135
|
||||
{
|
||||
get => SAV.Misc.Data[0x0135] == 1;
|
||||
set => SAV.Misc.Data[0x0135] = value ? (byte)1 : (byte)0;
|
||||
get => SAV.Misc.IsWormholeShiny;
|
||||
set => SAV.Misc.IsWormholeShiny = value;
|
||||
}
|
||||
|
||||
/// <summary> Inclusive maximum </summary>
|
||||
public const int WormholeSlotMax = 15;
|
||||
|
||||
// Slots currently use digits 1 through 15 inclusively.
|
||||
|
@ -128,7 +129,7 @@ public sealed class WormholeInfoReader(SAV7 SAV)
|
|||
|
||||
public static ushort WormholeSlotToPokemon(int mapid, int slot)
|
||||
{
|
||||
if (slot is < 1 or > WormholeSlotMax)
|
||||
if ((uint)slot > WormholeSlotMax)
|
||||
return 0;
|
||||
|
||||
return mapid switch
|
||||
|
|
Loading…
Reference in a new issue