mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-27 06:20:25 +00:00
Redirect eventflag r/w for frlg
can't just re-call base.SetEventFlag with an adjusted flag ID since the exception checks max. just override the geteventflag method with a silly adjustment -- we can't be sure if Block2 is immediately after Block2, so just adjust the flag r/w to a different offset&flag when appropriate. fixes r/s badgeflag get/set, oops, meant to modify FRLG's value in the last commit.
This commit is contained in:
parent
a38a0fed60
commit
10d73d1bf3
2 changed files with 33 additions and 5 deletions
|
@ -156,7 +156,7 @@ namespace PKHeX.Core
|
|||
OFS_PouchBerry = BlockOfs[1] + 0x054C;
|
||||
SeenFlagOffsets = new[] { PokeDex + 0x44, BlockOfs[1] + 0x5F8, BlockOfs[4] + 0xB98 };
|
||||
EventFlag = BlockOfs[1] + 0xEE0;
|
||||
EventConst = EventFlag + (EventFlagMax / 8);
|
||||
EventConst = BlockOfs[2] + 0x80; // EventFlag + (EventFlagMax / 8);
|
||||
Daycare = BlockOfs[4] + 0x100;
|
||||
break;
|
||||
}
|
||||
|
@ -381,6 +381,34 @@ namespace PKHeX.Core
|
|||
set => Data[BlockOfs[0] + 0x12] = (byte)value;
|
||||
}
|
||||
|
||||
public override bool GetEventFlag(int flagNumber)
|
||||
{
|
||||
if (flagNumber > EventFlagMax)
|
||||
throw new ArgumentException($"Event Flag to get ({flagNumber}) is greater than max ({EventFlagMax}).");
|
||||
|
||||
var start = EventFlag;
|
||||
if (Version == GameVersion.FRLG && flagNumber >= 0x500)
|
||||
{
|
||||
flagNumber -= 0x500;
|
||||
start = BlockOfs[2];
|
||||
}
|
||||
return GetFlag(start + (flagNumber >> 3), flagNumber & 7);
|
||||
}
|
||||
|
||||
public override void SetEventFlag(int flagNumber, bool value)
|
||||
{
|
||||
if (flagNumber > EventFlagMax)
|
||||
throw new ArgumentException($"Event Flag to set ({flagNumber}) is greater than max ({EventFlagMax}).");
|
||||
|
||||
var start = EventFlag;
|
||||
if (Version == GameVersion.FRLG && flagNumber >= 0x500)
|
||||
{
|
||||
flagNumber -= 0x500;
|
||||
start = BlockOfs[2];
|
||||
}
|
||||
SetFlag(start + (flagNumber >> 3), flagNumber & 7, value);
|
||||
}
|
||||
|
||||
public int Badges
|
||||
{
|
||||
get
|
||||
|
@ -408,9 +436,9 @@ namespace PKHeX.Core
|
|||
get
|
||||
{
|
||||
if (Version == GameVersion.FRLG)
|
||||
return 800; // dec
|
||||
return 0x820;
|
||||
if (Version == GameVersion.RS)
|
||||
return 0x820; // hex
|
||||
return 0x807;
|
||||
return 0x867; // emerald
|
||||
}
|
||||
}
|
||||
|
|
|
@ -309,7 +309,7 @@ namespace PKHeX.Core
|
|||
/// </summary>
|
||||
/// <param name="flagNumber">Event Flag to check</param>
|
||||
/// <returns>Flag is Set (true) or not Set (false)</returns>
|
||||
public bool GetEventFlag(int flagNumber)
|
||||
public virtual bool GetEventFlag(int flagNumber)
|
||||
{
|
||||
if (flagNumber > EventFlagMax)
|
||||
throw new ArgumentException($"Event Flag to get ({flagNumber}) is greater than max ({EventFlagMax}).");
|
||||
|
@ -322,7 +322,7 @@ namespace PKHeX.Core
|
|||
/// <param name="flagNumber">Event Flag to check</param>
|
||||
/// <param name="value">Event Flag status to set</param>
|
||||
/// <remarks>Flag is Set (true) or not Set (false)</remarks>
|
||||
public void SetEventFlag(int flagNumber, bool value)
|
||||
public virtual void SetEventFlag(int flagNumber, bool value)
|
||||
{
|
||||
if (flagNumber > EventFlagMax)
|
||||
throw new ArgumentException($"Event Flag to set ({flagNumber}) is greater than max ({EventFlagMax}).");
|
||||
|
|
Loading…
Reference in a new issue