Update 22.06.01

This commit is contained in:
Kurt 2022-06-01 21:27:54 -07:00
parent 2f44d7486f
commit f2356f1865
10 changed files with 115 additions and 29 deletions

View file

@ -374,6 +374,8 @@ namespace PKHeX.Core
return 0x124 + (index * 0x1C); return 0x124 + (index * 0x1C);
} }
public bool IsHOMEGift => CardID >= 9000;
public bool CanHandleOT(int language) => !GetHasOT(language); public bool CanHandleOT(int language) => !GetHasOT(language);
public override GameVersion Version public override GameVersion Version
@ -468,6 +470,10 @@ namespace PKHeX.Core
pk.MetDate = IsDateRestricted && EncounterServerDate.WA8Gifts.TryGetValue(CardID, out var dt) ? dt.Start : DateTime.Now; pk.MetDate = IsDateRestricted && EncounterServerDate.WA8Gifts.TryGetValue(CardID, out var dt) ? dt.Start : DateTime.Now;
// HOME Gifts for Sinnoh/Hisui starters were forced JPN until May 20, 2022 (UTC).
if (CardID is 9018 or 9019 or 9020)
pk.Met_Day = 20;
var nickname_language = GetLanguage(language); var nickname_language = GetLanguage(language);
pk.Language = nickname_language != 0 ? nickname_language : sav.Language; pk.Language = nickname_language != 0 ? nickname_language : sav.Language;
pk.IsNicknamed = GetIsNicknamed(language); pk.IsNicknamed = GetIsNicknamed(language);
@ -539,9 +545,24 @@ namespace PKHeX.Core
ShinyType8.Random => Util.Rand32(), // Random, Any ShinyType8.Random => Util.Rand32(), // Random, Any
ShinyType8.AlwaysStar => (uint)(((tr.TID ^ tr.SID ^ (PID & 0xFFFF) ^ 1) << 16) | (PID & 0xFFFF)), // Fixed, Force Star ShinyType8.AlwaysStar => (uint)(((tr.TID ^ tr.SID ^ (PID & 0xFFFF) ^ 1) << 16) | (PID & 0xFFFF)), // Fixed, Force Star
ShinyType8.AlwaysSquare => (uint)(((tr.TID ^ tr.SID ^ (PID & 0xFFFF) ^ 0) << 16) | (PID & 0xFFFF)), // Fixed, Force Square ShinyType8.AlwaysSquare => (uint)(((tr.TID ^ tr.SID ^ (PID & 0xFFFF) ^ 0) << 16) | (PID & 0xFFFF)), // Fixed, Force Square
ShinyType8.FixedValue => PID, // Fixed, Force Value ShinyType8.FixedValue => GetFixedPID(tr),
_ => throw new ArgumentOutOfRangeException(nameof(type)), _ => throw new ArgumentOutOfRangeException(nameof(type)),
}; };
private uint GetFixedPID(ITrainerID tr)
{
var pid = PID;
if (!tr.IsShiny(pid, 8))
return pid;
if (IsHOMEGift)
return GetAntishinyFixedHOME(tr);
return pid;
}
private static uint GetAntishinyFixedHOME(ITrainerID tr)
{
var fid = ((uint)(tr.SID << 16) | (uint)tr.TID);
return fid ^ 0x10u;
}
private static uint GetAntishiny(ITrainerID tr) private static uint GetAntishiny(ITrainerID tr)
{ {
@ -600,7 +621,11 @@ namespace PKHeX.Core
var OT = GetOT(pkm.Language); // May not be guaranteed to work. var OT = GetOT(pkm.Language); // May not be guaranteed to work.
if (!string.IsNullOrEmpty(OT) && OT != pkm.OT_Name) return false; if (!string.IsNullOrEmpty(OT) && OT != pkm.OT_Name) return false;
if (OriginGame != 0 && OriginGame != pkm.Version) return false; if (OriginGame != 0 && OriginGame != pkm.Version)
{
if (OriginGame is (int)GameVersion.PLA && !(pkm.Version is (int)GameVersion.SW && pkm.Met_Location == Locations.HOME_SWLA))
return false;
}
if (EncryptionConstant != 0) if (EncryptionConstant != 0)
{ {
if (EncryptionConstant != pkm.EncryptionConstant) if (EncryptionConstant != pkm.EncryptionConstant)

View file

@ -443,6 +443,8 @@ namespace PKHeX.Core
Met_Location = MetLocation, Met_Location = MetLocation,
Egg_Location = EggLocation, Egg_Location = EggLocation,
}; };
if (EggLocation == 0)
pk.Egg_Location = Locations.Default8bNone;
if (Species == (int)Core.Species.Manaphy && IsEgg) if (Species == (int)Core.Species.Manaphy && IsEgg)
{ {
@ -466,7 +468,10 @@ namespace PKHeX.Core
pk.SID = sav.SID; pk.SID = sav.SID;
} }
pk.MetDate = DateTime.Now; pk.MetDate = IsDateRestricted && EncounterServerDate.WA8Gifts.TryGetValue(CardID, out var dt) ? dt.Start : DateTime.Now;
// HOME Gifts for Sinnoh/Hisui starters were forced JPN until May 20, 2022 (UTC).
if (CardID is 9015 or 9016 or 9017)
pk.Met_Day = 20;
var nickname_language = GetLanguage(language); var nickname_language = GetLanguage(language);
pk.Language = nickname_language != 0 ? nickname_language : sav.Language; pk.Language = nickname_language != 0 ? nickname_language : sav.Language;
@ -530,30 +535,43 @@ namespace PKHeX.Core
_ => AbilityPermission.Any12H, _ => AbilityPermission.Any12H,
}; };
private uint GetPID(ITrainerID tr, byte type) private uint GetPID(ITrainerID tr, ShinyType8 type) => type switch
{ {
return type switch ShinyType8.Never => GetAntishiny(tr), // Random, Never Shiny
{ ShinyType8.Random => Util.Rand32(), // Random, Any
0 => GetAntishiny(tr), // Random, Never Shiny ShinyType8.AlwaysStar => (uint)(((tr.TID ^ tr.SID ^ (PID & 0xFFFF) ^ 1) << 16) | (PID & 0xFFFF)), // Fixed, Force Star
1 => Util.Rand32(), // Random, Any ShinyType8.AlwaysSquare => (uint)(((tr.TID ^ tr.SID ^ (PID & 0xFFFF) ^ 0) << 16) | (PID & 0xFFFF)), // Fixed, Force Square
2 => (uint) (((tr.TID ^ tr.SID ^ (PID & 0xFFFF) ^ 1) << 16) | (PID & 0xFFFF)), // Fixed, Force Star ShinyType8.FixedValue => GetFixedPID(tr),
3 => (uint) (((tr.TID ^ tr.SID ^ (PID & 0xFFFF) ^ 0) << 16) | (PID & 0xFFFF)), // Fixed, Force Square
4 => PID, // Fixed, Force Value
_ => throw new ArgumentOutOfRangeException(nameof(type)), _ => throw new ArgumentOutOfRangeException(nameof(type)),
}; };
static uint GetAntishiny(ITrainerID tr) private uint GetFixedPID(ITrainerID tr)
{
var pid = PID;
if (!tr.IsShiny(pid, 8))
return pid;
if (IsHOMEGift)
return GetAntishinyFixedHOME(tr);
return pid;
}
private static uint GetAntishinyFixedHOME(ITrainerID tr)
{
var fid = ((uint)(tr.SID << 16) | (uint)tr.TID);
return fid ^ 0x10u;
}
private static uint GetAntishiny(ITrainerID tr)
{ {
var pid = Util.Rand32(); var pid = Util.Rand32();
if (tr.IsShiny(pid, 8)) if (tr.IsShiny(pid, 8))
return pid ^ 0x1000_0000; return pid ^ 0x1000_0000;
return pid; return pid;
} }
}
private void SetPID(PKM pk) private void SetPID(PKM pk)
{ {
pk.PID = GetPID(pk, PIDTypeValue); pk.PID = GetPID(pk, PIDType);
} }
private void SetIVs(PKM pk) private void SetIVs(PKM pk)
@ -600,7 +618,13 @@ namespace PKHeX.Core
var OT = GetOT(pkm.Language); // May not be guaranteed to work. var OT = GetOT(pkm.Language); // May not be guaranteed to work.
if (!string.IsNullOrEmpty(OT) && OT != pkm.OT_Name) return false; if (!string.IsNullOrEmpty(OT) && OT != pkm.OT_Name) return false;
if (OriginGame != 0 && OriginGame != pkm.Version) return false; if (OriginGame != 0 && OriginGame != pkm.Version)
{
if (OriginGame is (int)GameVersion.BD && !(pkm.Version is (int)GameVersion.SW && pkm.Met_Location == Locations.HOME_SWBD))
return false;
if (OriginGame is (int)GameVersion.SP && !(pkm.Version is (int)GameVersion.SH && pkm.Met_Location == Locations.HOME_SHSP))
return false;
}
if (EncryptionConstant != 0) if (EncryptionConstant != 0)
{ {
if (EncryptionConstant != pkm.EncryptionConstant) if (EncryptionConstant != pkm.EncryptionConstant)
@ -657,7 +681,7 @@ namespace PKHeX.Core
var type = PIDTypeValue; var type = PIDTypeValue;
if (type <= 1) if (type <= 1)
return true; return true;
return pkm.PID == GetPID(pkm, type); return pkm.PID == GetPID(pkm, (ShinyType8)type);
} }
protected override bool IsMatchEggLocation(PKM pk) protected override bool IsMatchEggLocation(PKM pk)

