Misc tweaks

RNG frame mismatch -> fishy (for now)
fix xmldoc copypaste
clean up some resharper warnings
This commit is contained in:
Kurt 2017-12-04 16:26:26 -08:00
parent 5a69f1d596
commit 3d7b2a2b29
8 changed files with 40 additions and 30 deletions

View file

@ -47,7 +47,7 @@ namespace PKHeX.Core
}
if (!info.FrameMatches && info.EncounterMatch is EncounterSlot && pkm.Version != (int)GameVersion.CXD) // if false, all valid RNG frame matches have already been consumed
info.Parse.Add(new CheckResult(Severity.Invalid, V400, CheckIdentifier.PID));
info.Parse.Add(new CheckResult(Severity.Fishy, V400, CheckIdentifier.PID)); // todo for further confirmation
if (!info.PIDIVMatches) // if false, all valid PIDIV matches have already been consumed
info.Parse.Add(new CheckResult(Severity.Invalid, V411, CheckIdentifier.PID));

View file

@ -1397,7 +1397,6 @@ namespace PKHeX.Core
return true;
}
// EncounterEgg
private static IEnumerable<EncounterEgg> GenerateEggs(PKM pkm)
{

View file

@ -132,9 +132,8 @@ namespace PKHeX.Core
private int storageBlock = -1; // Big Block
private int hofBlock = -1; // Hall of Fame Block
private int SBO => 0x40000 * storageBlock;
private int GBO => 0x40000 * generalBlock;
public int GBO => 0x40000 * generalBlock;
private int HBO => 0x40000 * hofBlock;
public int GetGBO => GBO;
private void GetActiveGeneralBlock()
{
if (Version < 0)

View file

@ -647,7 +647,7 @@ namespace PKHeX.Core
chk = (ushort) (crc16[(data[i] ^ chk) & 0xFF] ^ chk >> 8);
return (ushort)~chk;
}
/// <summary>Calculates the 32bit checksum over an input byte array. Used in GBA save files.</summary>
/// <summary>Calculates the 16bit checksum over an input byte array. Used in Gen7 save files.</summary>
/// <param name="data">Input byte array</param>
/// <param name="initial">Initial value for checksum</param>
/// <returns>Checksum</returns>

View file

@ -10,12 +10,16 @@ namespace PKHeX.Core
public Mail3(SAV3 sav, int index)
{
DataOffset = index * SIZE + sav.GetBlockOffset(3) + 0xCE0;
Data = sav.GetData(DataOffset, 0x24);
Data = sav.GetData(DataOffset, SIZE);
}
public Mail3()
{
Data = new byte[0x24];
Data = new byte[SIZE];
DataOffset = -1;
ResetData();
}
private void ResetData()
{
for (int y = 0; y < 3; y++)
for (int x = 0; x < 3; x++)
SetMessage(y, x, 0xFFFF);
@ -37,7 +41,7 @@ namespace PKHeX.Core
else
{
Data[0x18] = Data[0x19] = 0xFF;
StringConverter.SetString3(value, 7, false, 6, 0).CopyTo(Data, 0x12);
StringConverter.SetString3(value, 7, false, 6).CopyTo(Data, 0x12);
}
}
}

View file

