Refactoring

No functional changes
This commit is contained in:
Kaphotics 2016-04-21 18:48:21 -07:00
parent 2c523dcd97
commit 2c233be43f
3 changed files with 15 additions and 12 deletions

View File

@ -8,8 +8,8 @@ public static partial class Legal
// PKHeX master Wonder Card Database
internal static WC6[] WC6DB;
// PKHeX master personal.dat
internal static readonly PersonalInfo[] PersonalAO = PersonalInfo.getPersonalArray(Properties.Resources.personal_ao, PersonalInfo.SizeAO);
private static readonly PersonalInfo[] PersonalXY = PersonalInfo.getPersonalArray(Properties.Resources.personal_xy, PersonalInfo.SizeXY);
internal static readonly PersonalInfo[] PersonalAO = PersonalInfo.getArray(Properties.Resources.personal_ao, PersonalInfo.SizeAO);
private static readonly PersonalInfo[] PersonalXY = PersonalInfo.getArray(Properties.Resources.personal_xy, PersonalInfo.SizeXY);
private static readonly EggMoves[] EggMoveXY = EggMoves.getArray(Data.unpackMini(Properties.Resources.eggmove_xy, "xy"));
private static readonly Learnset[] LevelUpXY = Learnset.getArray(Data.unpackMini(Properties.Resources.lvlmove_xy, "xy"));
private static readonly EggMoves[] EggMoveAO = EggMoves.getArray(Data.unpackMini(Properties.Resources.eggmove_ao, "ao"));

View File

@ -344,7 +344,7 @@ public int RandomGender
}
public bool HasFormes => FormeCount > 1;
internal static PersonalInfo[] getPersonalArray(byte[] data, int size)
internal static PersonalInfo[] getArray(byte[] data, int size)
{
PersonalInfo[] d = new PersonalInfo[data.Length / size];
for (int i = 0; i < d.Length; i++)

View File

@ -556,20 +556,23 @@ internal static uint getRandomPID(int species, int cg, int origin, int nature, i
// SAV Manipulation
/// <summary>Calculates the CRC16-CCITT checksum over an input byte array.</summary>
/// <param name="chunk">Input byte array</param>
/// <param name="data">Input byte array</param>
/// <returns>Checksum</returns>
internal static ushort ccitt16(byte[] chunk)
internal static ushort ccitt16(byte[] data)
{
ushort crc = 0xFFFF;
foreach (byte t in chunk)
const ushort init = 0xFFFF;
const ushort poly = 0x1021;
ushort crc = init;
foreach (byte b in data)
{
crc ^= (ushort)(t << 8);
crc ^= (ushort)(b << 8);
for (int j = 0; j < 8; j++)
{
if ((crc & 0x8000) > 0)
crc = (ushort)(crc << 1 ^ 0x1021);
else
crc <<= 1;
bool flag = (crc & 0x8000) > 0;
crc <<= 1;
if (flag)
crc ^= poly;
}
}
return crc;