View file

@ -83,7 +83,7 @@ namespace PKHeX.Core
public override Shiny Shiny => PIDType switch public override Shiny Shiny => PIDType switch
{ {
ShinyType8.FixedValue => IsHOMEGift && IsHOMEShinyPossible() ? Shiny.Random : GetShinyXor() switch ShinyType8.FixedValue => IsHOMEGift && IsHOMEShinyPossible(DateTime.Now) ? Shiny.Random : GetShinyXor() switch
{ {
0 => Shiny.AlwaysSquare, 0 => Shiny.AlwaysSquare,
<= 15 => Shiny.AlwaysStar, <= 15 => Shiny.AlwaysStar,
@ -534,10 +534,26 @@ namespace PKHeX.Core
ShinyType8.Random => Util.Rand32(), // Random, Any ShinyType8.Random => Util.Rand32(), // Random, Any
ShinyType8.AlwaysStar => (uint) (((tr.TID ^ tr.SID ^ (PID & 0xFFFF) ^ 1) << 16) | (PID & 0xFFFF)), // Fixed, Force Star ShinyType8.AlwaysStar => (uint) (((tr.TID ^ tr.SID ^ (PID & 0xFFFF) ^ 1) << 16) | (PID & 0xFFFF)), // Fixed, Force Star
ShinyType8.AlwaysSquare => (uint) (((tr.TID ^ tr.SID ^ (PID & 0xFFFF) ^ 0) << 16) | (PID & 0xFFFF)), // Fixed, Force Square ShinyType8.AlwaysSquare => (uint) (((tr.TID ^ tr.SID ^ (PID & 0xFFFF) ^ 0) << 16) | (PID & 0xFFFF)), // Fixed, Force Square
ShinyType8.FixedValue => PID, // Fixed, Force Value ShinyType8.FixedValue => GetFixedPID(tr),
_ => throw new ArgumentOutOfRangeException(nameof(type)), _ => throw new ArgumentOutOfRangeException(nameof(type)),
}; };
private uint GetFixedPID(ITrainerID tr)
{
var pid = PID;
if (!tr.IsShiny(pid, 8))
return pid;
if (IsHOMEGift && !IsHOMEShinyPossible(DateTime.Now))
return GetAntishinyFixedHOME(tr);
return pid;
}
private static uint GetAntishinyFixedHOME(ITrainerID tr)
{
var fid = ((uint)(tr.SID << 16) | (uint)tr.TID);
return fid ^ 0x10u;
}
private static uint GetAntishiny(ITrainerID tr) private static uint GetAntishiny(ITrainerID tr)
{ {
var pid = Util.Rand32(); var pid = Util.Rand32();
@ -617,7 +633,7 @@ namespace PKHeX.Core
} }
else // Never or Random (HOME ID specific) else // Never or Random (HOME ID specific)
{ {
if (pkm.IsShiny && !IsHOMEShinyPossible()) if (pkm.IsShiny && !IsHOMEShinyPossible(pkm.MetDate ?? DateTime.Now))
return false; return false;
} }
} }
@ -683,10 +699,10 @@ namespace PKHeX.Core
return pkm.PID == GetPID(pkm, type); return pkm.PID == GetPID(pkm, type);
} }
private bool IsHOMEShinyPossible() private bool IsHOMEShinyPossible(DateTime date)
{ {
// no defined TID/SID and having a fixed PID can cause the player's TID/SID to match the PID's shiny calc. // no defined TID/SID and having a fixed PID can cause the player's TID/SID to match the PID's shiny calc.
return TID == 0 && SID == 0 && PID != 0; return TID == 0 && SID == 0 && PID != 0 && (CardID < 9015 && date < new DateTime(2022, 5, 18));
} }
public bool IsDateRestricted => IsHOMEGift; public bool IsDateRestricted => IsHOMEGift;