@ -10,9 +10,9 @@ namespace PKHeX.Core
{
switch (sav.Version)
{
case GameVersion.DP: DataOffset = index * SIZE + 0x4BEC + sav.GetGBO; break;
case GameVersion.Pt: DataOffset = index * SIZE + 0x4E80 + sav.GetGBO; break;
case GameVersion.HGSS: DataOffset = index * SIZE + 0x3FA8 + sav.GetGBO; break;
case GameVersion.DP: DataOffset = index * SIZE + 0x4BEC + sav.GBO; break;
case GameVersion.Pt: DataOffset = index * SIZE + 0x4E80 + sav.GBO; break;
case GameVersion.HGSS: DataOffset = index * SIZE + 0x3FA8 + sav.GBO; break;
}
Data = sav.GetData(DataOffset, SIZE);
}
@ -25,11 +25,15 @@ namespace PKHeX.Core
{
Data = new byte[SIZE];
DataOffset = -1;
if (lang != null) AuthorLanguage = (byte)lang;
if (ver != null) AuthorVersion = (byte)ver;
ResetData();
}
private void ResetData()
{
AuthorTID = 0;
AuthorSID = 0;
AuthorGender = 0;
if (lang != null) AuthorLanguage = (byte)lang;
if (ver != null) AuthorVersion = (byte)ver;
MailType = 0xFF;
AuthorName = "";
for (int i = 0; i < 3; i++)
@ -59,7 +63,7 @@ namespace PKHeX.Core
return null;
}
}
public override void SetBlank() => SetBlank();
public void SetBlank(byte? lang = null, byte? ver = null) => (new Mail4(lang: lang, ver: ver)).Data.CopyTo(Data, 0);
public override void SetBlank() => SetBlank(null, null);
public void SetBlank(byte? lang, byte? ver) => new Mail4(lang: lang, ver: ver).Data.CopyTo(Data, 0);
}
}

View file

@ -20,19 +20,23 @@ namespace PKHeX.Core
{
Data = new byte[SIZE];
DataOffset = -1;
if (lang != null) AuthorLanguage = (byte)lang;
if (ver != null) AuthorVersion = (byte)ver;
ResetData();
}
private void ResetData()
{
AuthorTID = 0;
AuthorSID = 0;
AuthorGender = 0;
if (lang != null) AuthorLanguage = (byte)lang;
if (ver != null) AuthorVersion = (byte)ver;
MailType = 0xFF;
AuthorName = "";
for (int i = 0; i < 3; i++)
SetMisc(i, 0);
MessageEnding = 0xFFFF;
for (int y = 0; y < 3; y++)
for (int x = 0; x < 4; x++)
SetMessage(y, x, (ushort)(x == 1 ? 0 : 0xFFFF));
for (int x = 0; x < 4; x++)
SetMessage(y, x, (ushort)(x == 1 ? 0 : 0xFFFF));
}
public override void CopyTo(PK5 pk5) => pk5.HeldMailData = Data;
public override ushort AuthorTID { get => BitConverter.ToUInt16(Data, 0); set => BitConverter.GetBytes(value).CopyTo(Data, 0); }
@ -41,7 +45,7 @@ namespace PKHeX.Core
public byte AuthorLanguage { get => Data[5]; set => Data[5] = value; }
public byte AuthorVersion { get => Data[6]; set => Data[6] = value; }
public override int MailType { get => Data[7]; set => Data[7] = (byte)value; }
public override string AuthorName { get => StringConverter.GetString5(Data, 8, 0x10); set => StringConverter.SetString5(value, 7, 8, 0).CopyTo(Data, 8); }
public override string AuthorName { get => StringConverter.GetString5(Data, 8, 0x10); set => StringConverter.SetString5(value, 7, 8).CopyTo(Data, 8); }
public int GetMisc(int index) => BitConverter.ToUInt16(Data, 0x1C - index * 2);
public void SetMisc(int index, int value) => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x1C - index * 2);
public ushort MessageEnding { get => BitConverter.ToUInt16(Data, 0x1E); set => BitConverter.GetBytes(value).CopyTo(Data, 0x1E); }
@ -56,7 +60,7 @@ namespace PKHeX.Core
return null;
}
}
public override void SetBlank() => SetBlank();
public void SetBlank(byte? lang = null, byte? ver = null) => (new Mail5(lang: lang, ver: ver)).Data.CopyTo(Data, 0);
public override void SetBlank() => SetBlank(null, null);
public void SetBlank(byte? lang, byte? ver) => new Mail5(lang: lang, ver: ver).Data.CopyTo(Data, 0);
}
}

View file

