Update database to load formats correctly

This commit is contained in:
Kaphotics 2016-06-27 22:20:31 -07:00
parent 44fd5ca07c
commit 6ddaa036d4
2 changed files with 8 additions and 8 deletions

View file

@ -52,19 +52,19 @@ namespace PKHeX
} }
return -1; return -1;
} }
internal static PKM getPKMfromBytes(byte[] data) internal static PKM getPKMfromBytes(byte[] data, string ident = null)
{ {
checkEncrypted(ref data); checkEncrypted(ref data);
switch (getPKMDataFormat(data)) switch (getPKMDataFormat(data))
{ {
case 3: case 3:
return new PK3(data); return new PK3(data, ident);
case 4: case 4:
return new PK4(data); return new PK4(data, ident);
case 5: case 5:
return new PK5(data); return new PK5(data, ident);
case 6: case 6:
return new PK6(data); return new PK6(data, ident);
default: default:
return null; return null;
} }

View file

@ -90,13 +90,13 @@ namespace PKHeX
{ {
FileInfo fi = new FileInfo(file); FileInfo fi = new FileInfo(file);
if (fi.Extension.Contains(".pk") && PKX.getIsPKM(fi.Length)) if (fi.Extension.Contains(".pk") && PKX.getIsPKM(fi.Length))
Database[0].Slot.Add(new PK6(File.ReadAllBytes(file), file)); Database[0].Slot.Add(PKMConverter.getPKMfromBytes(File.ReadAllBytes(file), file));
else else
loadDatabase(File.ReadAllBytes(file)); loadDatabase(File.ReadAllBytes(file));
} }
// Fetch from save file // Fetch from save file
foreach (var pk6 in Main.SAV.BoxData.Where(pk => pk.Species != 0)) foreach (var pkm in Main.SAV.BoxData.Where(pk => pk.Species != 0))
Database[0].Slot.Add(pk6); Database[0].Slot.Add(pkm);
// Prepare Database // Prepare Database
prepareDBForSearch(); prepareDBForSearch();