diff --git a/PKHeX.Core/Game/GameStrings/GameStrings.cs b/PKHeX.Core/Game/GameStrings/GameStrings.cs
index 55541c1d1..e9d5b58b4 100644
--- a/PKHeX.Core/Game/GameStrings/GameStrings.cs
+++ b/PKHeX.Core/Game/GameStrings/GameStrings.cs
@@ -81,7 +81,7 @@ public GameStrings(string l)
metGSC_00000 = Get("gsc_00000");
metCXD_00000 = Get("cxd_00000");
- metCXD_00000 = SanitizeMetStringsCXD(metCXD_00000);
+ SanitizeMetStringsCXD(metCXD_00000);
// Current Generation strings
natures = Util.GetNaturesList(l);
@@ -154,18 +154,16 @@ public GameStrings(string l)
Get("mail4").CopyTo(g4items, 137);
}
- private static string[] SanitizeMetStringsCXD(string[] cxd)
+ private static void SanitizeMetStringsCXD(string[] cxd)
{
- // Mark duplicate locations with their index
- var metSanitize = (string[])cxd.Clone();
- for (int i = 0; i < metSanitize.Length; i++)
+ // Less than 10% of met location values are unique.
+ // Just mark them with the ID if they aren't empty.
+ for (int i = 0; i < 227; i++)
{
- var met = metSanitize[i];
- if (cxd.Count(z => z == met) > 1)
- metSanitize[i] += $" [{i:000}]";
+ var str = cxd[i];
+ if (str.Length != 0)
+ cxd[i] = $"{str} [{i:000}]";
}
-
- return metSanitize;
}
private void Sanitize()
diff --git a/PKHeX.Core/Legality/Learnset/LearnsetReader.cs b/PKHeX.Core/Legality/Learnset/LearnsetReader.cs
index 0de76e95b..069da15de 100644
--- a/PKHeX.Core/Legality/Learnset/LearnsetReader.cs
+++ b/PKHeX.Core/Legality/Learnset/LearnsetReader.cs
@@ -60,7 +60,7 @@ private static Learnset ReadLearnset8(byte[] data, ref int offset)
/// Count of moves, followed by Moves and Levels which are 16-bit
private static Learnset ReadLearnset16(byte[] data)
{
- if (data.Length < 4 || data.Length % 4 != 0)
+ if (data.Length == 0)
return EMPTY;
var Count = (data.Length / 4) - 1;
var Moves = new int[Count];
diff --git a/PKHeX.Core/Legality/Structures/EggMoves.cs b/PKHeX.Core/Legality/Structures/EggMoves.cs
index 37b2b2faf..aec0b9db7 100644
--- a/PKHeX.Core/Legality/Structures/EggMoves.cs
+++ b/PKHeX.Core/Legality/Structures/EggMoves.cs
@@ -12,22 +12,30 @@ public abstract class EggMoves
public sealed class EggMoves2 : EggMoves
{
- private EggMoves2(byte[] data) : base(data.Select(i => (int)i).ToArray()) { }
+ private EggMoves2(int[] moves) : base(moves) { }
- public static EggMoves[] GetArray(byte[] data, int count)
+ public static EggMoves2[] GetArray(byte[] data, int count)
{
- int[] ptrs = new int[count+1];
- int baseOffset = (data[1] << 8 | data[0]) - (count * 2);
- for (int i = 1; i < ptrs.Length; i++)
- {
- var ofs = (i - 1) * 2;
- ptrs[i] = (data[ofs + 1] << 8 | data[ofs]) - baseOffset;
- }
+ var entries = new EggMoves2[count + 1];
+ var empty = entries[0] = new EggMoves2(Array.Empty());
- EggMoves[] entries = new EggMoves[count + 1];
- entries[0] = new EggMoves2(Array.Empty());
+ int baseOffset = BitConverter.ToInt16(data, 0) - (count * 2);
for (int i = 1; i < entries.Length; i++)
- entries[i] = new EggMoves2(data.Skip(ptrs[i]).TakeWhile(b => b != 0xFF).ToArray());
+ {
+ int start = BitConverter.ToInt16(data, (i - 1) * 2) - baseOffset;
+ int end = Array.FindIndex(data, start, z => z == 0xFF);
+ if (start == end)
+ {
+ entries[i] = empty;
+ continue;
+ }
+
+ int[] moves = new int[end - start];
+ for (int m = start; m < end; m++)
+ moves[m - start] = data[m];
+
+ entries[i] = new EggMoves2(moves);
+ }
return entries;
}
@@ -41,7 +49,7 @@ public sealed class EggMoves6 : EggMoves
private static EggMoves6 Get(byte[] data)
{
- if (data.Length < 2 || data.Length % 2 != 0)
+ if (data.Length == 0)
return None;
int count = BitConverter.ToInt16(data, 0);
@@ -69,7 +77,7 @@ public sealed class EggMoves7 : EggMoves
private static EggMoves7 Get(byte[] data)
{
- if (data.Length < 2 || data.Length % 2 != 0)
+ if (data.Length == 0)
return None;
int formIndex = BitConverter.ToInt16(data, 0);