@ -18,7 +18,7 @@ namespace PKHeX.WinForms
SAV = (SAV4)(Origin = sav).Clone();
InitializeComponent();
int GBO = SAV.GetGBO;
int GBO = SAV.GBO;
switch (SAV.Version)
{
case GameVersion.D:
@ -573,8 +573,8 @@ namespace PKHeX.WinForms
int Facility = CB_Stats1.SelectedIndex;
int BattleType = CB_Stats2.SelectedIndex;
int RBi = StatRBA[1].Checked ? 1 : 0;
int addrVal = SAV.GetGBO + BFF[Facility][2] + BFF[Facility][3] * BattleType + (RBi << 3);
int addrFlag = SAV.GetGBO + BFF[Facility][4];
int addrVal = SAV.GBO + BFF[Facility][2] + BFF[Facility][3] * BattleType + (RBi << 3);
int addrFlag = SAV.GBO + BFF[Facility][4];
byte maskFlag = (byte)(1 << BattleType + (RBi << 2));
int TowerContinueCountOfs = SAV.DP ? 3 : 1;
@ -657,7 +657,7 @@ namespace PKHeX.WinForms
}
private void GetCastleStat()
{
int ofs = SAV.GetGBO + BFF[3][2] + BFF[3][3] * CB_Stats2.SelectedIndex + 0x0A;
int ofs = SAV.GBO + BFF[3][2] + BFF[3][3] * CB_Stats2.SelectedIndex + 0x0A;
NumericUpDown[] na = { NUD_CastleRankRcv, NUD_CastleRankItem, NUD_CastleRankInfo };
for (int i = 0; i < na.Length; i++)
{
@ -671,11 +671,11 @@ namespace PKHeX.WinForms
NumericUpDown[] na = new[] { NUD_CastleRankRcv, NUD_CastleRankItem, NUD_CastleRankInfo };
int i = Array.IndexOf(na, sender);
if (i < 0) return;
BitConverter.GetBytes((int)na[i].Value).CopyTo(SAV.Data, SAV.GetGBO + BFF[3][2] + BFF[3][3] * CB_Stats2.SelectedIndex + 0x0A + (i << 1));
BitConverter.GetBytes((int)na[i].Value).CopyTo(SAV.Data, SAV.GBO + BFF[3][2] + BFF[3][3] * CB_Stats2.SelectedIndex + 0x0A + (i << 1));
}
private void GetHallStat()
{
int ofscur = SAV.GetGBO + BFF[2][2] + BFF[2][3] * CB_Stats2.SelectedIndex;
int ofscur = SAV.GBO + BFF[2][2] + BFF[2][3] * CB_Stats2.SelectedIndex;
int curspe = BitConverter.ToInt16(SAV.Data, ofscur + 4);
bool c = curspe == species;
CHK_HallCurrent.Checked = c;
@ -703,7 +703,7 @@ namespace PKHeX.WinForms
private void CHK_HallCurrent_CheckedChanged(object sender, EventArgs e)
{
if (editing) return;
BitConverter.GetBytes((ushort)(CHK_HallCurrent.Checked ? species : 0)).CopyTo(SAV.Data, SAV.GetGBO + BFF[2][2] + BFF[2][3] * CB_Stats2.SelectedIndex + 4);
BitConverter.GetBytes((ushort)(CHK_HallCurrent.Checked ? species : 0)).CopyTo(SAV.Data, SAV.GBO + BFF[2][2] + BFF[2][3] * CB_Stats2.SelectedIndex + 4);
editing = true;
GetHallStat();
editing = false;
@ -714,7 +714,7 @@ namespace PKHeX.WinForms
if (editing) return;
int i = Array.IndexOf(HallNUDA, sender);
if (i < 0) return;
int ofs = SAV.GetGBO + BFF[2][2] + BFF[2][3] * CB_Stats2.SelectedIndex + 6 + (i >> 1 << 1);
int ofs = SAV.GBO + BFF[2][2] + BFF[2][3] * CB_Stats2.SelectedIndex + 6 + (i >> 1 << 1);
SAV.Data[ofs] = (byte)(SAV.Data[ofs] & ~(0xF << ((i & 1) << 2)) | (int)HallNUDA[i].Value << ((i & 1) << 2));
L_SumHall.Text = HallNUDA.Sum(x => x.Value).ToString();
}