View file

@ -12,7 +12,7 @@
<ApplicationIcon>Resources\icon.ico</ApplicationIcon> <ApplicationIcon>Resources\icon.ico</ApplicationIcon>
<StartupObject>PKHeX.WinForms.Program</StartupObject> <StartupObject>PKHeX.WinForms.Program</StartupObject>
<AssemblyName>PKHeX</AssemblyName> <AssemblyName>PKHeX</AssemblyName>
<Version>22.05.08</Version> <Version>22.06.01</Version>
<LangVersion>10</LangVersion> <LangVersion>10</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>

View file

@ -1,7 +1,28 @@
PKHeX - By Kaphotics PKHeX - By Kaphotics
http://projectpokemon.org/pkhex/ http://projectpokemon.org/pkhex/
22/05/08 - New Update: 22/06/01 - New Update:
- Legality:
- - Added: HOME 2.0.0 support. Thanks @SciresM, @sora10pls, @Lusamine, & all contributing via the Discord server!
- - Changed: Revises legality checks to account for traveling between the three game islands (PLA/BDSP/SWSH)
- - Changed: Evolution History is now tracked in the Legality parse for specific contexts, rather than by generation only.
- - Fixed: More Gen1/2 tradeback edge cases are handled correctly.
- Added: HOME 2.0.0 conversion mechanisms between the three formats.
- Added: HOME 2.0.0 flexible conversion options to backfill missing data when converting from SW/SH back to PLA/BD/SP.
- Added: HOME 2.0.0 abstractions for HOME data storage format (EKH/PKH format 1, aka EH1/PH1).
- Added: `PKM` now exposes a `Context` to indicate the isolation context for legality purposes.
- Added: Gen8 BDSP misc editor can now unlock Arceus encounter same as Darkrai and Shaymin. Thanks @sora10pls!
- Fixed: Gen5 C-Gear Skins with incorrect file formats (not 32bit argb) show an error dialog rather than crash-erroring.
- Fixed: Gen5 Entree Forest/Misc5 out-of-range values no longer throw an error when the editor opens.
- Fixed: Loading a PKM while viewing an extrabyte index now correctly loads the new extrabyte value.
- Fixed: Gen8 PLA Initial mastery move flags are now suggested correctly for edge cases.
- Fixed: PKM Editor GUI controls now better aligned/sized with similar controls (ex: OT editing).
- Fixed: Drag & Drop now works correctly within the program. Still recommended to use ctrl/shift hotkeys!
- Removed: HaX mode can no longer change Stat_Level separately from Current Level. Set it via the batch editor instead.
- Changed: Enhanced the Gen1/2 Stadium save detection to now detect correctly if no team data has been set.
- Changed: Italian translation improved (GUI+Legality). Thanks @Manu098vm !
22/05/08 - New Update: (94641) [4908732]
- Legality: - Legality:
- - Added: PLA move mastery/purchased flags are now legality checked thoroughly. Thanks @Lusamine & @Atrius97 ! - - Added: PLA move mastery/purchased flags are now legality checked thoroughly. Thanks @Lusamine & @Atrius97 !
- - Added: PLA event gifts are now checked for their date obtained. - - Added: PLA event gifts are now checked for their date obtained.