mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-05-23 12:26:09 -05:00
Fix broken tests
some gen6 cards have bad data? trickled out to tests which failed to generate a celebi revert to old code, add in some year-set safety checks
This commit is contained in:
parent
f6da84b699
commit
96ec0ff28b
|
|
@ -69,7 +69,7 @@ private uint Day
|
|||
set => RawDate = SetDate(Year, Month, value);
|
||||
}
|
||||
|
||||
private static uint SetDate(uint year, uint month, uint day) => ((year - 2000) * 10000) + (month * 100) + day;
|
||||
private static uint SetDate(uint year, uint month, uint day) => Math.Max(0, year - 2000) * 10000 + (month * 100) + day;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the date of the card.
|
||||
|
|
|
|||
|
|
@ -18,21 +18,21 @@ public sealed class WC6 : MysteryGift, IRibbonSetEvent3, IRibbonSetEvent4, ILang
|
|||
|
||||
public WC6(byte[] data)
|
||||
{
|
||||
Data = data;
|
||||
if (Data.Length != SizeFull)
|
||||
return;
|
||||
Data = data; if (Data.Length == SizeFull)
|
||||
{
|
||||
// Load Restrictions
|
||||
RestrictVersion = Data[0x000];
|
||||
RestrictLanguage = Data[0x1FF];
|
||||
byte[] wc6 = new byte[Size];
|
||||
if (Data[0x205] != 0) // Valid data
|
||||
Array.Copy(Data, SizeFull - Size, wc6, 0, wc6.Length);
|
||||
Data = wc6;
|
||||
|
||||
// Load Restrictions
|
||||
RestrictVersion = Data[0x000];
|
||||
RestrictLanguage = Data[0x1FF];
|
||||
|
||||
byte[] wc6 = new byte[Size];
|
||||
if (Data[0x205] != 0) // Valid data
|
||||
Array.Copy(Data, SizeFull - Size, wc6, 0, wc6.Length);
|
||||
Data = wc6;
|
||||
|
||||
DateTime now = DateTime.Now;
|
||||
RawDate = SetDate((uint) now.Year, (uint) now.Month, (uint) now.Day);
|
||||
DateTime now = DateTime.Now;
|
||||
SetDate((uint) now.Year, (uint) now.Month, (uint) now.Day);
|
||||
}
|
||||
if (Year < 2000)
|
||||
Data = new byte[Data.Length]; // Invalidate
|
||||
}
|
||||
|
||||
public int RestrictLanguage { get; set; } = 0; // None
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ private uint Day
|
|||
set => RawDate = SetDate(Year, Month, value);
|
||||
}
|
||||
|
||||
private static uint SetDate(uint year, uint month, uint day) => ((year - 2000) * 10000) + (month * 100) + day;
|
||||
private static uint SetDate(uint year, uint month, uint day) => Math.Max(0, year - 2000) * 10000 + (month * 100) + day;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the date of the card.
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user